diff options
Diffstat (limited to 'pkg/service/git.go')
-rw-r--r-- | pkg/service/git.go | 19 |
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 { |