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


Java ResetType类代码示例

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


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

示例1: reset

import org.eclipse.jgit.api.ResetCommand.ResetType; //导入依赖的package包/类
public void reset(final int noOfCommitsToRevert, final String message) {
    final Repository repository = getRepository();
    final RevCommit commit = findCommit(Constants.HEAD
            + REVISION_STRING_DELIMITER + noOfCommitsToRevert, repository);
    if (commit == null) {
        return;
    }

    try {
        final Git git = new Git(repository);
        git.reset().setRef(commit.getName()).setMode(ResetType.HARD).call();
        // Commit changes
        commitAllChanges(message);
        LOGGER.info("Reset of last " + (noOfCommitsToRevert + 1)
                + " successful.");
    }
    catch (final Exception e) {
        throw new IllegalStateException("Reset did not succeed.", e);
    }
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:21,代码来源:GitOperationsImpl.java

示例2: cherryPickCommitToBranch

import org.eclipse.jgit.api.ResetCommand.ResetType; //导入依赖的package包/类
private void cherryPickCommitToBranch(ObjectId id, Project project, Branch branch) {

		doWithGit(project, git -> {

			try {
				checkout(project, branch);
			} catch (RuntimeException o_O) {

				logger.log(project, "Couldn't check out branch %s. Skipping cherrypick of commit %s.", branch, id.getName());
				return;
			}

			logger.log(project, "git cp %s", id.getName());
			CherryPickResult result = git.cherryPick().include(id).call();

			if (result.getStatus().equals(CherryPickStatus.OK)) {
				logger.log(project, "Successfully cherry-picked commit %s to branch %s.", id.getName(), branch);
			} else {
				logger.warn(project, "Cherry pick failed. aborting…");
				logger.log(project, "git reset --hard");
				git.reset().setMode(ResetType.HARD).call();
			}
		});
	}
 
开发者ID:spring-projects,项目名称:spring-data-dev-tools,代码行数:25,代码来源:GitOperations.java

示例3: buttonPressed

import org.eclipse.jgit.api.ResetCommand.ResetType; //导入依赖的package包/类
@Override
protected void buttonPressed(int buttonId) {
	switch (buttonId) {
	case IDialogConstants.PROCEED_ID:
		CommitUI commitUI = new CommitUI(getShell(), repository,
				new IResource[0], true);
		shouldContinue = commitUI.commit();
		break;
	case IDialogConstants.ABORT_ID:
		final ResetOperation operation = new ResetOperation(repository,
				Constants.HEAD, ResetType.HARD);
		String jobname = NLS.bind(UIText.ResetAction_reset, Constants.HEAD);
		JobUtil.scheduleUserWorkspaceJob(operation, jobname,
				JobFamilies.RESET);
		shouldContinue = true;
		break;
	case IDialogConstants.SKIP_ID:
		StashCreateUI stashCreateUI = new StashCreateUI(repository);
		shouldContinue = stashCreateUI.createStash(getShell());
		break;
	case IDialogConstants.CANCEL_ID:
	}
	super.buttonPressed(buttonId);
}
 
开发者ID:Genuitec,项目名称:gerrit-tools,代码行数:25,代码来源:CleanupUncomittedChangesDialog.java

示例4: execute

import org.eclipse.jgit.api.ResetCommand.ResetType; //导入依赖的package包/类
public void execute(IProgressMonitor m) throws CoreException {
	IProgressMonitor monitor;
	if (m == null)
		monitor = new NullProgressMonitor();
	else
		monitor = m;
	if (type == ResetType.HARD) {
		IWorkspaceRunnable action = new IWorkspaceRunnable() {
			public void run(IProgressMonitor actMonitor) throws CoreException {
				reset(actMonitor);
			}
		};
		// lock workspace to protect working tree changes
		ResourcesPlugin.getWorkspace().run(action, getSchedulingRule(),
				IWorkspace.AVOID_UPDATE, monitor);
	} else {
		reset(monitor);
	}
}
 
开发者ID:Genuitec,项目名称:gerrit-tools,代码行数:20,代码来源:ResetOperation.java

示例5: pullRepository

import org.eclipse.jgit.api.ResetCommand.ResetType; //导入依赖的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

示例6: resetHard

import org.eclipse.jgit.api.ResetCommand.ResetType; //导入依赖的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

示例7: switchToMainAndDeleteFrom

import org.eclipse.jgit.api.ResetCommand.ResetType; //导入依赖的package包/类
/**
 * Switch to the main branch and delete the temporary branch.
 *
 * @throws GitAPIException
 * @throws RefAlreadyExistsException
 * @throws RefNotFoundException
 * @throws InvalidRefNameException
 * @throws CheckoutConflictException
 * @throws NotMergedException
 * @throws CannotDeleteCurrentBranchException
 */
private void switchToMainAndDeleteFrom(final String tempBranch)
		throws GitAPIException, RefAlreadyExistsException,
		RefNotFoundException, InvalidRefNameException,
		CheckoutConflictException, NotMergedException,
		CannotDeleteCurrentBranchException {
	try {
		repository.reset().setMode(ResetType.HARD).call();
	} finally {
		try {
			repository.checkout().setCreateBranch(false)
			.setName(mainBranchName).setForce(true).call();
		} finally {
			try {
				repository.reset().setMode(ResetType.HARD).call();
			} finally {
				repository.branchDelete().setForce(true)
				.setBranchNames(tempBranch).call();
			}
		}
	}
}
 
开发者ID:mast-group,项目名称:commitmining-tools,代码行数:33,代码来源:RepositoryFileWalker.java

示例8: checkout

import org.eclipse.jgit.api.ResetCommand.ResetType; //导入依赖的package包/类
@Override
public void checkout(String hash) {
	LOG.info(String.format("Checking out %s.", hash));
	File lockFile = new File(git.getRepository().getDirectory(), "git/index.lock");
	if (lockFile.exists()) {
		lockFile.delete();
	}

	try {
		git.reset().setMode(ResetType.HARD).call();
		git.checkout().setName("master").call();
		
		git.checkout().setCreateBranch(true).setName("rm_branch"+branchCounter++)
		.setStartPoint(hash).setForce(true).setOrphan(true).call();
	} catch (GitAPIException e) {
		close();
		throw new RepositoryMinerException(e);
	}
}
 
开发者ID:visminer,项目名称:repositoryminer,代码行数:20,代码来源:GitSCM.java

示例9: setMode

import org.eclipse.jgit.api.ResetCommand.ResetType; //导入依赖的package包/类
/**
 * If mode is set, apply the specified mode according to Git manual.
 *
 * @antdoc.notrequired
 * @param mode the mode used to perform git reset. (Default is MIXED)
 */
public void setMode(String mode) {
        if ("soft".equalsIgnoreCase(mode)) {
                this.mode = ResetType.SOFT;
        } else if ("mixed".equalsIgnoreCase(mode)) {
                this.mode = ResetType.MIXED;
        } else if ("hard".equalsIgnoreCase(mode)) {
                this.mode = ResetType.HARD;
        } else if ("merge".equalsIgnoreCase(mode)) {
                this.mode = ResetType.MERGE;
        } else if ("keep".equalsIgnoreCase(mode)) {
                this.mode = ResetType.KEEP;
        } else {
                this.mode = ResetType.MIXED;
        }
}
 
开发者ID:rimerosolutions,项目名称:ant-git-tasks,代码行数:22,代码来源:ResetTask.java

示例10: resetAndRemoveUntrackedFiles

import org.eclipse.jgit.api.ResetCommand.ResetType; //导入依赖的package包/类
private void resetAndRemoveUntrackedFiles( final Git repository )
		throws GitAPIException, CheckoutConflictException {
	repository.clean() //
			.setCleanDirectories( true ) //
			.setForce( true ) //
			.setIgnore( false ) //
			.call(); //

	repository.reset() //
			.setMode( ResetType.HARD ) //
			.call(); //
}
 
开发者ID:retest,项目名称:rebazer,代码行数:13,代码来源:RebaseService.java

示例11: restartMerge

import org.eclipse.jgit.api.ResetCommand.ResetType; //导入依赖的package包/类
/**
 * Restore to the initial state of the repository. Only applicable if the
 * repository has conflicts
 */
public void restartMerge() {
	try {
		AnyObjectId commitToMerge = git.getRepository().resolve("MERGE_HEAD");
		git.clean().call();
		git.reset().setMode(ResetType.HARD).call();
		git.merge().include(commitToMerge).setStrategy(MergeStrategy.RECURSIVE).call();
		
		fireFileStateChanged(new ChangeEvent(GitCommand.MERGE_RESTART, Collections.<String> emptyList()));
	} catch (GitAPIException | IOException e) {
		if (logger.isDebugEnabled()) {
			logger.debug(END_FETCH_DEBUG_MESSAGE);
		}
	}
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:19,代码来源:GitAccess.java

示例12: reset

import org.eclipse.jgit.api.ResetCommand.ResetType; //导入依赖的package包/类
public void reset() {
	/* delete lock file if one is present */
	File f = new File(gitRepoPath + "/.git/index.lock");
	if(f.exists()) {
		f.delete();
	}
	
	/* reset --hard HEAD */
	try {
		git.reset().setMode(ResetType.HARD).call();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:wsdookadr,项目名称:mdetect,代码行数:15,代码来源:GitStore.java

示例13: close

import org.eclipse.jgit.api.ResetCommand.ResetType; //导入依赖的package包/类
public void close() throws GitAPIException {
	Git git = gitRepository.getGit();
	git.reset().setMode(ResetType.HARD).call();

	if (indexUpdate != null) {
		indexUpdate.close();
	}
}
 
开发者ID:link-intersystems,项目名称:GitDirStat,代码行数:9,代码来源:HistoryUpdate.java

示例14: reset

import org.eclipse.jgit.api.ResetCommand.ResetType; //导入依赖的package包/类
private void reset(Project project, Branch branch) throws Exception {

		logger.log(project, "git reset --hard origin/%s", branch);

		doWithGit(project, git -> {

			git.reset()//
					.setMode(ResetType.HARD)//
					.setRef("origin/".concat(branch.toString()))//
					.call();
		});
	}
 
开发者ID:spring-projects,项目名称:spring-data-dev-tools,代码行数:13,代码来源:GitOperations.java

示例15: reset

import org.eclipse.jgit.api.ResetCommand.ResetType; //导入依赖的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


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