Skip to content

Commit bd2c394

Browse files
committed
Allow to use full branch name in feature and hotfix finish goals - see #270
1 parent 7c5a3d4 commit bd2c394

22 files changed

+336
-13
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<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">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.amashchenko.maven.plugin</groupId>
4+
<artifactId>gitflow-maven-test</artifactId>
5+
<packaging>pom</packaging>
6+
<version>0.0.3-SNAPSHOT</version>
7+
</project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
build.log
2+
expected-pom.xml
3+
invoker.properties
4+
init.bsh
5+
verify.bsh
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
try {
2+
new File(basedir, "gitignorefile").renameTo(new File(basedir, ".gitignore"));
3+
4+
Process p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " init");
5+
p.waitFor();
6+
7+
Process p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " config user.email 'a@a.aa'");
8+
p.waitFor();
9+
Process p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " config user.name 'a'");
10+
p.waitFor();
11+
12+
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " add .");
13+
p.waitFor();
14+
15+
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " commit -m init");
16+
p.waitFor();
17+
18+
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " branch feature/test");
19+
p.waitFor();
20+
21+
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " checkout -b develop");
22+
p.waitFor();
23+
24+
} catch (Exception e) {
25+
e.printStackTrace();
26+
return false;
27+
}
28+
return true;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:feature-finish -DpushRemote=false -B -DfeatureBranch=feature/test
2+
3+
invoker.description=Non-interactive feature-finish using featureBranch parameter.

src/it/feature-finish-2-it/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<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">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.amashchenko.maven.plugin</groupId>
4+
<artifactId>gitflow-maven-test</artifactId>
5+
<packaging>pom</packaging>
6+
<version>0.0.3-test-SNAPSHOT</version>
7+
</project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import org.codehaus.plexus.util.FileUtils;
2+
3+
try {
4+
File gitRef = new File(basedir, ".git/refs/heads/feature/test");
5+
if (gitRef.exists()) {
6+
System.out.println("feature-finish .git/refs/heads/feature/test exists");
7+
return false;
8+
}
9+
10+
File file = new File(basedir, "pom.xml");
11+
File expectedFile = new File(basedir, "expected-pom.xml");
12+
13+
String actual = FileUtils.fileRead(file, "UTF-8");
14+
String expected = FileUtils.fileRead(expectedFile, "UTF-8");
15+
16+
actual = actual.replaceAll("\\r?\\n", "");
17+
expected = expected.replaceAll("\\r?\\n", "");
18+
19+
if (!expected.equals(actual)) {
20+
System.out.println("feature-finish expected: " + expected + " actual was:" + actual);
21+
return false;
22+
}
23+
} catch (Exception e) {
24+
e.printStackTrace();
25+
return false;
26+
}
27+
return true;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<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">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.amashchenko.maven.plugin</groupId>
4+
<artifactId>gitflow-maven-test</artifactId>
5+
<packaging>pom</packaging>
6+
<version>0.0.4-SNAPSHOT</version>
7+
</project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<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">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.amashchenko.maven.plugin</groupId>
4+
<artifactId>gitflow-maven-test</artifactId>
5+
<packaging>pom</packaging>
6+
<version>0.0.4</version>
7+
</project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
build.log
2+
expected-development-pom.xml
3+
expected-production-pom.xml
4+
invoker.properties
5+
init.bsh
6+
verify.bsh

src/it/hotfix-finish-4-it/init.bsh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import org.codehaus.plexus.util.FileUtils;
2+
3+
try {
4+
new File(basedir, "gitignorefile").renameTo(new File(basedir, ".gitignore"));
5+
6+
Process p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " init");
7+
p.waitFor();
8+
9+
Process p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " config user.email 'a@a.aa'");
10+
p.waitFor();
11+
Process p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " config user.name 'a'");
12+
p.waitFor();
13+
14+
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " add .");
15+
p.waitFor();
16+
17+
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " commit -m init");
18+
p.waitFor();
19+
20+
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " checkout -b develop");
21+
p.waitFor();
22+
23+
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " checkout -b hotfix/0.0.4");
24+
p.waitFor();
25+
26+
File pomfile = new File(basedir, "pom.xml");
27+
String pomfilestr = FileUtils.fileRead(pomfile, "UTF-8");
28+
pomfilestr = pomfilestr.replaceAll("0.0.3", "0.0.4");
29+
FileUtils.fileWrite(basedir + "/pom.xml", "UTF-8", pomfilestr);
30+
31+
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " add .");
32+
p.waitFor();
33+
34+
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " commit -m next");
35+
p.waitFor();
36+
37+
} catch (Exception e) {
38+
e.printStackTrace();
39+
return false;
40+
}
41+
return true;

0 commit comments

Comments
 (0)