From c20034be31034f135f4e5f0a995ae82c318516c2 Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Tue, 5 Feb 2019 22:47:01 +0100 Subject: Display the branch name in the commit view (#5950) * add branch info * Remove blank lines * Remove blank lines * update git dependency --- vendor/code.gitea.io/git/commit.go | 1 + vendor/code.gitea.io/git/repo_commit.go | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'vendor/code.gitea.io') diff --git a/vendor/code.gitea.io/git/commit.go b/vendor/code.gitea.io/git/commit.go index 227df09b7d..36b8d54565 100644 --- a/vendor/code.gitea.io/git/commit.go +++ b/vendor/code.gitea.io/git/commit.go @@ -18,6 +18,7 @@ import ( // Commit represents a git commit. type Commit struct { + Branch string // Branch this commit belongs to Tree ID SHA1 // The ID of this commit object Author *Signature diff --git a/vendor/code.gitea.io/git/repo_commit.go b/vendor/code.gitea.io/git/repo_commit.go index 484568585f..bfbf5c6dae 100644 --- a/vendor/code.gitea.io/git/repo_commit.go +++ b/vendor/code.gitea.io/git/repo_commit.go @@ -10,7 +10,7 @@ import ( "strconv" "strings" - "github.com/mcuadros/go-version" + version "github.com/mcuadros/go-version" ) // GetRefCommitID returns the last commit ID string of given reference (branch or tag). @@ -130,6 +130,14 @@ func (repo *Repository) getCommit(id SHA1) (*Commit, error) { commit.repo = repo commit.ID = id + data, err = NewCommand("name-rev", id.String()).RunInDirBytes(repo.Path) + if err != nil { + return nil, err + } + + // name-rev commitID ouput will be "COMMIT_ID master" or "COMMIT_ID master~12" + commit.Branch = strings.Split(strings.Split(string(data), " ")[1], "~")[0] + repo.commitCache.Set(id.String(), commit) return commit, nil } -- cgit v1.2.3