Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-13368] Merging in change as suggested. Also added a little null
checking for the buildData being passed around now.
  • Loading branch information
David Tanner committed Oct 25, 2012
1 parent cb2e9c9 commit 8e13991
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
14 changes: 11 additions & 3 deletions src/main/java/hudson/plugins/git/GitAPI.java
Expand Up @@ -8,6 +8,7 @@
import hudson.Launcher.LocalLauncher;
import hudson.Util;
import hudson.model.TaskListener;
import hudson.plugins.git.util.BuildData;
import hudson.remoting.VirtualChannel;
import hudson.util.ArgumentListBuilder;

Expand Down Expand Up @@ -386,12 +387,19 @@ private void whatchanged(String revFrom, String revTo, OutputStream outputStream
* @return The git show output, in List form.
* @throws GitException if errors were encountered running git show.
*/
public List<String> showRevision(Revision r) throws GitException {
String revName = r.getSha1String();
public List<String> showRevision(Revision r, BuildData buildData) throws GitException {
String revName = r.getSha1String();
if (buildData != null){
revName = buildData.lastBuild.revision.sha1.name() +".." + r.getSha1String();
}
String result = "";

if (revName != null) {
result = launchCommand("whatchanged", "--no-abbrev", "-M", "-m", "--pretty=raw", "-1", revName);
if (buildData != null){
result = launchCommand("show", "--no-abbrev", "--format=raw", "-M", "--raw", revName);
} else {
result = launchCommand("whatchanged", "--no-abbrev", "-M", "-m", "--pretty=raw", "-1", revName);
}
}

List<String> revShow = new ArrayList<String>();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/hudson/plugins/git/GitSCM.java
Expand Up @@ -744,7 +744,7 @@ public Boolean invoke(File localWorkspace, VirtualChannel channel) throws IOExce
List<Revision> candidates = new ArrayList<Revision>();

for (Revision c : origCandidates) {
if (!isRevExcluded(git, c, listener)) {
if (!isRevExcluded(git, c, listener, buildData)) {
candidates.add(c);
}
}
Expand Down Expand Up @@ -1761,9 +1761,9 @@ public String getRelativeTargetDir() {
* @param listener
* @return true if any exclusion files are matched, false otherwise.
*/
private boolean isRevExcluded(IGitAPI git, Revision r, TaskListener listener) {
private boolean isRevExcluded(IGitAPI git, Revision r, TaskListener listener, BuildData buildData) {
try {
List<String> revShow = git.showRevision(r);
List<String> revShow = git.showRevision(r, buildData);

// If the revision info is empty, something went weird, so we'll just
// return false.
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/hudson/plugins/git/IGitAPI.java
Expand Up @@ -2,6 +2,7 @@

import hudson.EnvVars;
import hudson.model.TaskListener;
import hudson.plugins.git.util.BuildData;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -121,7 +122,7 @@ public interface IGitAPI {
ObjectId mergeBase(ObjectId sha1, ObjectId sha12);
String getAllLogEntries(String branch);

List<String> showRevision(Revision r) throws GitException;
List<String> showRevision(Revision r, BuildData buildData) throws GitException;
String getHeadRev(String remoteRepoUrl, String branch) throws GitException;

String getReference();
Expand Down

0 comments on commit 8e13991

Please sign in to comment.