-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Gerrit connector usability #230
Conversation
This makes it possible to use http password token that is defined in Settings -> HTTP Password page instead of the regular site password. https://gerrit-review.googlesource.com/Documentation/rest-api.html#authentication
When a cherry-pick is done and there are more commits with the same changeId, an exended id can be used to distinguish between them. It has a tilde separated format: project/subproject~branch/subbranch~changeId If this is not encoded but just put in the URL, an error message comes from the server like: Request not successful. Message: Not Found. Status-Code: 404. Content: Not found: project
As it's a Gerrit feature and not a client side deduplication, it should not have a large overhead, therefore it's enabled by default.
Codecov Report
@@ Coverage Diff @@
## master #230 +/- ##
============================================
+ Coverage 72.38% 74.16% +1.78%
- Complexity 608 625 +17
============================================
Files 146 147 +1
Lines 1988 2009 +21
Branches 131 131
============================================
+ Hits 1439 1490 +51
+ Misses 489 457 -32
- Partials 60 62 +2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your support. There are a few things to rephrase and I'll be happy to merge it.
} | ||
// To keep the changeId readable, we don't encode '~' (it is not needed according to RFC2396) | ||
return StreamSupport.stream(Splitter.on('~').split(changeId).spliterator(), false) | ||
.map(GerritFacadeBuilder::safeUrlEncode).collect(Collectors.joining("~")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just hope you're right and it works :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add a comment with a reference to
ChangesRestClient.id where they do it in a very similar way with the 2 and 3 argument methods.
} | ||
|
||
@Test | ||
void build_shouldEscapeChangeIdWithSlash() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to fit project style please skip build_ prefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Roger that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
void build_shouldEscapeChangeIdWithSlash() { | ||
GerritFacade connector = gerritFacadeBuilder.build(configuration); | ||
|
||
assertEquals("project%2Fsubproject~branch%2Fsubbranch~changeId", connector.gerritPatchset.getChangeId()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use assertj assertions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Roger that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
} | ||
|
||
@Test | ||
void build_optionsPassed() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldBuildOptions maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Roger that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -56,7 +67,38 @@ void shouldNotListDeletedFiles() throws IOException, RestApiException { | |||
assertThat(reviewFiles).hasSize(1); | |||
} | |||
|
|||
@Test | |||
void publish() throws IOException, RestApiException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use should... naming style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Roger that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
This actually does the same as the old 'safeUrlEncode(String)'. Also a reference is now added for the ID encoding method.
@SpOOnman Please check the changes again, I think I considered all your comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your support!
// To keep the changeId readable, we don't encode '~' (it is not needed according to RFC2396) | ||
// See also: ChangesRestClient.id(String, String) and ChangesRestClient.id(String, String, String) | ||
return StreamSupport.stream(Splitter.on('~').split(changeId).spliterator(), false) | ||
.map(Url::encode).collect(Collectors.joining("~")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
* Allow usage of Gerrit HTTP password tokens (TouK#220) This makes it possible to use http password token that is defined in Settings -> HTTP Password page instead of the regular site password. https://gerrit-review.googlesource.com/Documentation/rest-api.html#authentication * URL encode changeId when creating GerritPatchset (TouK#221) When a cherry-pick is done and there are more commits with the same changeId, an exended id can be used to distinguish between them. It has a tilde separated format: project/subproject~branch/subbranch~changeId If this is not encoded but just put in the URL, an error message comes from the server like: Request not successful. Message: Not Found. Status-Code: 404. Content: Not found: project * Support gerrit configuration to omit duplicate comments (TouK#108) As it's a Gerrit feature and not a client side deduplication, it should not have a large overhead, therefore it's enabled by default. * Improve test coverage of Gerrit connector * Use Gerrit API's URL encoding in GerritFacadeBuilder This actually does the same as the old 'safeUrlEncode(String)'. Also a reference is now added for the ID encoding method. * Clean up Gerrit connector tests to better fit the project style Co-authored-by: Gabor Garancsi <gabor.garancsi@casrd.net>
Allow usage of Gerrit HTTP password tokens (#220)
URL encode changeId when creating GerritPatchset (#221)
Support gerrit configuration to omit duplicate comments (#108)