From e1f4f900f6557f8e5b17cd39aba0cd07ee207263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20Sch=C3=B6ning?= Date: Wed, 22 Feb 2012 13:40:02 +0100 Subject: [PATCH 1/2] Fixed a bug in changeLogResult checkout calls changeLogResult with a null-changelog, but changeLogResult handles this as an error and returns false. This false is delivered directly to Hudson which is aborting the build if it was started without any commit. We had to ways to fix this: Let checkout always return true on now changes or change changeLogResult to always return true. I preferred the latter because the intended call of changeLogResult seems like deleting the changeLogFile. --- src/main/java/hudson/plugins/git/GitSCM.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/hudson/plugins/git/GitSCM.java b/src/main/java/hudson/plugins/git/GitSCM.java index 610e626c..d393aff7 100644 --- a/src/main/java/hudson/plugins/git/GitSCM.java +++ b/src/main/java/hudson/plugins/git/GitSCM.java @@ -1462,18 +1462,16 @@ private RemoteConfig newRemoteConfig(String name, String refUrl, RefSpec refSpec } } - private boolean changeLogResult(String changeLog, File changelogFile) throws IOException { - if (changeLog == null) { - return false; - } else { - changelogFile.delete(); + private boolean changeLogResult(String changeLog, File changeLogFile) throws IOException { + changeLogFile.delete(); - FileOutputStream fos = new FileOutputStream(changelogFile); + if (changeLog != null) { + FileOutputStream fos = new FileOutputStream(changeLogFile); fos.write(changeLog.getBytes()); fos.close(); - // Write to file - return true; } + + return true; } private Pattern[] getExcludedRegionsPatterns() { From 310a123c18923449d922b5124fa6d234d187eddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20Sch=C3=B6ning?= Date: Wed, 22 Feb 2012 13:43:43 +0100 Subject: [PATCH 2/2] gerRevisionToBuild -> getRevisionToBuild --- src/main/java/hudson/plugins/git/GitSCM.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/hudson/plugins/git/GitSCM.java b/src/main/java/hudson/plugins/git/GitSCM.java index d393aff7..87cafa24 100644 --- a/src/main/java/hudson/plugins/git/GitSCM.java +++ b/src/main/java/hudson/plugins/git/GitSCM.java @@ -619,7 +619,7 @@ public boolean checkout(final AbstractBuild build, Launcher launcher, } List repos = entry.getValue(); - final Revision revToBuild = gerRevisionToBuild(listener, workingDirectory, gitExe, buildData, environment, + final Revision revToBuild = getRevisionToBuild(listener, workingDirectory, gitExe, buildData, environment, singleBranch, repos, parentLastBuiltRev, rpa); @@ -647,7 +647,6 @@ public boolean checkout(final AbstractBuild build, Launcher launcher, buildConfig = getBuildConfig(listener, workingDirectory, buildNumber, gitExe, buildData, environment, paramLocalBranch, repos, revToBuild, internalTagName, internalTagComment); - build.addAction(buildConfig.getBuildData()); result = result && changeLogResult(buildConfig.getChangeLog(), changelogFile); @@ -838,7 +837,7 @@ public BuildConfig invoke(File localWorkspace, VirtualChannel channel) }); } - private Revision gerRevisionToBuild(final BuildListener listener, FilePath workingDirectory, final String gitExe, + private Revision getRevisionToBuild(final BuildListener listener, FilePath workingDirectory, final String gitExe, final BuildData buildData, final EnvVars environment, final String singleBranch, final List paramRepos, final Revision parentLastBuiltRev, final RevisionParameterAction rpa) throws IOException, InterruptedException {