summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Chmielewski <code@mikec.123mail.org>2015-10-28 22:12:22 -0400
committerMichael Chmielewski <code@mikec.123mail.org>2015-10-28 22:34:39 -0400
commita0d0a0179134c16c84dfa18da9db78b375cd7cd0 (patch)
treeeeb0bb860fb96ff16be753a50662e151e2d14c61
parent7b62791afc8e98f8ccd7d85dbae0cf2128883c13 (diff)
downloadgitlab-ce-a0d0a0179134c16c84dfa18da9db78b375cd7cd0.tar.gz
Actually converted code to following suggestions.
-rw-r--r--app/models/repository.rb9
-rw-r--r--spec/models/repository_spec.rb2
2 files changed, 4 insertions, 7 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 112ad05c188..a0f2b3fb765 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -91,12 +91,9 @@ class Repository
# Limited to 1000 commits for now, could be parameterized?
args = %W(git log --pretty=%H --max-count 1000 --grep=#{query})
- git_log_results = Gitlab::Popen.popen(args, path_to_repo)
-
- # 1. Get result, which is 1-element array
- # 2. Split on lines
- # 3. Recreate array, but remove trailing newline characters on each element
- git_log_results.first.lines.map{ |l| l.chomp }
+ git_log_results = Gitlab::Popen.popen(args, path_to_repo).first.lines.map{ |l| l.chomp }
+ commits = git_log_results.map{ |c| commit(c) }
+ commits
end
def find_branch(name)
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 17b5f28891b..aedbfa04d88 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -27,7 +27,7 @@ describe Repository do
end
describe :find_commits_with_matching_log do
- subject { repository.find_commits_with_matching_log('submodule') }
+ subject { repository.find_commits_with_matching_log('submodule').map{ |k| k.id } }
it { is_expected.to include('5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
it { is_expected.to include('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }