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


Java ResetCommand.call方法代码示例

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


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

示例1: resetAll

import org.eclipse.jgit.api.ResetCommand; //导入方法依赖的package包/类
/**
 * Reset all the specified files from the staging area.
 * 
 * @param fileNames
 *          - the list of file to be removed
 */
public void resetAll(List<FileStatus> files) {
	try {
		if (!files.isEmpty()) {
			ResetCommand reset = git.reset();
			for (FileStatus file : files) {
				reset.addPath(file.getFileLocation());

			}
			reset.call();
		}
		
     fireFileStateChanged(new ChangeEvent(GitCommand.UNSTAGE, getPaths(files)));
     
	} catch (GitAPIException e) {
		if (logger.isDebugEnabled()) {
			logger.debug(e, e);
		}
	}
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:26,代码来源:GitAccess.java

示例2: pullRepository

import org.eclipse.jgit.api.ResetCommand; //导入方法依赖的package包/类
public static void pullRepository() {
	try {
 	logger.info("Scanning devices folder for changes.");
 	git.add().addFilepattern(".").call();
 	Status status = git.status().call();
 	if (status.getChanged().size()>0 || status.getAdded().size()>0 || status.getModified().size()>0) {
 		logger.info("Changes have been found. Doing a hard reset (removing user modifications).");
 		ResetCommand reset = git.reset();
 		reset.setMode(ResetType.HARD);
 		reset.setRef(Constants.HEAD);
 		reset.call();
 	}
 	logger.info("Pulling changes from github.");
 	git.pull().call();
	} catch (NoHeadException e) {
		logger.info("Pull failed. Trying to clone repository instead");
		closeRepository();
		cloneRepository();
	}
	catch (Exception e1) {
		closeRepository();
	}
}
 
开发者ID:Androxyde,项目名称:Flashtool,代码行数:24,代码来源:DevicesGit.java

示例3: resetHard

import org.eclipse.jgit.api.ResetCommand; //导入方法依赖的package包/类
private Ref resetHard(Git git, String label, String ref) {
	ResetCommand reset = git.reset();
	reset.setRef(ref);
	reset.setMode(ResetType.HARD);
	try {
		Ref resetRef = reset.call();
		if (resetRef != null) {
			this.logger.info(
					"Reset label " + label + " to version " + resetRef.getObjectId());
		}
		return resetRef;
	}
	catch (Exception ex) {
		String message = "Could not reset to remote for " + label + " (current ref="
				+ ref + "), remote: " + git.getRepository().getConfig()
						.getString("remote", "origin", "url");
		warn(message, ex);
		return null;
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:21,代码来源:JGitEnvironmentRepository.java

示例4: reset

import org.eclipse.jgit.api.ResetCommand; //导入方法依赖的package包/类
@Override
public void reset(ResetParams params) throws GitException {
  try {
    ResetCommand resetCommand = getGit().reset();
    resetCommand.setRef(params.getCommit());
    List<String> patterns = params.getFilePattern();
    patterns.forEach(resetCommand::addPath);

    if (params.getType() != null && patterns.isEmpty()) {
      switch (params.getType()) {
        case HARD:
          resetCommand.setMode(ResetType.HARD);
          break;
        case KEEP:
          resetCommand.setMode(ResetType.KEEP);
          break;
        case MERGE:
          resetCommand.setMode(ResetType.MERGE);
          break;
        case MIXED:
          resetCommand.setMode(ResetType.MIXED);
          break;
        case SOFT:
          resetCommand.setMode(ResetType.SOFT);
          break;
      }
    }

    resetCommand.call();
  } catch (GitAPIException exception) {
    throw new GitException(exception.getMessage(), exception);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:34,代码来源:JGitConnection.java

示例5: reset

import org.eclipse.jgit.api.ResetCommand; //导入方法依赖的package包/类
public void reset(String refToResetTo) {
    
    ResetCommand command = _git.reset();
    command.setRef(refToResetTo);
    command.setMode(ResetType.HARD);
    try {
        command.call();
    } catch (Throwable e) {
        throw new RuntimeException(String.format("Failed to reset to [%s]", refToResetTo), e);
    }
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:12,代码来源:JGitOperator.java

示例6: resetHard

import org.eclipse.jgit.api.ResetCommand; //导入方法依赖的package包/类
Ref resetHard() {
    try {
        ResetCommand resetCmd = git.reset().setMode(ResetType.HARD);
        return resetCmd.call();
    } catch (GitAPIException ex) {
        throw new IllegalStateException("Cannot reset workspace", ex);
    }
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:9,代码来源:ProfileRegistry.java

示例7: testGitInit

import org.eclipse.jgit.api.ResetCommand; //导入方法依赖的package包/类
@Test
public void testGitInit() throws IOException, GitAPIException {
    String targetPath = getClass().getProtectionDomain().getCodeSource().getLocation().getFile() + "/..";
    System.setProperty(PLUMBER_GIT_URL.configKey(), "[email protected]:github/testrepo.git");
    System.setProperty(PLUMBER_GIT_PATH.configKey(), targetPath + "/junit-git-iaac");
    PlumberConfig.reload();
    System.clearProperty(PLUMBER_GIT_URL.configKey());
    System.clearProperty(PLUMBER_GIT_PATH.configKey());

    File gitFolder = new File(PlumberConfig.get(PLUMBER_GIT_PATH));
    if (gitFolder.exists() && gitFolder.isDirectory()) {
        FileUtils.deleteDirectory(gitFolder);
    }
    assertTrue(gitFolder.mkdirs());

    GitWorker gitWorker = new GitWorker(PlumberConfig.get(PLUMBER_GIT_URL), PlumberConfig.get(PLUMBER_GIT_PATH));
    gitWorker.init();

    gitWorker = new GitWorker(PlumberConfig.get(PLUMBER_GIT_URL), PlumberConfig.get(PLUMBER_GIT_PATH));
    gitWorker.init();

    Git git = gitWorker.getGit();
    assertNotNull(git);
    Iterator<RevCommit> log = git.log().call().iterator();
    assertTrue(log.hasNext());
    String latestRef = log.next().getName();
    assertTrue(log.hasNext());
    String previousRef = log.next().getName();
    assertNotEquals(latestRef, previousRef);

    ResetCommand resetCommand = git.reset();
    resetCommand.setMode(ResetCommand.ResetType.HARD);
    resetCommand.setRef("HEAD~1");
    resetCommand.call();
    assertTrue(git.log().call().iterator().hasNext());

    log = git.log().call().iterator();
    assertTrue(log.hasNext());
    String latestRefAfterRebase = log.next().getName();
    assertEquals(previousRef, latestRefAfterRebase);

    PullResult pullResult = gitWorker.pull();
    assertTrue(pullResult.isSuccessful());
    assertEquals(MergeResult.MergeStatus.FAST_FORWARD, pullResult.getMergeResult().getMergeStatus());

    log = git.log().call().iterator();
    assertTrue(log.hasNext());
    String latestRefAfterRePull = log.next().getName();
    assertEquals(latestRef, latestRefAfterRePull);

    if (gitFolder.exists() && gitFolder.isDirectory()) {
        FileUtils.deleteDirectory(gitFolder);
    }
}
 
开发者ID:plumber-cd,项目名称:plumber,代码行数:55,代码来源:BasicGitTest.java


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