summaryrefslogtreecommitdiff
path: root/app/models/repository.rb
diff options
context:
space:
mode:
authorIgor Drozdov <idrozdov@gitlab.com>2019-06-18 17:20:11 +0300
committerIgor Drozdov <idrozdov@gitlab.com>2019-06-28 16:22:35 +0300
commitca5cd7b7fb5108d30d0f6b74e31da736024592dd (patch)
treeaec9468afa579b128b7e09f6e78e7357d6413b85 /app/models/repository.rb
parent546355f734f74c040d0ef0917ade50751fd90731 (diff)
downloadgitlab-ce-ca5cd7b7fb5108d30d0f6b74e31da736024592dd.tar.gz
Add endpoint for fetching diverging commit countsid-stale-branches
Extract diverging_commit_counts into a service class
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r--app/models/repository.rb40
1 files changed, 0 insertions, 40 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index e05d3dd58ac..992ed7485e5 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -282,46 +282,6 @@ class Repository
ref_exists?(keep_around_ref_name(sha))
end
- def diverging_commit_counts(branch)
- return diverging_commit_counts_without_max(branch) if Feature.enabled?('gitaly_count_diverging_commits_no_max')
-
- ## TODO: deprecate the below code after 12.0
- @root_ref_hash ||= raw_repository.commit(root_ref).id
- cache.fetch(:"diverging_commit_counts_#{branch.name}") do
- # Rugged seems to throw a `ReferenceError` when given branch_names rather
- # than SHA-1 hashes
- branch_sha = branch.dereferenced_target.sha
-
- number_commits_behind, number_commits_ahead =
- raw_repository.diverging_commit_count(
- @root_ref_hash,
- branch_sha,
- max_count: MAX_DIVERGING_COUNT)
-
- if number_commits_behind + number_commits_ahead >= MAX_DIVERGING_COUNT
- { distance: MAX_DIVERGING_COUNT }
- else
- { behind: number_commits_behind, ahead: number_commits_ahead }
- end
- end
- end
-
- def diverging_commit_counts_without_max(branch)
- @root_ref_hash ||= raw_repository.commit(root_ref).id
- cache.fetch(:"diverging_commit_counts_without_max_#{branch.name}") do
- # Rugged seems to throw a `ReferenceError` when given branch_names rather
- # than SHA-1 hashes
- branch_sha = branch.dereferenced_target.sha
-
- number_commits_behind, number_commits_ahead =
- raw_repository.diverging_commit_count(
- @root_ref_hash,
- branch_sha)
-
- { behind: number_commits_behind, ahead: number_commits_ahead }
- end
- end
-
def archive_metadata(ref, storage_path, format = "tar.gz", append_sha:, path: nil)
raw_repository.archive_metadata(
ref,