summaryrefslogtreecommitdiffstats
path: root/modules/git/repo_compare.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-02-16 15:39:45 +0000
committerGitHub <noreply@github.com>2021-02-16 16:39:45 +0100
commit66a148e398c3c944e2b79187c09ef0bb7bdfdd5e (patch)
treee983d4e0d072ec88918e7ccf191c1c28f612999f /modules/git/repo_compare.go
parentebddee8d2b46afc8f297ef86463590db57367e70 (diff)
downloadgitea-66a148e398c3c944e2b79187c09ef0bb7bdfdd5e.tar.gz
gitea-66a148e398c3c944e2b79187c09ef0bb7bdfdd5e.zip
Restore detection of branches are equal on compare page (#14586)
Somehow the test for detecting if branches are equal broke this PR restores this functionality. Fix #14502 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/git/repo_compare.go')
-rw-r--r--modules/git/repo_compare.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/modules/git/repo_compare.go b/modules/git/repo_compare.go
index 5f92bc7714..3255e68392 100644
--- a/modules/git/repo_compare.go
+++ b/modules/git/repo_compare.go
@@ -20,9 +20,11 @@ import (
// CompareInfo represents needed information for comparing references.
type CompareInfo struct {
- MergeBase string
- Commits *list.List
- NumFiles int
+ MergeBase string
+ BaseCommitID string
+ HeadCommitID string
+ Commits *list.List
+ NumFiles int
}
// GetMergeBase checks and returns merge base of two branches and the reference used as base.
@@ -66,8 +68,18 @@ func (repo *Repository) GetCompareInfo(basePath, baseBranch, headBranch string)
}
compareInfo := new(CompareInfo)
+
+ compareInfo.HeadCommitID, err = GetFullCommitID(repo.Path, headBranch)
+ if err != nil {
+ compareInfo.HeadCommitID = headBranch
+ }
+
compareInfo.MergeBase, remoteBranch, err = repo.GetMergeBase(tmpRemote, baseBranch, headBranch)
if err == nil {
+ compareInfo.BaseCommitID, err = GetFullCommitID(repo.Path, remoteBranch)
+ if err != nil {
+ compareInfo.BaseCommitID = remoteBranch
+ }
// We have a common base - therefore we know that ... should work
logs, err := NewCommand("log", compareInfo.MergeBase+"..."+headBranch, prettyLogFormat).RunInDirBytes(repo.Path)
if err != nil {
@@ -83,6 +95,7 @@ func (repo *Repository) GetCompareInfo(basePath, baseBranch, headBranch string)
if err != nil {
compareInfo.MergeBase = remoteBranch
}
+ compareInfo.BaseCommitID = compareInfo.MergeBase
}
// Count number of changed files.