Commit 5b5a2a5d authored by Sean McGivern's avatar Sean McGivern

Merge branch 'adam-commit-search-case-insensitive' into 'master'

Make searching for commits case insensitive.

## Does this MR meet the acceptance criteria?

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- Tests
  - [x] Added for this feature/bug
  - [ ] All builds are passing
- [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

## What are the relevant issue numbers?

Fixes #21800

See merge request !6715
parents 2d3210fd 1cf2b9a6
...@@ -66,6 +66,7 @@ v 8.13.0 (unreleased) ...@@ -66,6 +66,7 @@ v 8.13.0 (unreleased)
- Add organization field to user profile - Add organization field to user profile
- Fix enter key when navigating search site search dropdown. !6643 (Brennan Roberts) - Fix enter key when navigating search site search dropdown. !6643 (Brennan Roberts)
- Fix deploy status responsiveness error !6633 - Fix deploy status responsiveness error !6633
- Make searching for commits case insensitive
- Fix resolved discussion display in side-by-side diff view !6575 - Fix resolved discussion display in side-by-side diff view !6575
- Optimize GitHub importing for speed and memory - Optimize GitHub importing for speed and memory
- API: expose pipeline data in builds API (!6502, Guilherme Salazar) - API: expose pipeline data in builds API (!6502, Guilherme Salazar)
......
...@@ -111,8 +111,10 @@ class Repository ...@@ -111,8 +111,10 @@ class Repository
def find_commits_by_message(query, ref = nil, path = nil, limit = 1000, offset = 0) def find_commits_by_message(query, ref = nil, path = nil, limit = 1000, offset = 0)
ref ||= root_ref ref ||= root_ref
# Limited to 1000 commits for now, could be parameterized? args = %W(
args = %W(#{Gitlab.config.git.bin_path} log #{ref} --pretty=%H --skip #{offset} --max-count #{limit} --grep=#{query}) #{Gitlab.config.git.bin_path} log #{ref} --pretty=%H --skip #{offset}
--max-count #{limit} --grep=#{query} --regexp-ignore-case
)
args = args.concat(%W(-- #{path})) if path.present? args = args.concat(%W(-- #{path})) if path.present?
git_log_results = Gitlab::Popen.popen(args, path_to_repo).first.lines.map(&:chomp) git_log_results = Gitlab::Popen.popen(args, path_to_repo).first.lines.map(&:chomp)
......
...@@ -97,12 +97,20 @@ describe Repository, models: true do ...@@ -97,12 +97,20 @@ describe Repository, models: true do
end end
describe '#find_commits_by_message' do describe '#find_commits_by_message' do
subject { repository.find_commits_by_message('submodule').map{ |k| k.id } } it 'returns commits with messages containing a given string' do
commit_ids = repository.find_commits_by_message('submodule').map(&:id)
it { is_expected.to include('5937ac0a7beb003549fc5fd26fc247adbce4a52e') } expect(commit_ids).to include('5937ac0a7beb003549fc5fd26fc247adbce4a52e')
it { is_expected.to include('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') } expect(commit_ids).to include('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9')
it { is_expected.to include('cfe32cf61b73a0d5e9f13e774abde7ff789b1660') } expect(commit_ids).to include('cfe32cf61b73a0d5e9f13e774abde7ff789b1660')
it { is_expected.not_to include('913c66a37b4a45b9769037c55c2d238bd0942d2e') } expect(commit_ids).not_to include('913c66a37b4a45b9769037c55c2d238bd0942d2e')
end
it 'is case insensitive' do
commit_ids = repository.find_commits_by_message('SUBMODULE').map(&:id)
expect(commit_ids).to include('5937ac0a7beb003549fc5fd26fc247adbce4a52e')
end
end end
describe '#blob_at' do describe '#blob_at' do
......
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