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


Java RefNotFoundException类代码示例

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


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

示例1: pull

import org.eclipse.jgit.api.errors.RefNotFoundException; //导入依赖的package包/类
@SneakyThrows
protected void pull() {
    try (
            Repository db = createRepository();
            Git git = Git.wrap(db);
    ) {
        String branchName = gitProperties.getBranchName();
        try {
            git.checkout().setName(branchName).call();
            git.pull().setCredentialsProvider(createCredentialsProvider()).call();
        } catch (RefNotFoundException e) {
            log.info("Branch {} not found in local repository", branchName);
            git.fetch().setCredentialsProvider(createCredentialsProvider()).call();
            git.checkout()
                    .setCreateBranch(true)
                    .setName(branchName)
                    .setUpstreamMode(TRACK)
                    .setStartPoint(DEFAULT_REMOTE_NAME + "/" + branchName).
                    call();
            git.pull().setCredentialsProvider(createCredentialsProvider()).call();
        }
    }
}
 
开发者ID:xm-online,项目名称:xm-ms-config,代码行数:24,代码来源:JGitRepository.java

示例2: visit

import org.eclipse.jgit.api.errors.RefNotFoundException; //导入依赖的package包/类
private static void visit( File directory ) throws IOException, RefNotFoundException, DetachedHeadException, WrongRepositoryStateException, InvalidRemoteException, InvalidConfigurationException, CanceledException {
    for ( final File child : directory.listFiles() ) {
        if ( child.isDirectory() ) {
            visit( child );
        }
        final String name = child.getName();
        if ( name.equals( ".git" ) ) {

            Thread t = new Thread( new Runnable() {
                public void run() {
                    try {
                        Git git = Git.open( child.getParentFile() );
                        PullResult pullResult = git.pull().call();
                        System.out.println( "pulled on " + child.getParentFile().getName() + ", pullResult = " + pullResult.isSuccessful() + ", " + pullResult.getFetchedFrom() + ", fetch messages: " + pullResult.getFetchResult().getMessages() );
                    }
                    catch ( Exception e ) {
                        e.printStackTrace();
                    }
                }
            } );
            t.start();

        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:26,代码来源:PullAll.java

示例3: promptSwitchToReviewBranch

import org.eclipse.jgit.api.errors.RefNotFoundException; //导入依赖的package包/类
/**
 * Asks the user if they want to switch to the review branch, and performs
 * the switch if so.
 */
private void promptSwitchToReviewBranch(TaskRepository taskRepository, String reviewBranch) {
  MessageDialog dialog = new MessageDialog(null, "Appraise Review", null,
      "Do you want to switch to the review branch (" + reviewBranch + ")", MessageDialog.QUESTION,
      new String[] {"Yes", "No"}, 0);
  int result = dialog.open();
  if (result == 0) {
    Repository repo = AppraisePluginUtils.getGitRepoForRepository(taskRepository);
    try (Git git = new Git(repo)) {
      previousBranch = repo.getFullBranch();
      git.checkout().setName(reviewBranch).call();
    } catch (RefNotFoundException rnfe) {
      MessageDialog alert = new MessageDialog(null, "Oops", null,
          "Branch " + reviewBranch + " not found", MessageDialog.INFORMATION, new String[] {"OK"}, 0);
      alert.open();
    } catch (Exception e) {
      AppraiseUiPlugin.logError("Unable to switch to review branch: " + reviewBranch, e);
    }
  }
}
 
开发者ID:google,项目名称:git-appraise-eclipse,代码行数:24,代码来源:AppraiseReviewTaskActivationListener.java

示例4: switchToMainAndDeleteFrom

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

示例5: fixCommitCount

import org.eclipse.jgit.api.errors.RefNotFoundException; //导入依赖的package包/类
private static TagVersionAndCount fixCommitCount(TagVersionAndCount resolved, Repository repo) throws RefNotFoundException, GitAPIException {
    Git git = new Git(repo);
    ObjectId target, head;
    LogCommand logCommand;
    try {
        target = repo.getRef(resolved.getVersion()).getPeeledObjectId();
        logCommand = git.log();
        logCommand.add(target);
    } catch (IOException e) {
        throw new SemverGitflowPlugin.VersionApplicationException(e);
    }
    int count = 0;
    for (RevCommit commit : logCommand.call()) {
        count ++;
    }
    return new TagVersionAndCount(resolved.getVersion(), count);
}
 
开发者ID:palantir,项目名称:gradle-gitsemver,代码行数:18,代码来源:DescribedTags.java

示例6: call

import org.eclipse.jgit.api.errors.RefNotFoundException; //导入依赖的package包/类
@Override
public Ref call() throws GitAPIException, RefNotFoundException,
	CheckoutConflictException, InvalidRefNameException,
	RefAlreadyExistsException
{
	this.checkCallable();
	try {
		this.processOptions();
		this.checkoutStartPoint();
		RefUpdate update = this.getRepository().updateRef(Constants.HEAD);
		Result r = update.link(this.getBranchName());
		if (EnumSet.of(Result.NEW, Result.FORCED).contains(r) == false) {
			throw new JGitInternalException(MessageFormat.format(
				JGitText.get().checkoutUnexpectedResult, r.name()));
		}
		this.setCallable(false);
		return this.getRepository().getRef(Constants.HEAD);
	}
	catch (IOException e) {
		throw new JGitInternalException(e.getMessage(), e);
	}
}
 
开发者ID:uw-loci,项目名称:github-backup-java,代码行数:23,代码来源:CreateOrphanBranchCommand.java

示例7: call

import org.eclipse.jgit.api.errors.RefNotFoundException; //导入依赖的package包/类
public Git call(final GitOperationsStep gitOperationsStep, Git git,
    CredentialsProvider cp, String gitRepoUrl, File gitRepoFolder)
    throws IllegalArgumentException, IOException,
    WrongRepositoryStateException, InvalidConfigurationException,
    DetachedHeadException, InvalidRemoteException, CanceledException,
    RefNotFoundException, NoHeadException, TransportException,
    GitAPIException {
  git.pull().setCredentialsProvider(cp).setRebase(rebase).call();
  return git;
}
 
开发者ID:ivylabs,项目名称:ivy-pdi-git-steps,代码行数:11,代码来源:PullGitCommand.java

示例8: resolveLatestTagVersionAndCount

import org.eclipse.jgit.api.errors.RefNotFoundException; //导入依赖的package包/类
public static TagVersionAndCount resolveLatestTagVersionAndCount(
        Repository repo, TagVersionAndCount curTag, int recur) throws IOException,
        RefNotFoundException, GitAPIException {
    Git git = new Git(repo);
    String described = git.describe().setTarget(curTag.getVersion()).call();
    if (described == null)
        return null;
    TagVersionAndCount describedTag = parseDescribeOutput(described);
    if (!SemanticVersions.isValid(GitRepos.stripVFromVersionString(describedTag.getVersion()))) {
        RevWalk revWalk = new RevWalk(repo);
        RevCommit describedRev = revWalk.parseCommit(repo.resolve(describedTag.getVersion()));
        TagVersionAndCount mostRecentParentTag = new TagVersionAndCount("", Integer.MAX_VALUE);
        for (RevCommit parent : describedRev.getParents()) {
            TagVersionAndCount parentTag = new TagVersionAndCount(parent.name(), -1);
            TagVersionAndCount resolvedParentTag = resolveLatestTagVersionAndCount(repo, parentTag, recur + 1);
            if (resolvedParentTag == null)
                continue;
            if (resolvedParentTag.getCount() < mostRecentParentTag.getCount()) {
                mostRecentParentTag = resolvedParentTag;
            }
        }
        if (mostRecentParentTag.getCount() == Integer.MAX_VALUE) {
            return null;
        }
        return mostRecentParentTag;
    } else {
    	if (recur != 0)
    		return new TagVersionAndCount(describedTag.getVersion(), -1);
        return describedTag;
    }
}
 
开发者ID:palantir,项目名称:gradle-gitsemver,代码行数:32,代码来源:DescribedTags.java

示例9: getLatestTagVersionAndCount

import org.eclipse.jgit.api.errors.RefNotFoundException; //导入依赖的package包/类
public static TagVersionAndCount getLatestTagVersionAndCount(Repository repo)
        throws IOException, RefNotFoundException, GitAPIException {
	TagVersionAndCount tac = resolveLatestTagVersionAndCount(repo, new TagVersionAndCount("HEAD", 0), 0);
	if (tac.getCount() == -1)
		return fixCommitCount(tac, repo);
	return tac;
}
 
开发者ID:palantir,项目名称:gradle-gitsemver,代码行数:8,代码来源:DescribedTags.java

示例10: initializeGitFlow

import org.eclipse.jgit.api.errors.RefNotFoundException; //导入依赖的package包/类
private static Git initializeGitFlow(Repository repo)
        throws RefAlreadyExistsException, RefNotFoundException,
        InvalidRefNameException, GitAPIException {
    Git git = new Git(repo);
    git.commit().setCommitter(COMMITTER).setMessage("initial commit").call();
    return git;
}
 
开发者ID:palantir,项目名称:gradle-gitsemver,代码行数:8,代码来源:TagBasedVersionFactoryTest.java

示例11: checkoutStartPoint

import org.eclipse.jgit.api.errors.RefNotFoundException; //导入依赖的package包/类
protected void checkoutStartPoint() throws GitAPIException,
	RefNotFoundException, CheckoutConflictException, IOException
{
	ObjectId sp = this.getStartPoint();
	if (sp != null) {
		this.checkout(sp);
	}
}
 
开发者ID:uw-loci,项目名称:github-backup-java,代码行数:9,代码来源:CreateOrphanBranchCommand.java

示例12: getStartPoint

import org.eclipse.jgit.api.errors.RefNotFoundException; //导入依赖的package包/类
protected ObjectId getStartPoint() throws RefNotFoundException, IOException {
	if (this.startCommit != null) {
		return this.startCommit.getId();
	}
	if (StringUtils.isEmptyOrNull(this.startPoint) == false) {
		ObjectId oid = this.getRepository().resolve(this.startPoint);
		if (oid == null) {
			throw new RefNotFoundException(MessageFormat.format(
				JGitText.get().refNotResolved, this.startPoint));
		}
		return oid;
	}
	return null;
}
 
开发者ID:uw-loci,项目名称:github-backup-java,代码行数:15,代码来源:CreateOrphanBranchCommand.java

示例13: getWorkflowsFromDirectory

import org.eclipse.jgit.api.errors.RefNotFoundException; //导入依赖的package包/类
/**
 * Get a list of workflows from a directory
 * @param gitInfo The Git directory information
 * @return The list of workflow overviews
 */
public List<WorkflowOverview> getWorkflowsFromDirectory(GitDetails gitInfo) throws IOException, GitAPIException {
    List<WorkflowOverview> workflowsInDir = new ArrayList<>();
    try {
        boolean safeToAccess = gitSemaphore.acquire(gitInfo.getRepoUrl());
        Git repo = null;
        while (repo == null) {
            try {
                repo = gitService.getRepository(gitInfo, safeToAccess);
            } catch (RefNotFoundException ex) {
                // Attempt slashes in branch fix
                GitDetails correctedForSlash = gitService.transferPathToBranch(gitInfo);
                if (correctedForSlash != null) {
                    gitInfo = correctedForSlash;
                } else {
                    throw ex;
                }
            }
        }

        Path localPath = repo.getRepository().getWorkTree().toPath();
        Path pathToDirectory = localPath.resolve(gitInfo.getPath()).normalize().toAbsolutePath();
        Path root = Paths.get("/").toAbsolutePath();
        if (pathToDirectory.equals(root)) {
            pathToDirectory = localPath;
        } else if (!pathToDirectory.startsWith(localPath.normalize().toAbsolutePath())) {
            // Prevent path traversal attacks
            throw new WorkflowNotFoundException();
        }

        File directory = new File(pathToDirectory.toString());
        if (directory.exists() && directory.isDirectory()) {
            for (final File file : directory.listFiles()) {
                int eIndex = file.getName().lastIndexOf('.') + 1;
                if (eIndex > 0) {
                    String extension = file.getName().substring(eIndex);
                    if (extension.equals("cwl")) {
                        WorkflowOverview overview = cwlService.getWorkflowOverview(file);
                        if (overview != null) {
                            workflowsInDir.add(overview);
                        }
                    }
                }
            }
        }
    } finally {
        gitSemaphore.release(gitInfo.getRepoUrl());
    }
    return workflowsInDir;
}
 
开发者ID:common-workflow-language,项目名称:cwlviewer,代码行数:55,代码来源:WorkflowService.java

示例14: main

import org.eclipse.jgit.api.errors.RefNotFoundException; //导入依赖的package包/类
public static void main( String[] args ) throws IOException, RefNotFoundException, DetachedHeadException, WrongRepositoryStateException, InvalidRemoteException, InvalidConfigurationException, CanceledException {
    visit( new File( "C:\\workingcopy\\phet-little-gits" ) );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:4,代码来源:PullAll.java


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