Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-09-26 07:33:57 +0300
committerTimothy Andrew <mail@timothyandrew.net>2016-09-26 16:08:40 +0300
commitc0ecef79fe936b9e71384f8d951fc5503f26f4a7 (patch)
treef1be52fe5ff1773036defe22f5f7d232cac3c40c /app/models/cycle_analytics
parentf1bfb872877df7baf36d2de1ad5dfdb4c8604c9b (diff)
Fix the "Commits" section of the cycle analytics summary.
- The commit count was capped at 10, due to `Gitlab::Git::Repository#log` enforcing a limit, with the default set to 10. - Reimplement a small portion of this `log` function to get just the data we need.
Diffstat (limited to 'app/models/cycle_analytics')
-rw-r--r--app/models/cycle_analytics/summary.rb28
1 files changed, 23 insertions, 5 deletions
diff --git a/app/models/cycle_analytics/summary.rb b/app/models/cycle_analytics/summary.rb
index 53b2cacb131..b46db449bf3 100644
--- a/app/models/cycle_analytics/summary.rb
+++ b/app/models/cycle_analytics/summary.rb
@@ -10,15 +10,33 @@ class CycleAnalytics
end
def commits
- repository = @project.repository.raw_repository
-
- if @project.default_branch
- repository.log(ref: @project.default_branch, after: @from).count
- end
+ ref = @project.default_branch.presence
+ count_commits_for(ref)
end
def deploys
@project.deployments.where("created_at > ?", @from).count
end
+
+ private
+
+ # Don't use the `Gitlab::Git::Repository#log` method, because it enforces
+ # a limit. Since we need a commit count, we _can't_ enforce a limit, so
+ # the easiest way forward is to replicate the relevant portions of the
+ # `log` function here.
+ def count_commits_for(ref)
+ return unless ref
+
+ repository = @project.repository.raw_repository
+ sha = @project.repository.commit(ref).sha
+
+ cmd = %W(git --git-dir=#{repository.path} log)
+ cmd << '--format=%H'
+ cmd << "--after=#{@from.iso8601}"
+ cmd << sha
+
+ raw_output = IO.popen(cmd) { |io| io.read }
+ raw_output.lines.count
+ end
end
end