all repos — elgit @ 43319d37943b0baef18c55a754fc732979f96167

fork of legit: web frontend for git, written in go

fix commit/diff URLs not using reference param

Alin
commit

43319d37943b0baef18c55a754fc732979f96167

parent

063228d9903995d645ebc66da1063c808c21f443

2 files changed, 8 insertions(+), 6 deletions(-)

changed files
M git/diff.gogit/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) }
M routes/routes.goroutes/routes.go
@@ -235,7 +235,7 @@ if !found {
return d.NotFound(rc) } - diff, err := gr.Diff() + diff, err := gr.Diff(ref) if err != nil { return err }
@@ -265,7 +265,7 @@ if !found {
return d.NotFound(rc) } - diff, err := gr.DiffFile(filePath) + diff, err := gr.DiffFile(ref, filePath) if err != nil { return err }