summaryrefslogtreecommitdiffstats
path: root/modules/repofiles
diff options
context:
space:
mode:
authorMario Lubenka <mario.lubenka@googlemail.com>2019-05-05 18:25:25 +0200
committerLauris BH <lauris@nix.lv>2019-05-05 19:25:25 +0300
commit55a8e12d85bd59314416bb026e84d258004a5071 (patch)
tree8735a97000a66f013b5da8407501995e63ec16f8 /modules/repofiles
parentc1da790cee96f1e2d15dded7748da5bc81022042 (diff)
downloadgitea-55a8e12d85bd59314416bb026e84d258004a5071.tar.gz
gitea-55a8e12d85bd59314416bb026e84d258004a5071.zip
Number of commits ahead/behind in branch overview (#6695)
* Call Git API to determine divergence of a branch and its base branch Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Show commit divergance in branch list Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Adds missing comment Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Adds test for diverging commits Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Try comparing commits instead of branches Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Removes test as CI can't run it Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Adjusts signature of percentage function to allow providing multiple integers as numerator Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Moves CountDivergingCommits function into repofiles module Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
Diffstat (limited to 'modules/repofiles')
-rw-r--r--modules/repofiles/commit.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/modules/repofiles/commit.go b/modules/repofiles/commit.go
new file mode 100644
index 0000000000..371e6cf3ab
--- /dev/null
+++ b/modules/repofiles/commit.go
@@ -0,0 +1,19 @@
+// Copyright 2019 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package repofiles
+
+import (
+ "code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/modules/git"
+)
+
+// CountDivergingCommits determines how many commits a branch is ahead or behind the repository's base branch
+func CountDivergingCommits(repo *models.Repository, branch string) (*git.DivergeObject, error) {
+ divergence, err := git.GetDivergingCommits(repo.RepoPath(), repo.DefaultBranch, branch)
+ if err != nil {
+ return nil, err
+ }
+ return &divergence, nil
+}