本文整理汇总了Java中org.eclipse.jgit.transport.PushResult.getRemoteUpdate方法的典型用法代码示例。如果您正苦于以下问题:Java PushResult.getRemoteUpdate方法的具体用法?Java PushResult.getRemoteUpdate怎么用?Java PushResult.getRemoteUpdate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.transport.PushResult
的用法示例。
在下文中一共展示了PushResult.getRemoteUpdate方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mergedOptionWithNewCommitWithSameChangeIdFails
import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
@Test
public void mergedOptionWithNewCommitWithSameChangeIdFails() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master");
r.assertOkStatus();
gApi.changes().id(r.getChangeId()).current().review(ReviewInput.approve());
gApi.changes().id(r.getChangeId()).current().submit();
RevCommit c2 =
testRepo
.amend(r.getCommit())
.message("New subject")
.insertChangeId(r.getChangeId().substring(1))
.create();
testRepo.reset(c2);
String ref = "refs/for/master%merged";
PushResult pr = pushHead(testRepo, ref, false);
RemoteRefUpdate rru = pr.getRemoteUpdate(ref);
assertThat(rru.getStatus()).isEqualTo(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
assertThat(rru.getMessage()).contains("not merged into branch");
}
示例2: cannotDeleteUserBranch
import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
@Test
@Sandboxed
public void cannotDeleteUserBranch() throws Exception {
grant(
allUsers,
RefNames.REFS_USERS + "${" + RefPattern.USERID_SHARDED + "}",
Permission.DELETE,
true,
REGISTERED_USERS);
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
String userRef = RefNames.refsUsers(admin.id);
PushResult r = deleteRef(allUsersRepo, userRef);
RemoteRefUpdate refUpdate = r.getRemoteUpdate(userRef);
assertThat(refUpdate.getStatus()).isEqualTo(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
assertThat(refUpdate.getMessage()).contains("Not allowed to delete user branch.");
try (Repository repo = repoManager.openRepository(allUsers)) {
assertThat(repo.exactRef(userRef)).isNotNull();
}
}
示例3: deleteUserBranchWithAccessDatabaseCapability
import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
@Test
@Sandboxed
public void deleteUserBranchWithAccessDatabaseCapability() throws Exception {
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
grant(
allUsers,
RefNames.REFS_USERS + "${" + RefPattern.USERID_SHARDED + "}",
Permission.DELETE,
true,
REGISTERED_USERS);
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
String userRef = RefNames.refsUsers(admin.id);
PushResult r = deleteRef(allUsersRepo, userRef);
RemoteRefUpdate refUpdate = r.getRemoteUpdate(userRef);
assertThat(refUpdate.getStatus()).isEqualTo(RemoteRefUpdate.Status.OK);
try (Repository repo = repoManager.openRepository(allUsers)) {
assertThat(repo.exactRef(userRef)).isNull();
}
assertThat(accountCache.getOrNull(admin.id)).isNull();
assertThat(accountQueryProvider.get().byDefault(admin.id.toString())).isEmpty();
}
示例4: cannotDeleteGroupBranch
import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
@Test
@Sandboxed
public void cannotDeleteGroupBranch() throws Exception {
assume().that(groupsInNoteDb()).isTrue();
grant(allUsers, RefNames.REFS_GROUPS + "*", Permission.DELETE, true, REGISTERED_USERS);
InternalGroup adminGroup =
groupCache.get(new AccountGroup.NameKey("Administrators")).orElse(null);
assertThat(adminGroup).isNotNull();
String groupRef = RefNames.refsGroups(adminGroup.getGroupUUID());
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
PushResult r = deleteRef(allUsersRepo, groupRef);
RemoteRefUpdate refUpdate = r.getRemoteUpdate(groupRef);
assertThat(refUpdate.getStatus()).isEqualTo(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
assertThat(refUpdate.getMessage()).contains("Not allowed to delete group branch.");
try (Repository repo = repoManager.openRepository(allUsers)) {
assertThat(repo.exactRef(groupRef)).isNotNull();
}
}
示例5: assertPushRejected
import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
public static void assertPushRejected(PushResult result, String ref, String expectedMessage) {
RemoteRefUpdate rru = result.getRemoteUpdate(ref);
assertThat(rru.getStatus())
.named(rru.toString())
.isEqualTo(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
assertThat(rru.getMessage()).isEqualTo(expectedMessage);
}
示例6: mergedOptionFailsWhenChangeExists
import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
@Test
public void mergedOptionFailsWhenChangeExists() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master");
r.assertOkStatus();
gApi.changes().id(r.getChangeId()).current().review(ReviewInput.approve());
gApi.changes().id(r.getChangeId()).current().submit();
testRepo.reset(r.getCommit());
String ref = "refs/for/master%merged";
PushResult pr = pushHead(testRepo, ref, false);
RemoteRefUpdate rru = pr.getRemoteUpdate(ref);
assertThat(rru.getStatus()).isEqualTo(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
assertThat(rru.getMessage()).contains("no new changes");
}
示例7: pushForReview
import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
private static void pushForReview(
TestRepository<?> testRepo, RemoteRefUpdate.Status expectedStatus, String expectedMessage)
throws GitAPIException {
String ref = "refs/for/master";
PushResult r = pushHead(testRepo, ref);
RemoteRefUpdate refUpdate = r.getRemoteUpdate(ref);
assertThat(refUpdate.getStatus()).isEqualTo(expectedStatus);
if (expectedMessage != null) {
assertThat(refUpdate.getMessage()).contains(expectedMessage);
}
}
示例8: assertDeleteRef
import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
private void assertDeleteRef(RemoteRefUpdate.Status expectedStatus) throws Exception {
BranchInput in = new BranchInput();
in.ref = "refs/heads/test";
gApi.projects().name(project.get()).branch(in.ref).create(in);
PushResult result = deleteRef(testRepo, in.ref);
RemoteRefUpdate refUpdate = result.getRemoteUpdate(in.ref);
assertThat(refUpdate.getStatus()).isEqualTo(expectedStatus);
}
示例9: pushTag
import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
private String pushTag(String tagName, boolean newCommit, boolean force, Status expectedStatus)
throws Exception {
if (force) {
testRepo.reset(initialHead);
}
commit(user.getIdent(), "subject");
boolean createTag = tagName == null;
tagName = MoreObjects.firstNonNull(tagName, "v1_" + System.nanoTime());
switch (tagType) {
case LIGHTWEIGHT:
break;
case ANNOTATED:
if (createTag) {
createAnnotatedTag(testRepo, tagName, user.getIdent());
} else {
updateAnnotatedTag(testRepo, tagName, user.getIdent());
}
break;
default:
throw new IllegalStateException("unexpected tag type: " + tagType);
}
if (!newCommit) {
grant(project, "refs/for/refs/heads/master", Permission.SUBMIT, false, REGISTERED_USERS);
pushHead(testRepo, "refs/for/master%submit");
}
String tagRef = tagRef(tagName);
PushResult r =
tagType == LIGHTWEIGHT
? pushHead(testRepo, tagRef, false, force)
: GitUtil.pushTag(testRepo, tagName, !createTag);
RemoteRefUpdate refUpdate = r.getRemoteUpdate(tagRef);
assertThat(refUpdate.getStatus()).named(tagType.name()).isEqualTo(expectedStatus);
return tagName;
}
示例10: assertPushOk
import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
public static void assertPushOk(PushResult result, String ref) {
RemoteRefUpdate rru = result.getRemoteUpdate(ref);
assertThat(rru.getStatus()).named(rru.toString()).isEqualTo(RemoteRefUpdate.Status.OK);
}
示例11: pushTagDeletion
import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
private void pushTagDeletion(String tagName, Status expectedStatus) throws Exception {
String tagRef = tagRef(tagName);
PushResult r = deleteRef(testRepo, tagRef);
RemoteRefUpdate refUpdate = r.getRemoteUpdate(tagRef);
assertThat(refUpdate.getStatus()).named(tagType.name()).isEqualTo(expectedStatus);
}
示例12: push
import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
@Override
public boolean push(String sourceBranch, String destinationBranch) {
PushCommand command = _git.push();
boolean ret = true;
RefSpec refSpec = new RefSpec().setSourceDestination(sourceBranch, destinationBranch);
command.setRefSpecs(refSpec);
try {
List<Ref> remoteBranches = _git.branchList().setListMode(ListMode.REMOTE).call();
Iterable<PushResult> results = command.call();
for (PushResult pushResult : results) {
Collection<RemoteRefUpdate> resultsCollection = pushResult.getRemoteUpdates();
Map<PushResult,RemoteRefUpdate> resultsMap = new HashMap<>();
for(RemoteRefUpdate remoteRefUpdate : resultsCollection)
{
resultsMap.put(pushResult, remoteRefUpdate);
}
RemoteRefUpdate remoteUpdate = pushResult.getRemoteUpdate(destinationBranch);
if (remoteUpdate != null) {
org.eclipse.jgit.transport.RemoteRefUpdate.Status status =
remoteUpdate.getStatus();
ret =
status.equals(org.eclipse.jgit.transport.RemoteRefUpdate.Status.OK)
|| status.equals(org.eclipse.jgit.transport.RemoteRefUpdate.Status.UP_TO_DATE);
}
if(remoteUpdate == null && !remoteBranches.toString().contains(destinationBranch))
{
for(RemoteRefUpdate resultValue : resultsMap.values())
{
if(resultValue.toString().contains("REJECTED_OTHER_REASON"))
{
ret = false;
}
}
}
}
} catch (Throwable e) {
throw new RuntimeException(String.format(
"Failed to push [%s] into [%s]",
sourceBranch,
destinationBranch), e);
}
return ret;
}
示例13: testCommitterVerification
import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
private void testCommitterVerification(UserModel user, String displayName, String emailAddress, boolean expectedSuccess) throws Exception {
if (GitBlit.self().getUserModel(user.username) != null) {
GitBlit.self().deleteUser(user.username);
}
CredentialsProvider cp = new UsernamePasswordCredentialsProvider(user.username, user.password);
// fork from original to a temporary bare repo
File verification = new File(GitBlitSuite.REPOSITORIES, "refchecks/verify-committer.git");
if (verification.exists()) {
FileUtils.delete(verification, FileUtils.RECURSIVE);
}
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
clone.setDirectory(verification);
clone.setBare(true);
clone.setCloneAllBranches(true);
clone.setCredentialsProvider(cp);
GitBlitSuite.close(clone.call());
// require push permissions and committer verification
RepositoryModel model = GitBlit.self().getRepositoryModel("refchecks/verify-committer.git");
model.authorizationControl = AuthorizationControl.NAMED;
model.accessRestriction = AccessRestrictionType.PUSH;
model.verifyCommitter = true;
// grant user push permission
user.setRepositoryPermission(model.name, AccessPermission.PUSH);
GitBlit.self().updateUserModel(user.username, user, true);
GitBlit.self().updateRepositoryModel(model.name, model, false);
// clone temp bare repo to working copy
File local = new File(GitBlitSuite.REPOSITORIES, "refchecks/verify-wc");
if (local.exists()) {
FileUtils.delete(local, FileUtils.RECURSIVE);
}
clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/{1}", url, model.name));
clone.setDirectory(local);
clone.setBare(false);
clone.setCloneAllBranches(true);
clone.setCredentialsProvider(cp);
GitBlitSuite.close(clone.call());
Git git = Git.open(local);
// force an identity which may or may not match the account's identity
git.getRepository().getConfig().setString("user", null, "name", displayName);
git.getRepository().getConfig().setString("user", null, "email", emailAddress);
git.getRepository().getConfig().save();
// commit a file and push it
File file = new File(local, "PUSHCHK");
OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET);
BufferedWriter w = new BufferedWriter(os);
w.write("// " + new Date().toString() + "\n");
w.close();
git.add().addFilepattern(file.getName()).call();
git.commit().setMessage("push test").call();
Iterable<PushResult> results = git.push().setCredentialsProvider(cp).setRemote("origin").call();
for (PushResult result : results) {
RemoteRefUpdate ref = result.getRemoteUpdate("refs/heads/master");
Status status = ref.getStatus();
if (expectedSuccess) {
assertTrue("Verification failed! User was NOT able to push commit! " + status.name(), Status.OK.equals(status));
} else {
assertTrue("Verification failed! User was able to push commit! " + status.name(), Status.REJECTED_OTHER_REASON.equals(status));
}
}
GitBlitSuite.close(git);
// close serving repository
GitBlitSuite.close(verification);
}