Commit 7b62791a authored by Michael Chmielewski's avatar Michael Chmielewski

Fixed method to use git log via Popen as recommended, and made output match...

Fixed method to use git log via Popen as recommended, and made output match test (and thus system) expectations.
parent b1f4aaa5
...@@ -91,7 +91,12 @@ class Repository ...@@ -91,7 +91,12 @@ class Repository
# Limited to 1000 commits for now, could be parameterized? # Limited to 1000 commits for now, could be parameterized?
args = %W(git log --pretty=%H --max-count 1000 --grep=#{query}) args = %W(git log --pretty=%H --max-count 1000 --grep=#{query})
Gitlab::Popen.popen(args, path_to_repo) 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 }
end end
def find_branch(name) def find_branch(name)
......
...@@ -27,7 +27,7 @@ describe Repository do ...@@ -27,7 +27,7 @@ describe Repository do
end end
describe :find_commits_with_matching_log do describe :find_commits_with_matching_log do
subject { repository.find_commits_with_matching_log('submodule').map{|k| k.id} } subject { repository.find_commits_with_matching_log('submodule') }
it { is_expected.to include('5937ac0a7beb003549fc5fd26fc247adbce4a52e') } it { is_expected.to include('5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
it { is_expected.to include('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') } it { is_expected.to include('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment