-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[patch] adding parameters for setting username and email
- Loading branch information
1 parent
1210a84
commit 6fb89a9
Showing
8 changed files
with
81 additions
and
16 deletions.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,19 +37,29 @@ interface TagTestSpec { | |
fun configureWithDefaults() | ||
fun configureWithOverrides( | ||
releaseBranch: String? = null, | ||
userName: String? = null, | ||
userEmail: String? = null, | ||
warningsAsErrors: Boolean? = null, | ||
) | ||
|
||
fun execute(version: String): TestResult | ||
|
||
@BeforeTest | ||
fun checkPrerequisites() { | ||
assertEquals("/dev/null", System.getenv("GIT_CONFIG_GLOBAL"), "Ensure this is set for the test to work as intended") | ||
assertEquals("/dev/null", System.getenv("GIT_CONFIG_SYSTEM"), "Ensure this is set for the test to work as intended") | ||
assertEquals( | ||
"/dev/null", | ||
System.getenv("GIT_CONFIG_GLOBAL"), | ||
"Ensure this is set for the test to work as intended", | ||
) | ||
assertEquals( | ||
"/dev/null", | ||
System.getenv("GIT_CONFIG_SYSTEM"), | ||
"Ensure this is set for the test to work as intended", | ||
) | ||
} | ||
|
||
@Test | ||
fun tagWillTagAndPushSuccessfully() { | ||
fun whenUserNameAndEmailAreConfiguredTagWillTagAndPush() { | ||
configureWithDefaults() | ||
|
||
val originDirectory = createTempDirectory() | ||
|
@@ -77,6 +87,32 @@ interface TagTestSpec { | |
assertEquals(expectedVersion, gitAdapter.showTag("HEAD")) | ||
} | ||
|
||
@Test | ||
fun whenUserNameAndEmailAreParametersTagWillTagAndPush() { | ||
configureWithOverrides(releaseBranch = "master", userName = "RoB as Test", userEmail = "[email protected]", warningsAsErrors = true) | ||
|
||
val originDirectory = createTempDirectory() | ||
val originGrgit = Grgit.init(fun InitOp.() { | ||
this.dir = originDirectory.absolutePathString() | ||
}) | ||
disableGpgSign(originDirectory.absolutePathString()) | ||
originGrgit.commit(fun CommitOp.() { | ||
this.message = "init" | ||
}) | ||
val grgit = initializeGitRepo( | ||
listOf("init", "[patch] commit 1", "[patch] commit 2"), | ||
remoteUrl = originDirectory.absolutePathString(), | ||
) | ||
grgit.push() | ||
|
||
val expectedVersion = "1.0.0" | ||
val result = execute(expectedVersion) | ||
assertIsNot<TestResult.Failure>(result, message = "$result") | ||
|
||
val gitAdapter = GitAdapter(this.projectDir.absolutePath) | ||
assertEquals(expectedVersion, gitAdapter.showTag("HEAD")) | ||
} | ||
|
||
@Test | ||
fun tagWillFailWhenUserEmailAndNameAreNotConfigured() { | ||
configureWithOverrides(releaseBranch = "master", warningsAsErrors = true) | ||
|