Skip to content

Commit a11f4fd

Browse files
authored
Merge pull request #32 from Praqma/ready/fix-for-29
Fix for #29
2 parents bf27d83 + 1c2ef48 commit a11f4fd

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

src/main/java/org/jenkinsci/plugins/pretestedintegration/scm/git/AccumulatedCommitStrategy.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,15 @@ public void integrate(AbstractBuild<?, ?> build, Launcher launcher, BuildListene
153153
logMessage = String.format(PretestedIntegrationBuildWrapper.LOG_PREFIX + "Commit of accumulated merge done");
154154
LOGGER.info(logMessage);
155155
listener.getLogger().println(logMessage);
156-
} catch (IOException | GitException | InterruptedException ex) {
157-
// If ".git/MERGE_MSG" wasn't found the most likely culrprit is that the merge was an empty
158-
// one (No changes) for some reason the merge() command does not complain or throw exception when that happens
159-
if(ex.getMessage().contains("Cannot commit") || ex.getMessage().contains("MERGE_MSG (No such file or directory)")) {
160-
logMessage = String.format("%sUnable to commit changes. Most likely you are trying to integrate a change that was already integrated. Message was:%n%s", PretestedIntegrationBuildWrapper.LOG_PREFIX, ex.getMessage());
161-
} else {
162-
logMessage = String.format(PretestedIntegrationBuildWrapper.LOG_PREFIX + "Exception while committing. Logging exception msg: %s", ex.getMessage());
163-
}
156+
} catch (FileNotFoundException | GitException ex) {
157+
//See Github issue #29 (https://github.com/Praqma/pretested-integration-plugin/issues/29)
158+
logMessage = String.format("%sUnable to commit changes. Most likely you are trying to integrate a change that was already integrated. Message was:%n%s", PretestedIntegrationBuildWrapper.LOG_PREFIX, ex.getMessage());
159+
LOGGER.log(Level.SEVERE, logMessage, ex);
160+
listener.getLogger().println(logMessage);
161+
ex.printStackTrace(listener.getLogger());
162+
throw new IntegrationFailedException(ex);
163+
} catch ( IOException | InterruptedException ex) {
164+
logMessage = String.format(PretestedIntegrationBuildWrapper.LOG_PREFIX + "Exception while committing. Logging exception msg: %s", ex.getMessage());
164165
LOGGER.log(Level.SEVERE, logMessage, ex);
165166
listener.getLogger().println(logMessage);
166167
ex.printStackTrace(listener.getLogger());

src/main/java/org/jenkinsci/plugins/pretestedintegration/scm/git/SquashCommitStrategy.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void integrate(AbstractBuild<?, ?> build, Launcher launcher, BuildListene
9393
LOGGER.log(Level.INFO, logMessage);
9494
listener.getLogger().println(logMessage);
9595
commitAuthor = client.withRepository(new FindCommitAuthorCallback(listener, builtBranch.getSHA1()));
96-
logMessage = String.format(PretestedIntegrationBuildWrapper.LOG_PREFIX + "Done colecting last commit author: %s", commitAuthor);
96+
logMessage = String.format(PretestedIntegrationBuildWrapper.LOG_PREFIX + "Done collecting last commit author: %s", commitAuthor);
9797
LOGGER.log(Level.INFO, logMessage);
9898
listener.getLogger().println(logMessage);
9999

@@ -127,14 +127,14 @@ public void integrate(AbstractBuild<?, ?> build, Launcher launcher, BuildListene
127127
logMessage = String.format(PretestedIntegrationBuildWrapper.LOG_PREFIX + "Commit of squashed merge done");
128128
LOGGER.info(logMessage);
129129
listener.getLogger().println(logMessage);
130-
} catch (IOException | GitException | InterruptedException ex) {
131-
// If ".git/MERGE_MSG" wasn't found the most likely culrprit is that the merge was an empty
132-
// one (No changes) for some reason the merge() command does not complain or throw exception when that happens
133-
if(ex.getMessage().contains("Cannot commit") || ex.getMessage().contains("MERGE_MSG (No such file or directory)")) {
134-
logMessage = String.format("%sUnable to commit changes. Most likely you are trying to integrate a change that was already integrated. Message was:%n%s", PretestedIntegrationBuildWrapper.LOG_PREFIX, ex.getMessage());
135-
} else {
136-
logMessage = String.format(PretestedIntegrationBuildWrapper.LOG_PREFIX + "Exception while committing. Logging exception msg: %s", ex.getMessage());
137-
}
130+
} catch (FileNotFoundException | GitException ex) {
131+
//See Github issue #29 (https://github.com/Praqma/pretested-integration-plugin/issues/29)
132+
logMessage = String.format("%sUnable to commit changes. Most likely you are trying to integrate a change that was already integrated. Message was:%n%s", PretestedIntegrationBuildWrapper.LOG_PREFIX, ex.getMessage());
133+
LOGGER.log(Level.SEVERE, logMessage, ex);
134+
listener.getLogger().println(logMessage);
135+
throw new IntegrationFailedException(ex);
136+
} catch (IOException | InterruptedException ex) {
137+
logMessage = String.format(PretestedIntegrationBuildWrapper.LOG_PREFIX + "Exception while committing. Logging exception msg: %s", ex.getMessage());
138138
LOGGER.log(Level.SEVERE, logMessage, ex);
139139
listener.getLogger().println(logMessage);
140140
throw new IntegrationFailedException(ex);

0 commit comments

Comments
 (0)