aboutsummaryrefslogtreecommitdiff
path: root/pkg/service
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-08-04 14:44:36 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-08-04 14:44:36 +0200
commit60004cfb97fe0eb64d1c8310e7c9caae96b8adbe (patch)
tree2267cf703f6870b05d68c73be7af1fc57190e770 /pkg/service
parentaa559681fcf8df993029370f28e0011315ca8761 (diff)
downloadcerrado-60004cfb97fe0eb64d1c8310e7c9caae96b8adbe.tar.gz
cerrado-60004cfb97fe0eb64d1c8310e7c9caae96b8adbe.tar.bz2
cerrado-60004cfb97fe0eb64d1c8310e7c9caae96b8adbe.zip
feat: Add diff view
Adds a very simple diff view for a commit
Diffstat (limited to 'pkg/service')
-rw-r--r--pkg/service/git.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/pkg/service/git.go b/pkg/service/git.go
index b368f0c..f03ba42 100644
--- a/pkg/service/git.go
+++ b/pkg/service/git.go
@@ -140,6 +140,25 @@ func (g *GitService) WriteTarGZip(w io.Writer, name, ref string, prefix string)
return nil
}
+func (g *GitService) Diff(name, ref string) (string, error) {
+ r := g.configRepo.GetByName(name)
+ if r == nil {
+ return "", ErrRepositoryNotFound
+ }
+
+ repo, err := git.OpenRepository(r.Path)
+ if err != nil {
+ return "", err
+ }
+
+ err = repo.SetRef(ref)
+ if err != nil {
+ return "", err
+ }
+
+ return repo.Diff()
+}
+
func (g *GitService) GetTree(name, ref, path string) (*object.Tree, error) {
r := g.configRepo.GetByName(name)
if r == nil {