本文整理汇总了Java中org.eclipse.jgit.transport.RemoteRefUpdate类的典型用法代码示例。如果您正苦于以下问题:Java RemoteRefUpdate类的具体用法?Java RemoteRefUpdate怎么用?Java RemoteRefUpdate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RemoteRefUpdate类属于org.eclipse.jgit.transport包,在下文中一共展示了RemoteRefUpdate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldShowSuccessWhenPushSucceeds
import org.eclipse.jgit.transport.RemoteRefUpdate; //导入依赖的package包/类
@Test
public void shouldShowSuccessWhenPushSucceeds() throws Exception {
XulMessageBox message = spy( new XulMessageBoxMock( XulDialogCallback.Status.ACCEPT ) );
when( document.createElement( MESSAGEBOX ) ).thenReturn( message );
doReturn( true ).when( uiGit ).hasRemote();
PushResult result = mock( PushResult.class );
doReturn( new URIish( "https://test.example.com" ) ).when( result ).getURI();
RemoteRefUpdate update = mock( RemoteRefUpdate.class );
when( update.getStatus() ).thenReturn( Status.OK );
when( result.getRemoteUpdates() ).thenReturn( Arrays.asList( update ) );
controller.push();
controller.push( IVCS.TYPE_BRANCH );
verify( uiGit ).push( "default" );
verify( uiGit ).push( IVCS.TYPE_BRANCH );
}
示例2: processPushResult
import org.eclipse.jgit.transport.RemoteRefUpdate; //导入依赖的package包/类
private void processPushResult( Iterable<PushResult> resultIterable ) throws Exception {
resultIterable.forEach( result -> { // for each (push)url
StringBuilder sb = new StringBuilder();
result.getRemoteUpdates().stream()
.filter( update -> update.getStatus() != RemoteRefUpdate.Status.OK )
.filter( update -> update.getStatus() != RemoteRefUpdate.Status.UP_TO_DATE )
.forEach( update -> { // for each failed refspec
sb.append(
result.getURI().toString()
+ "\n" + update.getSrcRef().toString()
+ "\n" + update.getStatus().toString()
+ ( update.getMessage() == null ? "" : "\n" + update.getMessage() )
+ "\n\n"
);
} );
if ( sb.length() == 0 ) {
showMessageBox( BaseMessages.getString( PKG, "Dialog.Success" ), BaseMessages.getString( PKG, "Dialog.Success" ) );
} else {
showMessageBox( BaseMessages.getString( PKG, "Dialog.Error" ), sb.toString() );
}
} );
}
示例3: pushVia
import org.eclipse.jgit.transport.RemoteRefUpdate; //导入依赖的package包/类
private PushResult pushVia(Transport tn)
throws IOException, NotSupportedException, TransportException, PermissionBackendException {
tn.applyConfig(config);
tn.setCredentialsProvider(credentialsProvider);
List<RemoteRefUpdate> todo = generateUpdates(tn);
if (todo.isEmpty()) {
// If we have no commands selected, we have nothing to do.
// Calling JGit at this point would just redo the work we
// already did, and come up with the same answer. Instead
// send back an empty result.
return new PushResult();
}
repLog.info("Push to " + uri + " references: " + todo);
return tn.push(NullProgressMonitor.INSTANCE, todo);
}
示例4: doPushDelta
import org.eclipse.jgit.transport.RemoteRefUpdate; //导入依赖的package包/类
private List<RemoteRefUpdate> doPushDelta(Map<String, Ref> local) throws IOException {
List<RemoteRefUpdate> cmds = new ArrayList<>();
boolean noPerms = !pool.isReplicatePermissions();
for (String src : delta) {
RefSpec spec = matchSrc(src);
if (spec != null) {
// If the ref still exists locally, send it, otherwise delete it.
Ref srcRef = local.get(src);
// Second try to ensure that the ref is truly not found locally
if (srcRef == null) {
srcRef = git.exactRef(src);
}
if (srcRef != null && canPushRef(src, noPerms)) {
push(cmds, spec, srcRef);
} else if (config.isMirror()) {
delete(cmds, spec);
}
}
}
return cmds;
}
示例5: shouldFireEventsForReplicationOfOneRefToOneNode
import org.eclipse.jgit.transport.RemoteRefUpdate; //导入依赖的package包/类
@Test
public void shouldFireEventsForReplicationOfOneRefToOneNode() throws URISyntaxException {
resetToDefault(pushResultProcessingMock);
URIish uri = new URIish("git://someHost/someRepo.git");
//expected events
pushResultProcessingMock.onRefReplicatedToOneNode(
"someProject", "someRef", uri, RefPushResult.SUCCEEDED, RemoteRefUpdate.Status.OK);
pushResultProcessingMock.onRefReplicatedToAllNodes("someProject", "someRef", 1);
pushResultProcessingMock.onAllRefsReplicatedToAllNodes(1);
replay(pushResultProcessingMock);
//actual test
replicationState.increasePushTaskCount("someProject", "someRef");
replicationState.markAllPushTasksScheduled();
replicationState.notifyRefReplicated(
"someProject", "someRef", uri, RefPushResult.SUCCEEDED, RemoteRefUpdate.Status.OK);
verify(pushResultProcessingMock);
}
示例6: shouldFireEventsForReplicationOfOneRefToMultipleNodes
import org.eclipse.jgit.transport.RemoteRefUpdate; //导入依赖的package包/类
@Test
public void shouldFireEventsForReplicationOfOneRefToMultipleNodes() throws URISyntaxException {
resetToDefault(pushResultProcessingMock);
URIish uri1 = new URIish("git://someHost1/someRepo.git");
URIish uri2 = new URIish("git://someHost2/someRepo.git");
//expected events
pushResultProcessingMock.onRefReplicatedToOneNode(
"someProject", "someRef", uri1, RefPushResult.SUCCEEDED, RemoteRefUpdate.Status.OK);
pushResultProcessingMock.onRefReplicatedToOneNode(
"someProject", "someRef", uri2, RefPushResult.FAILED, RemoteRefUpdate.Status.NON_EXISTING);
pushResultProcessingMock.onRefReplicatedToAllNodes("someProject", "someRef", 2);
pushResultProcessingMock.onAllRefsReplicatedToAllNodes(2);
replay(pushResultProcessingMock);
//actual test
replicationState.increasePushTaskCount("someProject", "someRef");
replicationState.increasePushTaskCount("someProject", "someRef");
replicationState.markAllPushTasksScheduled();
replicationState.notifyRefReplicated(
"someProject", "someRef", uri1, RefPushResult.SUCCEEDED, RemoteRefUpdate.Status.OK);
replicationState.notifyRefReplicated(
"someProject", "someRef", uri2, RefPushResult.FAILED, RemoteRefUpdate.Status.NON_EXISTING);
verify(pushResultProcessingMock);
}
示例7: shouldFireEventsForReplicationSameRefDifferentProjects
import org.eclipse.jgit.transport.RemoteRefUpdate; //导入依赖的package包/类
@Test
public void shouldFireEventsForReplicationSameRefDifferentProjects() throws URISyntaxException {
resetToDefault(pushResultProcessingMock);
URIish uri = new URIish("git://host1/someRepo.git");
//expected events
pushResultProcessingMock.onRefReplicatedToOneNode(
"project1", "ref1", uri, RefPushResult.SUCCEEDED, RemoteRefUpdate.Status.OK);
pushResultProcessingMock.onRefReplicatedToOneNode(
"project2", "ref2", uri, RefPushResult.SUCCEEDED, RemoteRefUpdate.Status.OK);
pushResultProcessingMock.onRefReplicatedToAllNodes("project1", "ref1", 1);
pushResultProcessingMock.onRefReplicatedToAllNodes("project2", "ref2", 1);
pushResultProcessingMock.onAllRefsReplicatedToAllNodes(2);
replay(pushResultProcessingMock);
//actual test
replicationState.increasePushTaskCount("project1", "ref1");
replicationState.increasePushTaskCount("project2", "ref2");
replicationState.markAllPushTasksScheduled();
replicationState.notifyRefReplicated(
"project1", "ref1", uri, RefPushResult.SUCCEEDED, RemoteRefUpdate.Status.OK);
replicationState.notifyRefReplicated(
"project2", "ref2", uri, RefPushResult.SUCCEEDED, RemoteRefUpdate.Status.OK);
verify(pushResultProcessingMock);
}
示例8: shouldFireEventsWhenSomeReplicationCompleteBeforeAllTasksAreScheduled
import org.eclipse.jgit.transport.RemoteRefUpdate; //导入依赖的package包/类
@Test
public void shouldFireEventsWhenSomeReplicationCompleteBeforeAllTasksAreScheduled()
throws URISyntaxException {
resetToDefault(pushResultProcessingMock);
URIish uri1 = new URIish("git://host1/someRepo.git");
//expected events
pushResultProcessingMock.onRefReplicatedToOneNode(
"someProject", "ref1", uri1, RefPushResult.SUCCEEDED, RemoteRefUpdate.Status.OK);
pushResultProcessingMock.onRefReplicatedToOneNode(
"someProject", "ref2", uri1, RefPushResult.SUCCEEDED, RemoteRefUpdate.Status.OK);
pushResultProcessingMock.onRefReplicatedToAllNodes("someProject", "ref1", 1);
pushResultProcessingMock.onRefReplicatedToAllNodes("someProject", "ref2", 1);
pushResultProcessingMock.onAllRefsReplicatedToAllNodes(2);
replay(pushResultProcessingMock);
//actual test
replicationState.increasePushTaskCount("someProject", "ref1");
replicationState.increasePushTaskCount("someProject", "ref2");
replicationState.notifyRefReplicated(
"someProject", "ref1", uri1, RefPushResult.SUCCEEDED, RemoteRefUpdate.Status.OK);
replicationState.notifyRefReplicated(
"someProject", "ref2", uri1, RefPushResult.SUCCEEDED, RemoteRefUpdate.Status.OK);
replicationState.markAllPushTasksScheduled();
verify(pushResultProcessingMock);
}
示例9: headRefReplicated
import org.eclipse.jgit.transport.RemoteRefUpdate; //导入依赖的package包/类
@Test
public void headRefReplicated()
throws URISyntaxException, OrmException, PermissionBackendException {
reset(dispatcherMock);
RefReplicatedEvent expectedEvent =
new RefReplicatedEvent(
"someProject",
"refs/heads/master",
"someHost",
RefPushResult.SUCCEEDED,
RemoteRefUpdate.Status.OK);
dispatcherMock.postEvent(RefReplicatedEventEquals.eqEvent(expectedEvent));
expectLastCall().once();
replay(dispatcherMock);
gitUpdateProcessing.onRefReplicatedToOneNode(
"someProject",
"refs/heads/master",
new URIish("git://someHost/someProject.git"),
RefPushResult.SUCCEEDED,
RemoteRefUpdate.Status.OK);
verify(dispatcherMock);
}
示例10: changeRefReplicated
import org.eclipse.jgit.transport.RemoteRefUpdate; //导入依赖的package包/类
@Test
public void changeRefReplicated()
throws URISyntaxException, OrmException, PermissionBackendException {
reset(dispatcherMock);
RefReplicatedEvent expectedEvent =
new RefReplicatedEvent(
"someProject",
"refs/changes/01/1/1",
"someHost",
RefPushResult.FAILED,
RemoteRefUpdate.Status.REJECTED_NONFASTFORWARD);
dispatcherMock.postEvent(RefReplicatedEventEquals.eqEvent(expectedEvent));
expectLastCall().once();
replay(dispatcherMock);
gitUpdateProcessing.onRefReplicatedToOneNode(
"someProject",
"refs/changes/01/1/1",
new URIish("git://someHost/someProject.git"),
RefPushResult.FAILED,
RemoteRefUpdate.Status.REJECTED_NONFASTFORWARD);
verify(dispatcherMock);
}
示例11: mergedOptionWithNewCommitWithSameChangeIdFails
import org.eclipse.jgit.transport.RemoteRefUpdate; //导入依赖的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");
}
示例12: allowedButNotSubscribed
import org.eclipse.jgit.transport.RemoteRefUpdate; //导入依赖的package包/类
@Test
public void allowedButNotSubscribed() throws Exception {
TestRepository<?> superRepo = createProjectWithPush("super-project");
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
allowMatchingSubmoduleSubscription(
"subscribed-to-project", "refs/heads/master", "super-project", "refs/heads/master");
pushChangeTo(subRepo, "master");
subRepo
.branch("HEAD")
.commit()
.insertChangeId()
.message("some change")
.add("b.txt", "b contents for testing")
.create();
String refspec = "HEAD:refs/heads/master";
PushResult r =
Iterables.getOnlyElement(
subRepo.git().push().setRemote("origin").setRefSpecs(new RefSpec(refspec)).call());
assertThat(r.getMessages()).doesNotContain("error");
assertThat(r.getRemoteUpdate("refs/heads/master").getStatus())
.isEqualTo(RemoteRefUpdate.Status.OK);
assertThat(hasSubmodule(superRepo, "master", "subscribed-to-project")).isFalse();
}
示例13: pushChangeTo
import org.eclipse.jgit.transport.RemoteRefUpdate; //导入依赖的package包/类
protected ObjectId pushChangeTo(
TestRepository<?> repo, String ref, String file, String content, String message, String topic)
throws Exception {
ObjectId ret =
repo.branch("HEAD").commit().insertChangeId().message(message).add(file, content).create();
String pushedRef = ref;
if (!topic.isEmpty()) {
pushedRef += "/" + name(topic);
}
String refspec = "HEAD:" + pushedRef;
Iterable<PushResult> res =
repo.git().push().setRemote("origin").setRefSpecs(new RefSpec(refspec)).call();
RemoteRefUpdate u = Iterables.getOnlyElement(res).getRemoteUpdate(pushedRef);
assertThat(u).isNotNull();
assertThat(u.getStatus()).isEqualTo(Status.OK);
assertThat(u.getNewObjectId()).isEqualTo(ret);
return ret;
}
示例14: cannotDeleteUserBranch
import org.eclipse.jgit.transport.RemoteRefUpdate; //导入依赖的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();
}
}
示例15: deleteUserBranchWithAccessDatabaseCapability
import org.eclipse.jgit.transport.RemoteRefUpdate; //导入依赖的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();
}