Skip to content
Permalink
Browse files

added testcase for force push [JENKINS-24082]

  • Loading branch information
wannessels committed Sep 16, 2014
1 parent 79819f5 commit b14f6f4398c0ccfb88392dfda8baaf2ef9e3a2c8
Showing with 36 additions and 0 deletions.
  1. +36 −0 src/test/java/hudson/plugins/git/GitPublisherTest.java
@@ -39,7 +39,9 @@
import hudson.scm.NullSCM;
import hudson.tasks.BuildStepDescriptor;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.Issue;

import java.io.IOException;
import java.util.ArrayList;
@@ -132,6 +134,40 @@ public void testMergeAndPush() throws Exception {
assertEquals(sha1, testRepo.git.revParse(Constants.HEAD).name());

}

@Issue("JENKINS-24082")
public void testForcePush() throws Exception {
FreeStyleProject project = setupSimpleProject("master");

GitSCM scm = new GitSCM(
createRemoteRepositories(),
Collections.singletonList(new BranchSpec("*")),
false, Collections.<SubmoduleConfig>emptyList(),
null, null,
Collections.<GitSCMExtension>emptyList());
project.setScm(scm);

project.getPublishersList().add(new GitPublisher(
Collections.<TagToPush>emptyList(),
Collections.singletonList(new BranchToPush("origin", "otherbranch")),
Collections.<NoteToPush>emptyList(),
true, true, true));

commit("commitFile", johnDoe, "Initial Commit");

testRepo.git.branch("otherbranch");
testRepo.git.checkout("otherbranch");
commit("otherCommitFile", johnDoe, "commit lost on force push");

testRepo.git.checkout("master");
commit("commitFile2", johnDoe, "commit to be pushed");

ObjectId expectedCommit = testRepo.git.revParse("master");

build(project, Result.SUCCESS, "commitFile");

assertEquals(expectedCommit, testRepo.git.revParse("otherbranch"));
}

/**
* Fix push to remote when skipTag is enabled

0 comments on commit b14f6f4

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