This repository has been archived by the owner on Jan 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
[SHIPKIT-513] Automated commit message should have CI build ID #682
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
83fd005
[SHIPKIT-513] Initial solution using Travis ENV
ArturSkowronski ca359de
[SHIPKIT-513] Exposing Travis URL to external class
ArturSkowronski 7cc4e74
[SHIPKIT-513] Quick exit if commit message is null
ArturSkowronski cebc216
Merge branch 'master' into SHIPKIT-513
ArturSkowronski bbbd06b
[SHIPKIT-513] Setting new message
ArturSkowronski 0abad20
[SHIPKIT-513] Generate Prefix in GitPlugin
ArturSkowronski 23619f5
[SHIPKIT-513] Restoring Travis Plugin
ArturSkowronski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
subprojects/shipkit/src/main/groovy/org/shipkit/internal/gradle/travis/TravisUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.shipkit.internal.gradle.travis; | ||
|
||
import org.shipkit.gradle.configuration.ShipkitConfiguration; | ||
|
||
public class TravisUtils { | ||
|
||
private static final String URL_PATTERN = "https://travis-ci.org/%s/builds/%s"; | ||
|
||
public static String generateCommitMessagePostfix(ShipkitConfiguration conf, String travisBuildNumber) { | ||
if (travisBuildNumber == null) { | ||
return conf.getGit().getCommitMessagePostfix(); | ||
} | ||
String travisJobUrl = generateTravisBuildUrl(conf, travisBuildNumber); | ||
|
||
return String.format("CI job: %s %s", travisJobUrl, conf.getGit().getCommitMessagePostfix()); | ||
} | ||
|
||
private static String generateTravisBuildUrl(ShipkitConfiguration conf, String travisBuildNumber) { | ||
return String.format(URL_PATTERN, conf.getGitHub().getRepository(), travisBuildNumber); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...rojects/shipkit/src/test/groovy/org/shipkit/internal/gradle/travis/TravisUtilsTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.shipkit.internal.gradle.travis | ||
|
||
import org.shipkit.gradle.configuration.ShipkitConfiguration | ||
import spock.lang.Specification | ||
|
||
class TravisUtilsTest extends Specification { | ||
|
||
def "should build travis url with [ci skip]"() { | ||
given: | ||
ShipkitConfiguration shipkitConfiguration = Mock(ShipkitConfiguration) | ||
ShipkitConfiguration.GitHub gitHub = Mock(ShipkitConfiguration.GitHub) | ||
ShipkitConfiguration.Git git = Mock(ShipkitConfiguration.Git) | ||
shipkitConfiguration.getGitHub() >> gitHub | ||
shipkitConfiguration.getGit() >> git | ||
1 * git.commitMessagePostfix >> "[ci skip]" | ||
1 * gitHub.getRepository() >> "mockito/shipkit" | ||
0 * _ | ||
when: | ||
def url = TravisUtils.generateCommitMessagePostfix(shipkitConfiguration, "123") | ||
then: | ||
url == "CI job: https://travis-ci.org/mockito/shipkit/builds/123 [ci skip]" | ||
} | ||
|
||
def "should build postfix without travis url if blank build number"() { | ||
given: | ||
ShipkitConfiguration shipkitConfiguration = Mock(ShipkitConfiguration) | ||
ShipkitConfiguration.GitHub gitHub = Mock(ShipkitConfiguration.GitHub) | ||
ShipkitConfiguration.Git git = Mock(ShipkitConfiguration.Git) | ||
shipkitConfiguration.getGitHub() >> gitHub | ||
shipkitConfiguration.getGit() >> git | ||
1 * git.commitMessagePostfix >> "[ci skip]" | ||
0 * _ | ||
when: | ||
def url = TravisUtils.generateCommitMessagePostfix(shipkitConfiguration, "") | ||
then: | ||
url == "[ci skip]" | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We want to set the commit message on the GitCommitTask. We don't want to generate commit message for ReleaseNeededTask because this task should work on verbatim commit message supplied by Travis. ReleaseNeededTask is not making commits :)
Check out the initial design of this feature at #514
When you work on this feature, I suggest to test it this way:
Above will get you a local commit with the message. Please ensure that this commit has the stuff we need.
Thank you for working on this!!!
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.
Sure, I created PR to confirm my assumptions were right (which were wrong, but now I got feedback :)).
I'll add necessary changes.