all repos — elgit @ 2288b32910ef20bfb53586d9d76786fb54b73b96

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

resolve linter complaints

Alan Pearce
commit

2288b32910ef20bfb53586d9d76786fb54b73b96

parent

f16bbb0a0f40ff7c25582c4e787f1de3e9db4e95

1 file changed, 13 insertions(+), 13 deletions(-)

changed files
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()