2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
module Gitlab
|
|
|
|
module Git
|
|
|
|
class Branch < Ref
|
2018-03-27 19:54:05 +05:30
|
|
|
STALE_BRANCH_THRESHOLD = 3.months
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def self.find(repo, branch_name)
|
|
|
|
if branch_name.is_a?(Gitlab::Git::Branch)
|
|
|
|
branch_name
|
|
|
|
else
|
|
|
|
repo.find_branch(branch_name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
def initialize(repository, name, target, target_commit)
|
|
|
|
super(repository, name, target, target_commit)
|
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
|
|
|
|
def active?
|
|
|
|
self.dereferenced_target.committed_date >= STALE_BRANCH_THRESHOLD.ago
|
|
|
|
end
|
|
|
|
|
|
|
|
def stale?
|
|
|
|
!active?
|
|
|
|
end
|
|
|
|
|
|
|
|
def state
|
|
|
|
active? ? :active : :stale
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|