Skip to content

Commit dd0468b

Browse files
committed
update versions in one run: test-case
1 parent 31e4560 commit dd0468b

File tree

8 files changed

+157
-0
lines changed

8 files changed

+157
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
4+
<parent>
5+
<groupId>com.amashchenko.maven.plugin</groupId>
6+
<artifactId>gitflow-maven-test</artifactId>
7+
<version>1.0</version>
8+
</parent>
9+
10+
<artifactId>gitflow-maven-test-child1</artifactId>
11+
<packaging>pom</packaging>
12+
</project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
4+
<parent>
5+
<groupId>com.amashchenko.maven.plugin</groupId>
6+
<artifactId>gitflow-maven-test</artifactId>
7+
<version>1.0</version>
8+
</parent>
9+
10+
<artifactId>gitflow-maven-test-child2</artifactId>
11+
<packaging>pom</packaging>
12+
13+
<dependencyManagement>
14+
<dependencies>
15+
<dependency>
16+
<groupId>com.amashchenko.maven.plugin</groupId>
17+
<artifactId>gitflow-maven-test-child1</artifactId>
18+
<version>${test.project.version}</version>
19+
<type>pom</type>
20+
<scope>import</scope>
21+
</dependency>
22+
</dependencies>
23+
</dependencyManagement>
24+
</project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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>1.0.1</version>
7+
8+
<modules>
9+
<module>child1</module>
10+
<module>child2</module>
11+
</modules>
12+
13+
<properties>
14+
<test.project.version>1.0.1</test.project.version>
15+
</properties>
16+
</project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
build.log
2+
expected-development-pom.xml
3+
expected-production-pom.xml
4+
expected-release-pom.xml
5+
invoker.properties
6+
init.bsh
7+
verify.bsh

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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 '[email protected]'");
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 + " branch hotfix/1.0.1");
21+
p.waitFor();
22+
23+
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " checkout hotfix/1.0.1");
24+
p.waitFor();
25+
26+
for (String fileName : new String[] {"pom.xml", "child1/pom.xml", "child2/pom.xml"}) {
27+
File pomfile = new File(basedir, fileName);
28+
String pomfilestr = FileUtils.fileRead(pomfile, "UTF-8");
29+
pomfilestr = pomfilestr.replaceAll("1.0", "1.0.1-SNAPSHOT");
30+
FileUtils.fileWrite(basedir + "/" + fileName, "UTF-8", pomfilestr);
31+
}
32+
33+
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " add .");
34+
p.waitFor();
35+
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " commit -m next");
36+
p.waitFor();
37+
38+
} catch (Exception e) {
39+
e.printStackTrace();
40+
return false;
41+
}
42+
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}:hotfix-finish -DpushRemote=false -DfetchRemote=false -B -DhotfixVersion=1.0.1 -DuseSnapshotInHotfix=true -DskipMergeDevBranch=true -DversionProperty=test.project.version
2+
3+
invoker.description=Check that versions:set and versions:set-property are applied in the same run. Otherwise, hotfix-finish fails on versions:set-property as pom version is inconsistent (mixed 1.0.1-SNAPSHOT and 1.0.1).

src/it/hotfix-finish-it-3/pom.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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>1.0</version>
7+
8+
<modules>
9+
<module>child1</module>
10+
<module>child2</module>
11+
</modules>
12+
13+
<properties>
14+
<test.project.version>1.0</test.project.version>
15+
</properties>
16+
</project>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import org.codehaus.plexus.util.FileUtils;
2+
3+
try {
4+
5+
File gitTag = new File(basedir, ".git/refs/tags/1.0.1");
6+
if (!gitTag.exists()) {
7+
System.out.println("hotfix-finish .git/refs/tags/1.0.1 does not exist");
8+
return false;
9+
}
10+
File gitMasterRef = new File(basedir, ".git/refs/heads/master");
11+
if (!gitMasterRef.exists()) {
12+
System.out.println("hotfix-finish .git/refs/heads/master doesn't exist");
13+
return false;
14+
}
15+
16+
p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " checkout master");
17+
p.waitFor();
18+
19+
file = new File(basedir, "pom.xml");
20+
expectedFile = new File(basedir, "expected-production-pom.xml");
21+
22+
actual = FileUtils.fileRead(file, "UTF-8");
23+
expected = FileUtils.fileRead(expectedFile, "UTF-8");
24+
25+
actual = actual.replaceAll("\\r?\\n", "");
26+
expected = expected.replaceAll("\\r?\\n", "");
27+
28+
if (!expected.equals(actual)) {
29+
System.out.println("hotfix-finish: " + expected + " actual was:" + actual);
30+
return false;
31+
}
32+
33+
} catch (Exception e) {
34+
e.printStackTrace();
35+
return false;
36+
}
37+
return true;

0 commit comments

Comments
 (0)