diff options
author | Jacob Vosmaer (GitLab) <jacob@gitlab.com> | 2018-05-21 12:05:34 +0300 |
---|---|---|
committer | Jacob Vosmaer (GitLab) <jacob@gitlab.com> | 2018-05-21 12:05:34 +0300 |
commit | 4649f3001f252cc064c8f6c65677cec7a07b49b5 (patch) | |
tree | b83b0af65e101de939c96a35b179029802dbe2fc | |
parent | 09f6efaa38514b7f29fbd06cd8d57be82f9d6b20 (diff) | |
parent | 2570f1d687dd97fe729c7bbb3cc14807a35727ab (diff) |
Merge branch 'master' into 'zj-fix-changelog'
# Conflicts:
# CHANGELOG.md
-rw-r--r-- | CHANGELOG.md | 10 | ||||
-rw-r--r-- | Dangerfile | 10 | ||||
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | changelogs/unreleased/.keep | 0 | ||||
-rw-r--r-- | changelogs/unreleased/zj-fix-dangerfile-really.yml | 5 | ||||
-rw-r--r-- | internal/service/repository/search_files.go | 9 | ||||
-rw-r--r-- | internal/service/repository/search_files_test.go | 24 | ||||
-rw-r--r-- | ruby/lib/gitlab/git/repository.rb | 10 |
8 files changed, 61 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 13a625ad4..1a69de306 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Gitaly changelog +## v0.102.0 + +#### Changed +- Unvendor Repository#add_branch + https://gitlab.com/gitlab-org/gitaly/merge_requests/717 + +#### Fixed +- Fix matching bug in SearchFilesByContent + https://gitlab.com/gitlab-org/gitaly/merge_requests/722 + ## v0.101.0 #### Changed diff --git a/Dangerfile b/Dangerfile index a23885beb..f1bb16150 100644 --- a/Dangerfile +++ b/Dangerfile @@ -12,10 +12,10 @@ def check_changelog(path) if !git.added_files.include?(path) warn("No changelog entry was generated, please do so by executing _support/changelog") else - yaml = YAML.safe_load(yaml) + yaml = YAML.safe_load(File.read(path)) - unless yaml['merge_request'] == gitlab.mr["iid"] - fail("Merge request ID was set to #{yaml['merge_request']}, expected #{gitlab.mr['iid']}") + unless yaml['merge_request'] == gitlab.mr_json["iid"] + fail("Merge request ID was not set to #{gitlab.mr_json['iid']}") end unless yaml['title'] == gitlab.mr_title @@ -24,7 +24,7 @@ def check_changelog(path) end end -check_changelog(File.join('changelogs', 'unreleased', "#{gitlab.branch_for_base}.yml}")) +check_changelog(File.join('changelogs', 'unreleased', "#{gitlab.branch_for_head}.yml")) VENDOR_JSON = 'vendor/vendor.json' fail("Expected #{VENDOR_JSON} to exist") unless File.exist?(VENDOR_JSON) @@ -38,3 +38,5 @@ if git.modified_files.include?(VENDOR_JSON) fail("gitaly-proto version is incorrect") end end + +# vim: ft=ruby @@ -1 +1 @@ -0.101.0 +0.102.0 diff --git a/changelogs/unreleased/.keep b/changelogs/unreleased/.keep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/changelogs/unreleased/.keep diff --git a/changelogs/unreleased/zj-fix-dangerfile-really.yml b/changelogs/unreleased/zj-fix-dangerfile-really.yml new file mode 100644 index 000000000..8ac8db5ff --- /dev/null +++ b/changelogs/unreleased/zj-fix-dangerfile-really.yml @@ -0,0 +1,5 @@ +--- +title: Fix Dangerfile bad changelog detection +merge_request: 724 +author: +type: other diff --git a/internal/service/repository/search_files.go b/internal/service/repository/search_files.go index 479ccff78..35ab1cb42 100644 --- a/internal/service/repository/search_files.go +++ b/internal/service/repository/search_files.go @@ -57,7 +57,7 @@ func (s *server) SearchFilesByContent(req *pb.SearchFilesByContentRequest, strea buf = append(buf, obj...) } } - if len(matches) > 1 { + if len(matches) > 0 { err = stream.Send(&pb.SearchFilesByContentResponse{Matches: matches}) matches = nil return err @@ -69,8 +69,11 @@ func (s *server) SearchFilesByContent(req *pb.SearchFilesByContentRequest, strea if err != nil { return helper.DecorateError(codes.Internal, err) } - if len(buf) > 1 { - return stream.Send(&pb.SearchFilesByContentResponse{Matches: [][]byte{buf}}) + if len(buf) > 0 { + matches = append(matches, buf) + } + if len(matches) > 0 { + return stream.Send(&pb.SearchFilesByContentResponse{Matches: matches}) } return nil } diff --git a/internal/service/repository/search_files_test.go b/internal/service/repository/search_files_test.go index 042b929cb..2679e4715 100644 --- a/internal/service/repository/search_files_test.go +++ b/internal/service/repository/search_files_test.go @@ -54,6 +54,22 @@ var ( []byte(""), }, []byte{'\n'}), } + contentCoffeeLines = [][]byte{ + bytes.Join([][]byte{ + []byte("many_files:CONTRIBUTING.md\x0092\x001. [Ruby style guide](https://github.com/bbatsov/ruby-style-guide)"), + []byte("many_files:CONTRIBUTING.md\x0093\x001. [Rails style guide](https://github.com/bbatsov/rails-style-guide)"), + []byte("many_files:CONTRIBUTING.md\x0094\x001. [CoffeeScript style guide](https://github.com/polarmobile/coffeescript-style-guide)"), + []byte("many_files:CONTRIBUTING.md\x0095\x001. [Shell command guidelines](doc/development/shell_commands.md)"), + []byte(""), + }, []byte{'\n'}), + bytes.Join([][]byte{ + []byte("many_files:files/js/application.js\x001\x00// This is a manifest file that'll be compiled into including all the files listed below."), + []byte("many_files:files/js/application.js\x002\x00// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically"), + []byte("many_files:files/js/application.js\x003\x00// be included in the compiled file accessible from http://example.com/assets/application.js"), + []byte("many_files:files/js/application.js\x004\x00// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the"), + []byte(""), + }, []byte{'\n'}), + } ) func TestSearchFilesByContentSuccessful(t *testing.T) { @@ -82,11 +98,17 @@ func TestSearchFilesByContentSuccessful(t *testing.T) { output: contentOutputLines, }, { - desc: "multi file in many_files", + desc: "single files, multiple matches", query: "backup", ref: "many_files", output: contentMultiLines, }, + { + desc: "multiple files, multiple matches", + query: "coffee", + ref: "many_files", + output: contentCoffeeLines, + }, } for _, tc := range testCases { diff --git a/ruby/lib/gitlab/git/repository.rb b/ruby/lib/gitlab/git/repository.rb index 35a8b2acc..b61c03b97 100644 --- a/ruby/lib/gitlab/git/repository.rb +++ b/ruby/lib/gitlab/git/repository.rb @@ -67,6 +67,16 @@ module Gitlab @gitlab_projects = gitlab_projects end + def add_branch(branch_name, user:, target:) + target_object = Ref.dereference_object(lookup(target)) + raise InvalidRef.new("target not found: #{target}") unless target_object + + OperationService.new(user, self).add_branch(branch_name, target_object.oid) + find_branch(branch_name) + rescue Rugged::ReferenceError => ex + raise InvalidRef, ex + end + def circuit_breaker FakeCircuitBreaker end |