ebf98f27c4
Enables frozen string for the following: * lib/gitlab/fogbugz_import/**/*.rb * lib/gitlab/gfm/**/*.rb * lib/gitlab/git/**/*.rb * lib/gitlab/gitaly_client/**/*.rb * lib/gitlab/gitlab_import/**/*.rb * lib/gitlab/google_code_import/**/*.rb * lib/gitlab/gpg/**/*.rb * lib/gitlab/grape_logging/**/*.rb * lib/gitlab/graphql/**/*.rb * lib/gitlab/graphs/**/*.rb * lib/gitlab/hashed_storage/**/*.rb * lib/gitlab/health_checks/**/*.rb Partially address gitlab-org/gitlab-ce#47424.
33 lines
668 B
Ruby
33 lines
668 B
Ruby
# frozen_string_literal: true
|
|
|
|
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)
|
|
end
|
|
end
|
|
|
|
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
|