Add tests for force-updating a tag by push

Change-Id: I09b46a058252599a2ebd45ac09fe0a61fb732928
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2016-09-05 16:38:51 +02:00
parent 439dd1f98e
commit 0a41b9cb89
3 changed files with 92 additions and 10 deletions

View File

@@ -179,16 +179,27 @@ public class GitUtil {
public static PushResult pushHead(TestRepository<?> testRepo, String ref,
boolean pushTags, boolean force) throws GitAPIException {
return pushHead(testRepo, ref, pushTags, force, null);
return pushOne(testRepo, "HEAD", ref, pushTags, force, null);
}
public static PushResult pushHead(TestRepository<?> testRepo, String ref,
boolean pushTags, boolean force, List<String> pushOptions)
throws GitAPIException {
return pushOne(testRepo, "HEAD", ref, pushTags, force, pushOptions);
}
public static PushResult deleteRef(TestRepository<?> testRepo, String ref)
throws GitAPIException {
return pushOne(testRepo, "", ref, false, true, null);
}
public static PushResult pushOne(TestRepository<?> testRepo, String source,
String target, boolean pushTags, boolean force, List<String> pushOptions)
throws GitAPIException {
PushCommand pushCmd = testRepo.git().push();
pushCmd.setForce(force);
pushCmd.setPushOptions(pushOptions);
pushCmd.setRefSpecs(new RefSpec("HEAD:" + ref));
pushCmd.setRefSpecs(new RefSpec(source + ":" + target));
if (pushTags) {
pushCmd.setPushTags();
}