diff options
author | Takuya Noguchi <takninnovationresearch@gmail.com> | 2017-11-15 23:56:36 +0900 |
---|---|---|
committer | Takuya Noguchi <takninnovationresearch@gmail.com> | 2018-03-06 21:28:14 +0900 |
commit | 580d8953636266e40802fd8ea525c4908ebc8b9f (patch) | |
tree | b643fc68bbb40643c8932f8b456173669a334a81 /lib | |
parent | 65348cf07bafef5efc1c9665d3efdb5a1bdd7128 (diff) | |
download | gitlab-ce-580d8953636266e40802fd8ea525c4908ebc8b9f.tar.gz |
Add overview of branches and a filter for active/stale branches
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 |