summaryrefslogtreecommitdiffstats
path: root/modules/templates
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/templates
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/templates')
-rw-r--r--modules/templates/helper.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index 6d964e88a5..3176684d82 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -223,6 +223,13 @@ func NewFuncMap() []template.FuncMap {
}
return dict, nil
},
+ "percentage": func(n int, values ...int) float32 {
+ var sum = 0
+ for i := 0; i < len(values); i++ {
+ sum += values[i]
+ }
+ return float32(n) * 100 / float32(sum)
+ },
}}
}