diff options
author | Rémy Coutable <remy@rymai.me> | 2018-03-06 13:14:10 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-03-06 13:14:10 +0000 |
commit | af84ccbd8227ac6d4d609bc8ff941ee6cad131f5 (patch) | |
tree | 50bb5c96a390c12af72126c50ce9c0583833f3b7 /lib | |
parent | fa31559a37bfe394dedf4078789f1540e01fc5c7 (diff) | |
parent | 580d8953636266e40802fd8ea525c4908ebc8b9f (diff) | |
download | gitlab-ce-af84ccbd8227ac6d4d609bc8ff941ee6cad131f5.tar.gz |
Merge branch '40187-project-branch-dashboard-with-active-stale-branches' into 'master'
Add overview of branches and filtered views for active/stale branches
Closes #40187 et #17293
See merge request gitlab-org/gitlab-ce!15402
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/git/branch.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/gitlab/git/branch.rb b/lib/gitlab/git/branch.rb index ae7e88f0503..6351cfb83e3 100644 --- a/lib/gitlab/git/branch.rb +++ b/lib/gitlab/git/branch.rb @@ -1,6 +1,8 @@ module Gitlab module Git class Branch < Ref + STALE_BRANCH_THRESHOLD = 3.months + def self.find(repo, branch_name) if branch_name.is_a?(Gitlab::Git::Branch) branch_name @@ -12,6 +14,18 @@ module Gitlab def initialize(repository, name, target, target_commit) super(repository, name, target, target_commit) end + + def active? + self.dereferenced_target.committed_date >= STALE_BRANCH_THRESHOLD.ago + end + + def stale? + !active? + end + + def state + active? ? :active : :stale + end end end end |