|
@@ -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