Skip to content
Permalink
Browse files

JENKINS-25960: Fixed tests due testutils change

  • Loading branch information...
buep committed Dec 11, 2014
1 parent 6e27a1e commit 64208a4f0303ced609e075233eb804b6e7fc7575
@@ -7,8 +7,10 @@

import hudson.model.AbstractBuild;
import hudson.model.Result;
import java.io.File;
import java.util.Iterator;
import static junit.framework.TestCase.assertTrue;
import org.apache.commons.io.FileUtils;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
@@ -95,17 +97,27 @@ private void validateResult() throws ValidationException {
}
}

private boolean validateHeadCommitMessage() throws ValidationException,Exception {
Git git = new Git(repo);
private boolean validateHeadCommitMessage() throws ValidationException, Exception {

File workDirForRepo = new File("work-" + repo.getDirectory().getPath().replace(".git",""));
Git.cloneRepository().setURI("file:///"+repo.getDirectory().getAbsolutePath()).setDirectory(workDirForRepo)
.setBare(false)
.setCloneAllBranches(true)
.setNoCheckout(false)
.call().close();

Git git = Git.open(workDirForRepo);

git.checkout().setName("master").call();
RevWalk walk = new RevWalk(repo);

Iterable<RevCommit> logs = git.log().call();
Iterator<RevCommit> i = logs.iterator();

ObjectId head = repo.resolve("HEAD");


Boolean validated = false;
String errorMessage = "No head commit found";
RevCommit commit = null;
while(i.hasNext()) {
commit = walk.parseCommit(i.next());
@@ -119,14 +131,27 @@ private boolean validateHeadCommitMessage() throws ValidationException,Exception
}

if(!(matched && match)) {
throw new ValidationException("The head commit did not match any of the strings specified");
validated = false;
errorMessage = "The head commit did not match any of the strings specified";
break;
//throw new ValidationException("The head commit did not match any of the strings specified");
} else {
return true;
//return true;
validated = true;

}

}
}
throw new ValidationException("No head commit found");
//throw new ValidationException("No head commit found");
git.close();
FileUtils.deleteDirectory(workDirForRepo);
if (!validated) {
throw new ValidationException(errorMessage);
}
else {
return validated;
}
}

@Override

0 comments on commit 64208a4

Please sign in to comment.
You can’t perform that action at this time.