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


Java ResetCommand类代码示例

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


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

示例1: applyPatches

import org.eclipse.jgit.api.ResetCommand; //导入依赖的package包/类
public boolean applyPatches() throws Exception {
    git.reset().setMode(ResetCommand.ResetType.HARD).setRef(getSrcCommit().getName()).call();
    File[] patchFiles = patchDirectory.listFiles(((dir, name) -> name.endsWith(".patch"))
    ) != null ? patchDirectory.listFiles(((dir, name) -> name.endsWith(".patch"))) : new
            File[0];
    boolean allPatchesApplied = true;
    for (File patchFile : patchFiles) {
    	try {
    		git.apply().setPatch(new FileInputStream(patchFile)).call();
    	}catch(PatchApplyException e) {
    		allPatchesApplied = false;
    		System.out.println("Failed to apply patch "+patchFile.getName()+". " + e.getMessage());
    	}
    }
    return allPatchesApplied;
}
 
开发者ID:PizzaCrust,项目名称:IodineToolkit,代码行数:17,代码来源:PatchService.java

示例2: 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

示例3: update

import org.eclipse.jgit.api.ResetCommand; //导入依赖的package包/类
private void update(Git git) throws GitAPIException {
    PullResult pullResult = git.pull().setRebase(true).call();
    RebaseResult rebaseResult = pullResult.getRebaseResult();

    if(!pullResult.isSuccessful()) {
        if(rebaseResult.getStatus() == RebaseResult.Status.CONFLICTS) {
            logger.warn("Git `pull` reported conflicts - will reset and try again next pass!");
            git.reset().setMode(ResetCommand.ResetType.HARD).call();
            return;
        }

        logger.warn("Git `pull` was unsuccessful :(");
        return;
    }

    if(rebaseResult.getStatus() == RebaseResult.Status.UP_TO_DATE) {
        logger.debug("Git `pull` reported that repository is already up-to-date");
        return;
    }

    logger.debug("Git repo is now at commit '{}'", rebaseResult.getCurrentCommit());
}
 
开发者ID:AnomalyXII,项目名称:werewolv.es-tools,代码行数:23,代码来源:BotServiceConfiguration.java

示例4: pull

import org.eclipse.jgit.api.ResetCommand; //导入依赖的package包/类
public static void pull(Git repo, String ref) throws Exception
{
    System.out.println( "Pulling updates for " + repo.getRepository().getDirectory() );

    repo.reset().setRef( "origin/master" ).setMode( ResetCommand.ResetType.HARD ).call();
    repo.fetch().call();

    System.out.println( "Successfully fetched updates!" );

    if ( ref == null || ref.isEmpty()) ref = "master";
    repo.reset().setRef( ref ).setMode( ResetCommand.ResetType.HARD ).call();
    if ( ref.equals( "master" ) )
    {
        repo.reset().setRef( "origin/master" ).setMode( ResetCommand.ResetType.HARD ).call();
    }
    System.out.println( "Checked out: " + ref );
}
 
开发者ID:finalchild,项目名称:BuilderTools,代码行数:18,代码来源:Builder.java

示例5: getAdvancedResetMenu

import org.eclipse.jgit.api.ResetCommand; //导入依赖的package包/类
private Menu getAdvancedResetMenu(CommitHelper commit) {
    Menu resetMenu = new Menu("Advanced");
    MenuItem hardItem = new MenuItem("reset --hard");
    MenuItem mixedItem = new MenuItem("reset --mixed");
    MenuItem softItem = new MenuItem("reset --soft");

    hardItem.setOnAction(event ->
            CommitTreeController.sessionController.handleAdvancedResetButton(commit, ResetCommand.ResetType.HARD));
    mixedItem.setOnAction(event ->
            CommitTreeController.sessionController.handleAdvancedResetButton(commit, ResetCommand.ResetType.MIXED));
    softItem.setOnAction(event ->
            CommitTreeController.sessionController.handleAdvancedResetButton(commit, ResetCommand.ResetType.SOFT));

    resetMenu.getItems().setAll(hardItem, mixedItem, softItem);

    return resetMenu;
}
 
开发者ID:dmusican,项目名称:Elegit,代码行数:18,代码来源:CommitTreeModel.java

示例6: 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

示例7: 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

示例8: refreshRepo

import org.eclipse.jgit.api.ResetCommand; //导入依赖的package包/类
@Override
public void refreshRepo() throws RotationLoadException, IOException {
    try {
        if (git == null) {
            if (new File(getPath() + File.separator + ".git").exists())
                this.git = Git.open(new File(getPath()));
            else
                this.git = ((CloneCommand) addCredentials(
                        Git.cloneRepository().setURI(gitUrl.toString()).setDirectory(new File(getPath())))).call();
        }
        git.clean().call();
        addCredentials(git.fetch()).call();
        git.reset().setRef("@{upstream}").setMode(ResetCommand.ResetType.HARD).call();
    } catch (GitAPIException e) {
        e.printStackTrace();
        throw new RotationLoadException("Could not load git repository: " + gitUrl);
    }
    super.refreshRepo();
}
 
开发者ID:twizmwazin,项目名称:CardinalPGM,代码行数:20,代码来源:GitRepository.java

示例9: getAllVersions

import org.eclipse.jgit.api.ResetCommand; //导入依赖的package包/类
public static Stream<FileVersion> getAllVersions(final String dirName, final String fileNameStartWith, final Optional<String> realm) throws IOException, GitAPIException {
    final File dir = new File(GitHubPublisher.localPath + dirName + File.separator);
    final Git git = GitHubPublisher.getRepo();
    logger.info("git fetch");
    git.fetch().call();
    logger.info("git fetch finished");
    logger.info("git reset");
    git.reset().setMode(ResetCommand.ResetType.HARD).call();
    logger.info("git reset finished");
    logger.trace("dir = {}", dir.getAbsoluteFile());
    if (dir.listFiles() == null) {
        return Stream.empty();
    }

    final Stream<FileVersion> stream = Stream.of(dir.listFiles())
            .filter(File::isDirectory)
            .filter(realmDir -> !realm.isPresent() || realmDir.getName().equals(realm.get()))
            .map(File::listFiles)
            .flatMap(Stream::of)
            .filter(File::isFile)
            .filter(f -> f.getName().startsWith(fileNameStartWith))
            .map(file -> {
                try {
                    return GitHubPublisher.getAllVersions(git, dirName + "/" + realm.orElse(new File(file.getParent()).getName()) + "/" + file.getName());
                } catch (final Exception e) {
                    logger.error(e.getLocalizedMessage(), e);
                    return null;
                }
            })
            .filter(Objects::nonNull)
            .flatMap(Collection::stream)
            .parallel();
    logger.info("getAllVersions done");
    return stream;
}
 
开发者ID:cobr123,项目名称:VirtaMarketAnalyzer,代码行数:36,代码来源:RetailSalePrediction.java

示例10: reset

import org.eclipse.jgit.api.ResetCommand; //导入依赖的package包/类
/** Removes any staged changes that are not yet committed from a git repository. */
public Git reset(Path repositoryRoot) {
  try {
    FileRepositoryBuilder builder = new FileRepositoryBuilder();
    Repository repository = builder.setWorkTree(repositoryRoot.toFile()).build();
    Git git = new Git(repository);
    git.reset().setMode(ResetCommand.ResetType.HARD).call();
    return git;
  } catch (Exception e) {
    throw new IllegalStateException(
        String.format("error resetting local GIT repository at %s", repositoryRoot), e);
  }
}
 
开发者ID:reflectoring,项目名称:coderadar,代码行数:14,代码来源:GitRepositoryResetter.java

示例11: 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

示例12: 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

示例13: getChanges

import org.eclipse.jgit.api.ResetCommand; //导入依赖的package包/类
/**
 *
 * @throws GitAPIException
 * @throws IOException
 */
private List<DiffEntry> getChanges() throws GitAPIException, IOException {
  // get tree for last processed commit
  ObjectId oldHeadTree = git.getRepository().resolve(this.lastProcessedGitHash + "^{tree}");

  // refresh to latest and reset hard to handle forced pushes
  this.git.fetch().setRemote(REMOTE_NAME).call();
  // reset hard to get a clean working set since pull --rebase may leave files around
  this.git.reset().setMode(ResetCommand.ResetType.HARD).setRef(REMOTE_NAME + "/" + this.branchName).call();

  ObjectId head = this.git.getRepository().resolve("HEAD");
  ObjectId headTree = this.git.getRepository().resolve("HEAD^{tree}");

  // remember the hash for the current HEAD. This will be checkpointed after the diff is processed.
  latestGitHash = head.getName();

  // diff old and new heads to find changes
  ObjectReader reader = this.git.getRepository().newObjectReader();
  CanonicalTreeParser oldTreeIter = new CanonicalTreeParser();
  oldTreeIter.reset(reader, oldHeadTree);
  CanonicalTreeParser newTreeIter = new CanonicalTreeParser();
  newTreeIter.reset(reader, headTree);

  return this.git.diff()
      .setNewTree(newTreeIter)
      .setOldTree(oldTreeIter)
      .setShowNameAndStatusOnly(true)
      .call();
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:34,代码来源:GitConfigMonitor.java

示例14: 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

示例15: resetHard

import org.eclipse.jgit.api.ResetCommand; //导入依赖的package包/类
public void resetHard() throws IOException {
    Git git = new Git(getJGitRepository());
    try {
        git.reset().setMode(ResetCommand.ResetType.HARD).call();
    } catch (GitAPIException e) {
        throw new IOException(e);
    }
}
 
开发者ID:winstonli,项目名称:writelatex-git-bridge,代码行数:9,代码来源:GitProjectRepo.java


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