当前位置: 首页>>代码示例>>Java>>正文


Java PushResult.getRemoteUpdates方法代码示例

本文整理汇总了Java中org.eclipse.jgit.transport.PushResult.getRemoteUpdates方法的典型用法代码示例。如果您正苦于以下问题:Java PushResult.getRemoteUpdates方法的具体用法?Java PushResult.getRemoteUpdates怎么用?Java PushResult.getRemoteUpdates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.transport.PushResult的用法示例。


在下文中一共展示了PushResult.getRemoteUpdates方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteRemoteBranch

import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
/**
 * Deletes a remote branch. Essentially a 'git push <remote> :<remote branch name>'
 *
 * @param branchHelper the remote branch to delete
 * @return the status of the push to remote to delete
 * @throws GitAPIException
 */
public RemoteRefUpdate.Status deleteRemoteBranch(RemoteBranchHelper branchHelper) throws GitAPIException, IOException {
    PushCommand pushCommand = new Git(this.repoHelper.repo).push();
    // We're deleting the branch on a remote, so there it shows up as refs/heads/<branchname>
    // instead of what it shows up on local: refs/<remote>/<branchname>, so we manually enter
    // this thing in here
    pushCommand.setRemote("origin").add(":refs/heads/"+branchHelper.parseBranchName());
    this.repoHelper.myWrapAuthentication(pushCommand);

    // Update the remote branches in case it worked
    updateRemoteBranches();

    boolean succeeded=false;
    for (PushResult result : pushCommand.call()) {
        for (RemoteRefUpdate refUpdate : result.getRemoteUpdates()) {
            return refUpdate.getStatus();
        }
    }
    return null;
}
 
开发者ID:dmusican,项目名称:Elegit,代码行数:27,代码来源:BranchModel.java

示例2: push

import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
/**
 * Pushes all the commits from the local repository to the remote repository
 * 
 * @param username
 *          - Git username
 * @param password
 *          - Git password
 *          
 * @throws GitAPIException
 * @throws TransportException
 * @throws InvalidRemoteException
 */
public PushResponse push(final String username, final String password)
    throws GitAPIException {

  AuthenticationInterceptor.install();
  PushResponse response = new PushResponse();

  RepositoryState repositoryState = git.getRepository().getRepositoryState();

  if (repositoryState == RepositoryState.MERGING) {
    response.setStatus(org.eclipse.jgit.transport.RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
    response.setMessage(translator.getTranslation(Tags.PUSH_WITH_CONFLICTS));
    return response;
  }
  if (getPullsBehind() > 0) {
    response.setStatus(org.eclipse.jgit.transport.RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
    response.setMessage(translator.getTranslation(Tags.BRANCH_BEHIND));
    return response;
  }
  String sshPassphrase = OptionsManager.getInstance().getSshPassphrase();
  Iterable<PushResult> call = git.push()
      .setCredentialsProvider(new SSHUserCredentialsProvider(username, password, sshPassphrase)).call();
  Iterator<PushResult> results = call.iterator();
  logger.debug("Push Ended");
  while (results.hasNext()) {
    PushResult result = results.next();
    for (RemoteRefUpdate info : result.getRemoteUpdates()) {
      response.setStatus(info.getStatus());
      return response;
    }
  }

  response.setStatus(org.eclipse.jgit.transport.RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
  response.setMessage(translator.getTranslation(Tags.PUSH_FAILED_UNKNOWN));
  return response;
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:48,代码来源:GitAccess.java

示例3: pushAndLogResult

import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
private void pushAndLogResult(final PushCommand pushCommand)
		throws GitAPIException, InvalidRemoteException, TransportException {
	for (final PushResult result : pushCommand.call()) {
		for (final RemoteRefUpdate upd : result.getRemoteUpdates()) {
			log.info(upd.toString());
		}
	}
}
 
开发者ID:SourcePond,项目名称:release-maven-plugin-parent,代码行数:9,代码来源:GitProposedTag.java

示例4: testAnonymousPush

import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
@Test
public void testAnonymousPush() throws Exception {
	GitBlitSuite.close(ticgitFolder);
	if (ticgitFolder.exists()) {
		FileUtils.delete(ticgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
	}

	// restore anonymous repository access
	RepositoryModel model = GitBlit.self().getRepositoryModel("ticgit.git");
	model.accessRestriction = AccessRestrictionType.NONE;
	model.authorizationControl = AuthorizationControl.NAMED;
	GitBlit.self().updateRepositoryModel(model.name, model, false);

	CloneCommand clone = Git.cloneRepository();
	clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
	clone.setDirectory(ticgitFolder);
	clone.setBare(false);
	clone.setCloneAllBranches(true);
	GitBlitSuite.close(clone.call());		
	assertTrue(true);
	
	Git git = Git.open(ticgitFolder);
	File file = new File(ticgitFolder, "TODO");
	OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET);
	BufferedWriter w = new BufferedWriter(os);
	w.write("// hellol中文 " + new Date().toString() + "\n");
	w.close();
	git.add().addFilepattern(file.getName()).call();
	git.commit().setMessage("test commit").call();
	Iterable<PushResult> results = git.push().setPushAll().call();
	GitBlitSuite.close(git);
	for (PushResult result : results) {
		for (RemoteRefUpdate update : result.getRemoteUpdates()) {
			assertEquals(Status.OK, update.getStatus());
		}
	}
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:38,代码来源:GitDaemonTest.java

示例5: testPushRestrictedRepo

import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
@Test
public void testPushRestrictedRepo() throws Exception {
	GitBlitSuite.close(ticgitFolder);
	if (ticgitFolder.exists()) {
		FileUtils.delete(ticgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
	}

	// restore anonymous repository access
	RepositoryModel model = GitBlit.self().getRepositoryModel("ticgit.git");
	model.accessRestriction = AccessRestrictionType.PUSH;
	model.authorizationControl = AuthorizationControl.NAMED;
	GitBlit.self().updateRepositoryModel(model.name, model, false);

	CloneCommand clone = Git.cloneRepository();
	clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
	clone.setDirectory(ticgitFolder);
	clone.setBare(false);
	clone.setCloneAllBranches(true);
	GitBlitSuite.close(clone.call());		
	assertTrue(true);
	
	Git git = Git.open(ticgitFolder);
	File file = new File(ticgitFolder, "TODO");
	OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET);
	BufferedWriter w = new BufferedWriter(os);
	w.write("// hellol中文 " + new Date().toString() + "\n");
	w.close();
	git.add().addFilepattern(file.getName()).call();
	git.commit().setMessage("test commit").call();
	Iterable<PushResult> results = git.push().setPushAll().call();
	GitBlitSuite.close(git);
	for (PushResult result : results) {
		for (RemoteRefUpdate update : result.getRemoteUpdates()) {
			assertEquals(Status.REJECTED_OTHER_REASON, update.getStatus());
		}
	}
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:38,代码来源:GitDaemonTest.java

示例6: testPushToNonBareRepository

import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
@Test
public void testPushToNonBareRepository() throws Exception {
	GitBlitSuite.close(jgit2Folder);
	if (jgit2Folder.exists()) {
		FileUtils.delete(jgit2Folder, FileUtils.RECURSIVE | FileUtils.RETRY);
	}
	
	CloneCommand clone = Git.cloneRepository();
	clone.setURI(MessageFormat.format("{0}/working/jgit", url));
	clone.setDirectory(jgit2Folder);
	clone.setBare(false);
	clone.setCloneAllBranches(true);
	GitBlitSuite.close(clone.call());
	assertTrue(true);

	Git git = Git.open(jgit2Folder);
	File file = new File(jgit2Folder, "NONBARE");
	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("test commit followed by push to non-bare repository").call();

	Iterable<PushResult> results = git.push().setPushAll().call();
	GitBlitSuite.close(git);
	
	for (PushResult result : results) {
		for (RemoteRefUpdate update : result.getRemoteUpdates()) {
			assertEquals(Status.REJECTED_OTHER_REASON, update.getStatus());
		}
	}
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:34,代码来源:GitDaemonTest.java

示例7: testAnonymousPush

import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
@Test
public void testAnonymousPush() throws Exception {
	GitBlitSuite.close(ticgitFolder);
	if (ticgitFolder.exists()) {
		FileUtils.delete(ticgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
	}

	RepositoryModel model = GitBlit.self().getRepositoryModel("ticgit.git");
	model.accessRestriction = AccessRestrictionType.NONE;
	GitBlit.self().updateRepositoryModel(model.name, model, false);

	CloneCommand clone = Git.cloneRepository();
	clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
	clone.setDirectory(ticgitFolder);
	clone.setBare(false);
	clone.setCloneAllBranches(true);
	clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password));
	GitBlitSuite.close(clone.call());		
	assertTrue(true);
	
	Git git = Git.open(ticgitFolder);
	File file = new File(ticgitFolder, "TODO");
	OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET);
	BufferedWriter w = new BufferedWriter(os);
	w.write("// hellol中文 " + new Date().toString() + "\n");
	w.close();
	git.add().addFilepattern(file.getName()).call();
	git.commit().setMessage("test commit").call();
	Iterable<PushResult> results = git.push().setPushAll().call();
	GitBlitSuite.close(git);
	for (PushResult result : results) {
		for (RemoteRefUpdate update : result.getRemoteUpdates()) {
			assertEquals(Status.OK, update.getStatus());
		}
	}
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:37,代码来源:GitServletTest.java

示例8: testSubfolderPush

import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
@Test
public void testSubfolderPush() throws Exception {
	GitBlitSuite.close(jgitFolder);
	if (jgitFolder.exists()) {
		FileUtils.delete(jgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
	}
	
	CloneCommand clone = Git.cloneRepository();
	clone.setURI(MessageFormat.format("{0}/test/jgit.git", url));
	clone.setDirectory(jgitFolder);
	clone.setBare(false);
	clone.setCloneAllBranches(true);
	clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password));
	GitBlitSuite.close(clone.call());
	assertTrue(true);

	Git git = Git.open(jgitFolder);
	File file = new File(jgitFolder, "TODO");
	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("test commit").call();
	Iterable<PushResult> results = git.push().setPushAll().setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password)).call();
	GitBlitSuite.close(git);
	for (PushResult result : results) {
		for (RemoteRefUpdate update : result.getRemoteUpdates()) {
			assertEquals(Status.OK, update.getStatus());
		}
	}
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:33,代码来源:GitServletTest.java

示例9: testPushToNonBareRepository

import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
@Test
public void testPushToNonBareRepository() throws Exception {
	CloneCommand clone = Git.cloneRepository();
	clone.setURI(MessageFormat.format("{0}/working/jgit", url));
	clone.setDirectory(jgit2Folder);
	clone.setBare(false);
	clone.setCloneAllBranches(true);
	clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password));
	GitBlitSuite.close(clone.call());
	assertTrue(true);

	Git git = Git.open(jgit2Folder);
	File file = new File(jgit2Folder, "NONBARE");
	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("test commit followed by push to non-bare repository").call();
	Iterable<PushResult> results = git.push().setPushAll().setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password)).call();
	GitBlitSuite.close(git);
	for (PushResult result : results) {
		for (RemoteRefUpdate update : result.getRemoteUpdates()) {
			assertEquals(Status.REJECTED_OTHER_REASON, update.getStatus());
		}
	}
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:28,代码来源:GitServletTest.java

示例10: 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;
   }
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:50,代码来源:JGitOperator.java

示例11: doInBackground

import org.eclipse.jgit.transport.PushResult; //导入方法依赖的package包/类
@Override
protected String doInBackground(GitCommand... commands) {
    Integer nbChanges = null;
    for (GitCommand command : commands) {
        Log.d("doInBackground", "Executing the command <" + command.toString() + ">");
        try {
            if (command instanceof StatusCommand) {
                // in case we have changes, we want to keep track of it
                org.eclipse.jgit.api.Status status = ((StatusCommand) command).call();
                nbChanges = status.getChanged().size() + status.getMissing().size();
            } else if (command instanceof CommitCommand) {
                // the previous status will eventually be used to avoid a commit
                if (nbChanges == null || nbChanges > 0)
                    command.call();
            }else if (command instanceof PushCommand) {
                for (final PushResult result : ((PushCommand) command).call()) {
                    // Code imported (modified) from Gerrit PushOp, license Apache v2
                    for (final RemoteRefUpdate rru : result.getRemoteUpdates()) {
                        switch (rru.getStatus()) {
                            case REJECTED_NONFASTFORWARD:
                                return activity.getString(R.string.git_push_nff_error);
                            case REJECTED_NODELETE:
                            case REJECTED_REMOTE_CHANGED:
                            case NON_EXISTING:
                            case NOT_ATTEMPTED:
                                return activity.getString(R.string.git_push_generic_error) + rru.getStatus().name();
                            case REJECTED_OTHER_REASON:
                                if ("non-fast-forward".equals(rru.getMessage())) {
                                    return activity.getString(R.string.git_push_other_error);
                                } else {
                                    return activity.getString(R.string.git_push_generic_error) + rru.getMessage();
                                }
                            default:
                                break;
                        }
                    }
                }
            } else {
                command.call();
            }

        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage() + "\nCaused by:\n" + e.getCause();
        }
    }
    return "";
}
 
开发者ID:zeapo,项目名称:Android-Password-Store,代码行数:49,代码来源:GitAsyncTask.java


注:本文中的org.eclipse.jgit.transport.PushResult.getRemoteUpdates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。