gitlab-org--gitlab-foss/lib/gitlab/git/branch.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
666 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-01-04 13:43:06 -05:00
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
else
repo.find_branch(branch_name)
2017-10-27 11:55:08 -04:00
end
end
def active?
self.dereferenced_target.committed_date >= STALE_BRANCH_THRESHOLD.ago
end
def stale?
!active?
end
def state
active? ? :active : :stale
end
def cache_key
"branch:" + Digest::SHA1.hexdigest([name, target, dereferenced_target&.sha].join(':'))
end
2017-01-04 13:43:06 -05:00
end
end
end