all repos — elgit @ 2288b32910ef20bfb53586d9d76786fb54b73b96

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

resolve linter complaints

Alan Pearce
commit

2288b32910ef20bfb53586d9d76786fb54b73b96

parent

f16bbb0a0f40ff7c25582c4e787f1de3e9db4e95

4 files changed, 19 insertions(+), 19 deletions(-)

changed files
M git/diff.gogit/diff.go
@@ -46,7 +46,7 @@ Diff []Diff
} // DiffFile returns a diff for a specific file in the current commit -func (g *GitRepo) DiffFile(filePath string) (*NiceDiff, error) { +func (g *Repo) DiffFile(filePath string) (*NiceDiff, error) { niceDiff, err := g.Diff() if err != nil { return nil, err
@@ -100,7 +100,7 @@ Diff: filteredDiffs,
}, nil } -func (g *GitRepo) Diff() (*NiceDiff, error) { +func (g *Repo) Diff() (*NiceDiff, error) { c, err := g.r.CommitObject(g.h) if err != nil { return nil, fmt.Errorf("commit object: %w", err)
@@ -162,9 +162,9 @@ })
for _, l := range tf.Lines { switch l.Op { case gitdiff.OpAdd: - nd.Stat.Insertions += 1 + nd.Stat.Insertions++ case gitdiff.OpDelete: - nd.Stat.Deletions += 1 + nd.Stat.Deletions++ } } }
M git/git.gogit/git.go
@@ -15,7 +15,7 @@ "github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object" ) -type GitRepo struct { +type Repo struct { r *git.Repository h plumbing.Hash }
@@ -87,9 +87,9 @@
return dateI.After(dateJ) } -func Open(path string, ref string) (*GitRepo, error) { +func Open(path string, ref string) (*Repo, error) { var err error - g := GitRepo{} + g := Repo{} g.r, err = git.PlainOpen(path) if err != nil { return nil, fmt.Errorf("opening %s: %w", path, err)
@@ -112,7 +112,7 @@
return &g, nil } -func (g *GitRepo) Commits() ([]*CommitReference, error) { +func (g *Repo) Commits() ([]*CommitReference, error) { ci, err := g.r.Log(&git.LogOptions{From: g.h}) if err != nil { return nil, fmt.Errorf("commits from ref: %w", err)
@@ -159,7 +159,7 @@
return commitRefs, nil } -func (g *GitRepo) LastCommit() (*CommitReference, error) { +func (g *Repo) LastCommit() (*CommitReference, error) { c, err := g.r.CommitObject(g.h) if err != nil { return nil, fmt.Errorf("last commit: %w", err)
@@ -194,7 +194,7 @@
return commitRef, nil } -func (g *GitRepo) FileContent(path string) (string, error) { +func (g *Repo) FileContent(path string) (string, error) { c, err := g.r.CommitObject(g.h) if err != nil { return "", fmt.Errorf("commit object: %w", err)
@@ -212,14 +212,14 @@ }
isbin, _ := file.IsBinary() - if !isbin { - return file.Contents() - } else { + if isbin { return "Not displaying binary file", nil } + + return file.Contents() } -func (g *GitRepo) Tags() ([]*TagReference, error) { +func (g *Repo) Tags() ([]*TagReference, error) { iter, err := g.r.Tags() if err != nil { return nil, fmt.Errorf("tag objects: %w", err)
@@ -254,7 +254,7 @@
return tags, nil } -func (g *GitRepo) Branches() ([]*plumbing.Reference, error) { +func (g *Repo) Branches() ([]*plumbing.Reference, error) { bi, err := g.r.Branches() if err != nil { return nil, fmt.Errorf("branchs: %w", err)
@@ -271,7 +271,7 @@
return branches, nil } -func (g *GitRepo) FindMainBranch(branches []string) (string, error) { +func (g *Repo) FindMainBranch(branches []string) (string, error) { for _, b := range branches { _, err := g.r.ResolveRevision(plumbing.Revision(b)) if err == nil {
@@ -284,7 +284,7 @@ }
// WriteTar writes itself from a tree into a binary tar file format. // prefix is root folder to be appended. -func (g *GitRepo) WriteTar(w io.Writer, prefix string) (err error) { +func (g *Repo) WriteTar(w io.Writer, prefix string) (err error) { tw := tar.NewWriter(w) defer func() { err = tw.Close()
M git/tree.gogit/tree.go
@@ -7,7 +7,7 @@
"github.com/go-git/go-git/v5/plumbing/object" ) -func (g *GitRepo) FileTree(path string) ([]NiceTree, error) { +func (g *Repo) FileTree(path string) ([]NiceTree, error) { path = strings.TrimSuffix(path, "/") c, err := g.r.CommitObject(g.h) if err != nil {
M routes/util.goroutes/util.go
@@ -15,7 +15,7 @@ securejoin "github.com/cyphar/filepath-securejoin"
"github.com/dimfeld/httptreemux/v5" ) -func isGoModule(gr *git.GitRepo) bool { +func isGoModule(gr *git.Repo) bool { _, err := gr.FileContent("go.mod") return err == nil