Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions modules/git/repo_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@ import (
"strconv"
"strings"

"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/mcuadros/go-version"
"gopkg.in/src-d/go-git.v4/plumbing"
Comment thread
zeripath marked this conversation as resolved.
Outdated
"gopkg.in/src-d/go-git.v4/plumbing/object"
Comment thread
zeripath marked this conversation as resolved.
Outdated
)

// GetRefCommitID returns the last commit ID string of given reference (branch or tag).
func (repo *Repository) GetRefCommitID(name string) (string, error) {
ref, err := repo.gogitRepo.Reference(plumbing.ReferenceName(name), true)
if err != nil {
if err == plumbing.ErrReferenceNotFound {
return "", ErrNotExist{
ID: name,
}
}
return "", err
}

Expand Down
4 changes: 1 addition & 3 deletions routers/repo/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/repofiles"
"code.gitea.io/gitea/modules/util"

"github.com/go-git/go-git/v5/plumbing"
)

const (
Expand Down Expand Up @@ -253,7 +251,7 @@ func loadBranches(ctx *context.Context) []*Branch {
repoIDToGitRepo[pr.BaseRepoID] = baseGitRepo
}
pullCommit, err := baseGitRepo.GetRefCommitID(pr.GetGitRefName())
if err != nil && err != plumbing.ErrReferenceNotFound {
if err != nil && !git.IsErrNotExist(err) {
ctx.ServerError("GetBranchCommitID", err)
return nil
}
Expand Down