fix commit/diff URLs not using reference param
1 file changed, 6 insertions(+), 4 deletions(-)
changed files
M git/diff.go → git/diff.go
@@ -6,6 +6,7 @@ "log" "strings" "github.com/bluekeyes/go-gitdiff/gitdiff" + "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/object" )@@ -46,8 +47,8 @@ Diff []Diff } // DiffFile returns a diff for a specific file in the current commit -func (g *Repo) DiffFile(filePath string) (*NiceDiff, error) { - niceDiff, err := g.Diff() +func (g *Repo) DiffFile(ref, filePath string) (*NiceDiff, error) { + niceDiff, err := g.Diff(ref) if err != nil { return nil, err }@@ -100,8 +101,9 @@ Diff: filteredDiffs, }, nil } -func (g *Repo) Diff() (*NiceDiff, error) { - c, err := g.r.CommitObject(g.h) +func (g *Repo) Diff(ref string) (*NiceDiff, error) { + hash := plumbing.NewHash(ref) + c, err := g.r.CommitObject(hash) if err != nil { return nil, fmt.Errorf("commit object: %w", err) }