Commit f8a4a760480a2395ca371c4ab6201344a186fa39
1 parent
e91ff84d
Exists in
master
and in
4 other branches
decorate commits in Gitlab::Git::repository with valid class
Showing
2 changed files
with
21 additions
and
4 deletions
Show diff stats
lib/gitlab/git/repository.rb
... | ... | @@ -54,11 +54,11 @@ module Gitlab |
54 | 54 | repo.commits(root_ref).first |
55 | 55 | end |
56 | 56 | |
57 | - Commit.new(commit) if commit | |
57 | + decorate_commit(commit) if commit | |
58 | 58 | end |
59 | 59 | |
60 | 60 | def commits_with_refs(n = 20) |
61 | - commits = repo.branches.map { |ref| Commit.new(ref.commit, ref) } | |
61 | + commits = repo.branches.map { |ref| decorate_commit(ref.commit, ref) } | |
62 | 62 | |
63 | 63 | commits.sort! do |x, y| |
64 | 64 | y.committed_date <=> x.committed_date |
... | ... | @@ -74,11 +74,11 @@ module Gitlab |
74 | 74 | repo.commits(ref, limit, offset) |
75 | 75 | else |
76 | 76 | repo.commits(ref) |
77 | - end.map{ |c| Commit.new(c) } | |
77 | + end.map{ |c| decorate_commit(c) } | |
78 | 78 | end |
79 | 79 | |
80 | 80 | def commits_between(from, to) |
81 | - repo.commits_between(from, to).map { |c| Commit.new(c) } | |
81 | + repo.commits_between(from, to).map { |c| decorate_commit(c) } | |
82 | 82 | end |
83 | 83 | |
84 | 84 | def last_commit_for(ref, path = nil) |
... | ... | @@ -190,6 +190,12 @@ module Gitlab |
190 | 190 | def cache_key(type) |
191 | 191 | "#{type}:#{path_with_namespace}" |
192 | 192 | end |
193 | + | |
194 | + protected | |
195 | + | |
196 | + def decorate_commit(commit, ref = nil) | |
197 | + Gitlab::Git::Commit.new(commit, ref) | |
198 | + end | |
193 | 199 | end |
194 | 200 | end |
195 | 201 | end | ... | ... |
spec/lib/gitlab/git/repository_spec.rb
... | ... | @@ -82,6 +82,17 @@ describe Gitlab::Git::Repository do |
82 | 82 | end |
83 | 83 | end |
84 | 84 | |
85 | + describe "commits" do | |
86 | + subject do | |
87 | + commits = repository.commits('master', 'app', 3, 1) | |
88 | + commits.map { |c| c.id } | |
89 | + end | |
90 | + | |
91 | + it { should have(3).elements } | |
92 | + it { should include("8716fc78f3c65bbf7bcf7b574febd583bc5d2812") } | |
93 | + it { should_not include("bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a") } | |
94 | + end | |
95 | + | |
85 | 96 | describe "commits_between" do |
86 | 97 | subject do |
87 | 98 | commits = repository.commits_between("3a4b4fb4cde7809f033822a171b9feae19d41fff", | ... | ... |