Skip to content

Commit

Permalink
fix file-merge didn't work correct
Browse files Browse the repository at this point in the history
  • Loading branch information
cecom committed Nov 12, 2014
1 parent 99c6cd4 commit 35ac789
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.oppermann.pomutils</groupId>
<artifactId>pomutils</artifactId>
<version>1.0</version>
<version>1.1</version>

<licenses>
<license>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/oppermann/pomutils/PomMergeDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void adjustTheirPomVersion() {
}

public int doGitMerge() {
ProcessBuilder processBuilder = new ProcessBuilder("git", "merge-file", "-p", "-L", "our", "-L", "base", "-L", "theirs", ourPom.getPath(),
ProcessBuilder processBuilder = new ProcessBuilder("git", "merge-file", "-L", "our", "-L", "base", "-L", "theirs", ourPom.getPath(),
basePom.getPath(), theirPom.getPath());
processBuilder.redirectErrorStream(true);
try {
Expand Down
9 changes: 8 additions & 1 deletion src/test/java/de/oppermann/pomutils/PomMergeDriverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import junit.framework.TestCase;

import org.apache.commons.io.FileUtils;
import org.codehaus.mojo.versions.api.PomHelper;

import de.oppermann.pomutils.util.POM;

Expand Down Expand Up @@ -55,11 +56,17 @@ public void testAutoMergeSucceded() throws Exception {
int mergeReturnValue = pomMergeDriver.doGitMerge();

assertTrue("merge succeeded", mergeReturnValue == 0);

POM theirPom = new POM(theirPomFile);
POM ourPom = new POM(ourPomFile);

assertEquals("same version now", ourPom.getProjectVersion(), theirPom.getProjectVersion());


String theirDependecyVersoin = PomHelper.getRawModel(new File(theirPomFile)).getDependencies().get(0).getVersion();
String ourDependencyVersion = PomHelper.getRawModel(new File(ourPomFile)).getDependencies().get(0).getVersion();

assertEquals("dependency version change merged", theirDependecyVersoin, ourDependencyVersion);
}

public void testAutoMergeFailed() throws Exception {
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/merge/autoMergeSucceded/our.pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.5</version>
<version>2.1</version>
<type>maven-plugin</type>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/merge/autoMergeSucceded/their.pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.1</version>
<version>2.5</version>
<type>maven-plugin</type>
</dependency>
</dependencies>
Expand Down

0 comments on commit 35ac789

Please sign in to comment.