forked from forgejo/forgejo
Removed unnecessary conversions (#7557)
No need to convert to the same type.
This commit is contained in:
parent
2f75766532
commit
54d96c79b5
24 changed files with 39 additions and 46 deletions
|
@ -25,7 +25,7 @@ func (tes Entries) GetCommitsInfo(commit *Commit, treePath string, cache LastCom
|
|||
defer commitGraphFile.Close()
|
||||
}
|
||||
|
||||
c, err := commitNodeIndex.Get(plumbing.Hash(commit.ID))
|
||||
c, err := commitNodeIndex.Get(commit.ID)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
|
@ -6,8 +6,6 @@ package git
|
|||
|
||||
import (
|
||||
"io/ioutil"
|
||||
|
||||
"gopkg.in/src-d/go-git.v4/plumbing"
|
||||
)
|
||||
|
||||
// NotesRef is the git ref where Gitea will look for git-notes data.
|
||||
|
@ -45,7 +43,7 @@ func GetNote(repo *Repository, commitID string, note *Note) error {
|
|||
}
|
||||
note.Message = d
|
||||
|
||||
commit, err := repo.gogitRepo.CommitObject(plumbing.Hash(notes.ID))
|
||||
commit, err := repo.gogitRepo.CommitObject(notes.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"gopkg.in/src-d/go-git.v4/plumbing"
|
||||
"gopkg.in/src-d/go-git.v4/plumbing/filemode"
|
||||
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
||||
)
|
||||
|
@ -57,7 +56,7 @@ func parseTreeEntries(data []byte, ptree *Tree) ([]*TreeEntry, error) {
|
|||
return nil, fmt.Errorf("Invalid ls-tree output: %v", err)
|
||||
}
|
||||
entry.ID = id
|
||||
entry.gogitTreeEntry.Hash = plumbing.Hash(id)
|
||||
entry.gogitTreeEntry.Hash = id
|
||||
pos += 41 // skip over sha and trailing space
|
||||
|
||||
end := pos + bytes.IndexByte(data[pos:], '\n')
|
||||
|
|
|
@ -20,5 +20,5 @@ func (repo *Repository) LineBlame(revision, path, file string, line uint) (*Comm
|
|||
if len(res) < 40 {
|
||||
return nil, fmt.Errorf("invalid result of blame: %s", res)
|
||||
}
|
||||
return repo.GetCommit(string(res[:40]))
|
||||
return repo.GetCommit(res[:40])
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
)
|
||||
|
||||
func (repo *Repository) getBlob(id SHA1) (*Blob, error) {
|
||||
encodedObj, err := repo.gogitRepo.Storer.EncodedObject(plumbing.AnyObject, plumbing.Hash(id))
|
||||
encodedObj, err := repo.gogitRepo.Storer.EncodedObject(plumbing.AnyObject, id)
|
||||
if err != nil {
|
||||
return nil, ErrNotExist{id.String(), ""}
|
||||
}
|
||||
|
|
|
@ -86,9 +86,9 @@ func convertPGPSignatureForTag(t *object.Tag) *CommitGPGSignature {
|
|||
func (repo *Repository) getCommit(id SHA1) (*Commit, error) {
|
||||
var tagObject *object.Tag
|
||||
|
||||
gogitCommit, err := repo.gogitRepo.CommitObject(plumbing.Hash(id))
|
||||
gogitCommit, err := repo.gogitRepo.CommitObject(id)
|
||||
if err == plumbing.ErrObjectNotFound {
|
||||
tagObject, err = repo.gogitRepo.TagObject(plumbing.Hash(id))
|
||||
tagObject, err = repo.gogitRepo.TagObject(id)
|
||||
if err == nil {
|
||||
gogitCommit, err = repo.gogitRepo.CommitObject(tagObject.Target)
|
||||
}
|
||||
|
|
|
@ -34,13 +34,13 @@ func (repo *Repository) GetRefsFiltered(pattern string) ([]*Reference, error) {
|
|||
refType := string(ObjectCommit)
|
||||
if ref.Name().IsTag() {
|
||||
// tags can be of type `commit` (lightweight) or `tag` (annotated)
|
||||
if tagType, _ := repo.GetTagType(SHA1(ref.Hash())); err == nil {
|
||||
if tagType, _ := repo.GetTagType(ref.Hash()); err == nil {
|
||||
refType = tagType
|
||||
}
|
||||
}
|
||||
r := &Reference{
|
||||
Name: ref.Name().String(),
|
||||
Object: SHA1(ref.Hash()),
|
||||
Object: ref.Hash(),
|
||||
Type: refType,
|
||||
repo: repo,
|
||||
}
|
||||
|
|
|
@ -10,12 +10,10 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gopkg.in/src-d/go-git.v4/plumbing"
|
||||
)
|
||||
|
||||
func (repo *Repository) getTree(id SHA1) (*Tree, error) {
|
||||
gogitTree, err := repo.gogitRepo.TreeObject(plumbing.Hash(id))
|
||||
gogitTree, err := repo.gogitRepo.TreeObject(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -41,7 +39,7 @@ func (repo *Repository) GetTree(idStr string) (*Tree, error) {
|
|||
return nil, err
|
||||
}
|
||||
resolvedID := id
|
||||
commitObject, err := repo.gogitRepo.CommitObject(plumbing.Hash(id))
|
||||
commitObject, err := repo.gogitRepo.CommitObject(id)
|
||||
if err == nil {
|
||||
id = SHA1(commitObject.TreeHash)
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ func (t *Tree) SubTree(rpath string) (*Tree, error) {
|
|||
}
|
||||
|
||||
func (t *Tree) loadTreeObject() error {
|
||||
gogitTree, err := t.repo.gogitRepo.TreeObject(plumbing.Hash(t.ID))
|
||||
gogitTree, err := t.repo.gogitRepo.TreeObject(t.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"path"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/src-d/go-git.v4/plumbing"
|
||||
"gopkg.in/src-d/go-git.v4/plumbing/filemode"
|
||||
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
||||
)
|
||||
|
@ -23,7 +22,7 @@ func (t *Tree) GetTreeEntryByPath(relpath string) (*TreeEntry, error) {
|
|||
gogitTreeEntry: &object.TreeEntry{
|
||||
Name: "",
|
||||
Mode: filemode.Dir,
|
||||
Hash: plumbing.Hash(t.ID),
|
||||
Hash: t.ID,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue