-
Notifications
You must be signed in to change notification settings - Fork 52
Feature/153 support release of multiple major versions #155
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
Open
nroeske
wants to merge
6
commits into
develop
Choose a base branch
from
feature/153-support-release-of-multiple-major-versions
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ecc7a98
#153 set development branch for finish gitflow release
nroeske 7265f0c
#153 update changelog
nroeske adcc4c7
#153 make release process more secure by checking BASE_VERSION in Mak…
nroeske aab6d6a
#153 check unallowed backport
nroeske 51e6770
#153 support legacy master branch in git flow
Sgu74 0784042
#153 add tests and refactor
Sgu74 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -140,6 +140,179 @@ class GitFlowTest { | |
| assertEquals("git push --delete origin myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| } | ||
|
|
||
| @Test | ||
| void testFinishReleaseWithCustomMainAndDevelopBranch() { | ||
| String releaseBranchAuthorName = 'release' | ||
| String releaseBranchEmail = '[email protected]' | ||
| String releaseBranchAuthor = createGitAuthorString(releaseBranchAuthorName, releaseBranchEmail) | ||
| String developBranchAuthorName = 'develop' | ||
| String developBranchEmail = '[email protected]' | ||
| String developBranchAuthor = createGitAuthorString(developBranchAuthorName, developBranchEmail) | ||
| scriptMock.expectedShRetValueForScript.put('git --no-pager show -s --format=\'%an <%ae>\' HEAD', | ||
| [releaseBranchAuthor, releaseBranchAuthor, releaseBranchAuthor, releaseBranchAuthor, | ||
| // these two are the ones where the release branch author is stored: | ||
| releaseBranchAuthor, releaseBranchAuthor, | ||
| developBranchAuthor, developBranchAuthor | ||
| ]) | ||
| scriptMock.expectedShRetValueForScript.put('git push origin main/1.0 dev/1.0 myVersion', 0) | ||
|
|
||
| scriptMock.expectedDefaultShRetValue = "" | ||
| scriptMock.env.BRANCH_NAME = "myReleaseBranch" | ||
| Git git = new Git(scriptMock) | ||
| GitFlow gitflow = new GitFlow(scriptMock, git) | ||
| gitflow.finishRelease("myVersion", "main/1.0", "dev/1.0") | ||
|
|
||
| scriptMock.allActualArgs.removeAll("echo ") | ||
| scriptMock.allActualArgs.removeAll("git --no-pager show -s --format='%an <%ae>' HEAD") | ||
| int i = 0 | ||
| assertEquals("git ls-remote origin refs/tags/myVersion", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git config 'remote.origin.fetch' '+refs/heads/*:refs/remotes/origin/*'", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git fetch --all", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git log origin/myReleaseBranch..origin/dev/1.0 --oneline", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git checkout myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git reset --hard origin/myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git checkout dev/1.0", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git reset --hard origin/dev/1.0", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git checkout main/1.0", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git reset --hard origin/main/1.0", scriptMock.allActualArgs[i++]) | ||
|
|
||
| // Author & Email 1 (calls 'git --no-pager...' twice) | ||
| assertEquals("git merge --no-ff myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| assertAuthor(0, releaseBranchAuthorName, releaseBranchEmail) | ||
|
|
||
| // Author & Email 2 (calls 'git --no-pager...' twice) | ||
| assertEquals("git tag -f -m \"release version myVersion\" myVersion", scriptMock.allActualArgs[i++]) | ||
| assertAuthor(1, releaseBranchAuthorName, releaseBranchEmail) | ||
|
|
||
| assertEquals("git checkout dev/1.0", scriptMock.allActualArgs[i++]) | ||
| // Author & Email 3 (calls 'git --no-pager...' twice) | ||
| assertEquals("git merge --no-ff myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| assertAuthor(2, releaseBranchAuthorName, releaseBranchEmail) | ||
|
|
||
| assertEquals("git branch -d myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git checkout myVersion", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git push origin main/1.0 dev/1.0 myVersion", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git push --delete origin myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| } | ||
|
|
||
| @Test | ||
| void testFinishReleaseWithBaseVersionSet() { | ||
| String releaseBranchAuthorName = 'release' | ||
| String releaseBranchEmail = '[email protected]' | ||
| String releaseBranchAuthor = createGitAuthorString(releaseBranchAuthorName, releaseBranchEmail) | ||
| String developBranchAuthorName = 'develop' | ||
| String developBranchEmail = '[email protected]' | ||
| String developBranchAuthor = createGitAuthorString(developBranchAuthorName, developBranchEmail) | ||
| scriptMock.expectedShRetValueForScript.put('git --no-pager show -s --format=\'%an <%ae>\' HEAD', | ||
| [releaseBranchAuthor, releaseBranchAuthor, releaseBranchAuthor, releaseBranchAuthor, | ||
| // these two are the ones where the release branch author is stored: | ||
| releaseBranchAuthor, releaseBranchAuthor, | ||
| developBranchAuthor, developBranchAuthor | ||
| ]) | ||
| scriptMock.expectedShRetValueForScript.put('git push origin 4.2.2/main 4.2.2/develop myVersion', 0) | ||
|
|
||
| scriptMock.expectedDefaultShRetValue = "" | ||
| scriptMock.env.BRANCH_NAME = "myReleaseBranch" | ||
| scriptMock.expectedShRetValueForScript.put('grep -e "^BASE_VERSION=" Makefile | sed "s/BASE_VERSION=//g"'.toString(), "4.2.2".toString()) | ||
|
|
||
| Git git = new Git(scriptMock) | ||
| Makefile makefile = new Makefile(scriptMock) | ||
| GitFlow gitflow = new GitFlow(scriptMock, git, makefile) | ||
| gitflow.finishRelease("myVersion", "4.2.2/main", "4.2.2/develop") | ||
|
|
||
| scriptMock.allActualArgs.removeAll("echo ") | ||
| scriptMock.allActualArgs.removeAll("git --no-pager show -s --format='%an <%ae>' HEAD") | ||
| int i = 0 | ||
| assertEquals("git ls-remote origin refs/tags/myVersion", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git config 'remote.origin.fetch' '+refs/heads/*:refs/remotes/origin/*'", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git fetch --all", scriptMock.allActualArgs[i++]) | ||
| assertEquals("grep -e \"^BASE_VERSION=\" Makefile | sed \"s/BASE_VERSION=//g\"", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git log origin/myReleaseBranch..origin/4.2.2/develop --oneline", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git checkout myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git reset --hard origin/myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git checkout 4.2.2/develop", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git reset --hard origin/4.2.2/develop", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git checkout 4.2.2/main", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git reset --hard origin/4.2.2/main", scriptMock.allActualArgs[i++]) | ||
|
|
||
| // Author & Email 1 (calls 'git --no-pager...' twice) | ||
| assertEquals("git merge --no-ff myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| assertAuthor(0, releaseBranchAuthorName, releaseBranchEmail) | ||
|
|
||
| // Author & Email 2 (calls 'git --no-pager...' twice) | ||
| assertEquals("git tag -f -m \"release version myVersion\" myVersion", scriptMock.allActualArgs[i++]) | ||
| assertAuthor(1, releaseBranchAuthorName, releaseBranchEmail) | ||
|
|
||
| assertEquals("git checkout 4.2.2/develop", scriptMock.allActualArgs[i++]) | ||
| // Author & Email 3 (calls 'git --no-pager...' twice) | ||
| assertEquals("git merge --no-ff myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| assertAuthor(2, releaseBranchAuthorName, releaseBranchEmail) | ||
|
|
||
| assertEquals("git branch -d myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git checkout myVersion", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git push origin 4.2.2/main 4.2.2/develop myVersion", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git push --delete origin myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| } | ||
|
|
||
| @Test | ||
| void testFinishReleaseWithBaseVersionUnSet() { | ||
| String releaseBranchAuthorName = 'release' | ||
| String releaseBranchEmail = '[email protected]' | ||
| String releaseBranchAuthor = createGitAuthorString(releaseBranchAuthorName, releaseBranchEmail) | ||
| String developBranchAuthorName = 'develop' | ||
| String developBranchEmail = '[email protected]' | ||
| String developBranchAuthor = createGitAuthorString(developBranchAuthorName, developBranchEmail) | ||
| scriptMock.expectedShRetValueForScript.put('git --no-pager show -s --format=\'%an <%ae>\' HEAD', | ||
| [releaseBranchAuthor, releaseBranchAuthor, releaseBranchAuthor, releaseBranchAuthor, | ||
| // these two are the ones where the release branch author is stored: | ||
| releaseBranchAuthor, releaseBranchAuthor, | ||
| developBranchAuthor, developBranchAuthor | ||
| ]) | ||
| scriptMock.expectedShRetValueForScript.put('git push origin master develop myVersion', 0) | ||
|
|
||
| scriptMock.expectedDefaultShRetValue = "" | ||
| scriptMock.env.BRANCH_NAME = "myReleaseBranch" | ||
| scriptMock.expectedShRetValueForScript.put('grep -e "^BASE_VERSION=" Makefile | sed "s/BASE_VERSION=//g"'.toString(), "".toString()) | ||
|
|
||
| Git git = new Git(scriptMock) | ||
| Makefile makefile = new Makefile(scriptMock) | ||
| GitFlow gitflow = new GitFlow(scriptMock, git, makefile) | ||
| gitflow.finishRelease("myVersion") | ||
|
|
||
| scriptMock.allActualArgs.removeAll("echo ") | ||
| scriptMock.allActualArgs.removeAll("git --no-pager show -s --format='%an <%ae>' HEAD") | ||
| int i = 0 | ||
| assertEquals("git ls-remote origin refs/tags/myVersion", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git config 'remote.origin.fetch' '+refs/heads/*:refs/remotes/origin/*'", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git fetch --all", scriptMock.allActualArgs[i++]) | ||
| assertEquals("grep -e \"^BASE_VERSION=\" Makefile | sed \"s/BASE_VERSION=//g\"", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git log origin/myReleaseBranch..origin/develop --oneline", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git checkout myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git reset --hard origin/myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git checkout develop", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git reset --hard origin/develop", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git checkout master", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git reset --hard origin/master", scriptMock.allActualArgs[i++]) | ||
|
|
||
| // Author & Email 1 (calls 'git --no-pager...' twice) | ||
| assertEquals("git merge --no-ff myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| assertAuthor(0, releaseBranchAuthorName, releaseBranchEmail) | ||
|
|
||
| // Author & Email 2 (calls 'git --no-pager...' twice) | ||
| assertEquals("git tag -f -m \"release version myVersion\" myVersion", scriptMock.allActualArgs[i++]) | ||
| assertAuthor(1, releaseBranchAuthorName, releaseBranchEmail) | ||
|
|
||
| assertEquals("git checkout develop", scriptMock.allActualArgs[i++]) | ||
| // Author & Email 3 (calls 'git --no-pager...' twice) | ||
| assertEquals("git merge --no-ff myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| assertAuthor(2, releaseBranchAuthorName, releaseBranchEmail) | ||
|
|
||
| assertEquals("git branch -d myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git checkout myVersion", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git push origin master develop myVersion", scriptMock.allActualArgs[i++]) | ||
| assertEquals("git push --delete origin myReleaseBranch", scriptMock.allActualArgs[i++]) | ||
| } | ||
|
|
||
| @Test | ||
| void testThrowsErrorWhenTagAlreadyExists() { | ||
| scriptMock.expectedShRetValueForScript.put('git ls-remote origin refs/tags/myVersion', 'thisIsATag') | ||
|
|
@@ -163,6 +336,55 @@ class GitFlowTest { | |
| assertEquals("There are changes on develop branch that are not merged into release. Please merge and restart process.", err.getMessage()) | ||
| } | ||
|
|
||
| @Test | ||
| void testIsUnallowedBackportReleaseIsUnallowedStandardBranches() { | ||
| scriptMock.expectedShRetValueForScript.put('grep -e "^BASE_VERSION=" Makefile | sed "s/BASE_VERSION=//g"'.toString(), "4.2".toString()) | ||
|
|
||
| Git git = new Git(scriptMock) | ||
| Makefile makefile = new Makefile(scriptMock) | ||
| GitFlow gitflow = new GitFlow(scriptMock, git, makefile) | ||
| def result = gitflow.isUnallowedBackportRelease("main", "develop") | ||
|
|
||
| assertEquals(true, result) | ||
| } | ||
|
|
||
| @Test | ||
| void testIsUnallowedBackportReleaseIsUnallowedStandardBranches2() { | ||
| scriptMock.expectedShRetValueForScript.put('grep -e "^BASE_VERSION=" Makefile | sed "s/BASE_VERSION=//g"'.toString(), "4.2".toString()) | ||
|
|
||
| Git git = new Git(scriptMock) | ||
| Makefile makefile = new Makefile(scriptMock) | ||
| GitFlow gitflow = new GitFlow(scriptMock, git, makefile) | ||
| def result = gitflow.isUnallowedBackportRelease("master", "develop") | ||
|
|
||
| assertEquals(true, result) | ||
| } | ||
|
|
||
| @Test | ||
| void testIsUnallowedBackportReleaseIsUnallowedWrongVersionBranches() { | ||
| scriptMock.expectedShRetValueForScript.put('grep -e "^BASE_VERSION=" Makefile | sed "s/BASE_VERSION=//g"'.toString(), "4.2".toString()) | ||
|
|
||
| Git git = new Git(scriptMock) | ||
| Makefile makefile = new Makefile(scriptMock) | ||
| GitFlow gitflow = new GitFlow(scriptMock, git, makefile) | ||
| def result = gitflow.isUnallowedBackportRelease("4.3/main", "4.3/develop") | ||
|
|
||
| assertEquals(true, result) | ||
| } | ||
|
|
||
| @Test | ||
| void testIsUnallowedBackportReleaseIsAllowed() { | ||
| scriptMock.expectedShRetValueForScript.put('grep -e "^BASE_VERSION=" Makefile | sed "s/BASE_VERSION=//g"'.toString(), "4.2".toString()) | ||
|
|
||
| Git git = new Git(scriptMock) | ||
| Makefile makefile = new Makefile(scriptMock) | ||
| GitFlow gitflow = new GitFlow(scriptMock, git, makefile) | ||
| def result = gitflow.isUnallowedBackportRelease("4.2/main", "4.2/develop") | ||
|
|
||
| assertEquals(false, result) | ||
| } | ||
|
|
||
|
|
||
| void assertAuthor(int withEnvInvocationIndex, String author, String email) { | ||
| def withEnvMap = scriptMock.actualWithEnvAsMap(withEnvInvocationIndex) | ||
| assert withEnvMap['GIT_AUTHOR_NAME'] == author | ||
|
|
||
Oops, something went wrong.
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.
What is happening here? :D why is that call returning 6 times release Author and two times developAuthor?