-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
Hotfix Finish support without parameter hotfixBranch #327
Open
basmussen
wants to merge
1
commit into
aleksandr-m:master
Choose a base branch
from
dataliquid:feature/326-one-hotfix-branch
base: master
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.amashchenko.maven.plugin</groupId> | ||
<artifactId>gitflow-maven-test</artifactId> | ||
<packaging>pom</packaging> | ||
<version>0.0.4-SNAPSHOT</version> | ||
</project> |
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,7 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.amashchenko.maven.plugin</groupId> | ||
<artifactId>gitflow-maven-test</artifactId> | ||
<packaging>pom</packaging> | ||
<version>0.0.4</version> | ||
</project> |
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,6 @@ | ||
build.log | ||
expected-development-pom.xml | ||
expected-production-pom.xml | ||
invoker.properties | ||
init.bsh | ||
verify.bsh |
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,41 @@ | ||
import org.codehaus.plexus.util.FileUtils; | ||
|
||
try { | ||
new File(basedir, "gitignorefile").renameTo(new File(basedir, ".gitignore")); | ||
|
||
Process p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " init"); | ||
p.waitFor(); | ||
|
||
Process p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " config user.email '[email protected]'"); | ||
p.waitFor(); | ||
Process p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " config user.name 'a'"); | ||
p.waitFor(); | ||
|
||
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " add ."); | ||
p.waitFor(); | ||
|
||
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " commit -m init"); | ||
p.waitFor(); | ||
|
||
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " checkout -b develop"); | ||
p.waitFor(); | ||
|
||
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " checkout -b hotfix/0.0.4"); | ||
p.waitFor(); | ||
|
||
File pomfile = new File(basedir, "pom.xml"); | ||
String pomfilestr = FileUtils.fileRead(pomfile, "UTF-8"); | ||
pomfilestr = pomfilestr.replaceAll("0.0.3", "0.0.4"); | ||
FileUtils.fileWrite(basedir + "/pom.xml", "UTF-8", pomfilestr); | ||
|
||
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " add ."); | ||
p.waitFor(); | ||
|
||
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " commit -m next"); | ||
p.waitFor(); | ||
|
||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return false; | ||
} | ||
return true; |
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,3 @@ | ||
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:hotfix-finish -DpushRemote=false -B | ||
|
||
invoker.description=Non-interactive hotfix-finish without using hotfixBranch parameter. |
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,7 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.amashchenko.maven.plugin</groupId> | ||
<artifactId>gitflow-maven-test</artifactId> | ||
<packaging>pom</packaging> | ||
<version>0.0.3</version> | ||
</project> |
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 @@ | ||
import org.codehaus.plexus.util.FileUtils; | ||
|
||
try { | ||
File gitRef = new File(basedir, ".git/refs/heads/hotfix/0.0.4"); | ||
if (gitRef.exists()) { | ||
System.out.println("hotfix-finish .git/refs/heads/hotfix/0.0.4 exists"); | ||
return false; | ||
} | ||
|
||
File file = new File(basedir, "pom.xml"); | ||
File expectedFile = new File(basedir, "expected-development-pom.xml"); | ||
|
||
String actual = FileUtils.fileRead(file, "UTF-8"); | ||
String expected = FileUtils.fileRead(expectedFile, "UTF-8"); | ||
|
||
if (!expected.equals(actual)) { | ||
System.out.println("hotfix-finish expected: " + expected + " actual was:" + actual); | ||
return false; | ||
} | ||
|
||
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " checkout master"); | ||
p.waitFor(); | ||
|
||
file = new File(basedir, "pom.xml"); | ||
expectedFile = new File(basedir, "expected-production-pom.xml"); | ||
|
||
actual = FileUtils.fileRead(file, "UTF-8"); | ||
expected = FileUtils.fileRead(expectedFile, "UTF-8"); | ||
|
||
if (!expected.equals(actual)) { | ||
System.out.println("hotfix-finish expected: " + expected + " actual was:" + actual); | ||
return false; | ||
} | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return false; | ||
} | ||
return true; |
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
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.
DISCLAIMER: I'm not a maintainer, so feel free to ignore what I'm saying. 😉
This is basically the same block as in
GitFlowReleaseFinishMojo
.I wonder if it makes sense / is possible to avoid the duplicated code by, e.g., having an intermediate layer like
AbstractGitFlowFinishMojo
, which encloses this functionality. (Although it looks likeGitFlowFeatureFinishMojo
couldn't benefit from it.)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.
Abstraction via inheritance is an obvious improvement since you write less code, right? But in many cases inheritance becomes much more inconvenient to maintain, than just copy some code, that has potential to diverge a little in the future.
If any, I would prefer using composition over inheritance everywhere. At least you can interchange the solution with a very less effort.
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.
No, but thanks for ELI5. 😉