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


Java GitAPIException类代码示例

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


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

示例1: invoke

import org.eclipse.jgit.api.errors.GitAPIException; //导入依赖的package包/类
@Override
public Boolean invoke(File file, VirtualChannel channel){
    try{
        Git git = Git.cloneRepository()
                .setURI(url)
                .setDirectory(localDir)
                .setTransportConfigCallback(getTransportConfigCallback())
                .setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password))
                .call();

        // Default branch to checkout is master
        if(branch==null || branch.isEmpty()){
            branch = "master";
        } else if (cloneType.equals("branch")){
            branch = "origin" + File.separator + branch;
        }
        git.checkout().setName(branch).call();
        git.close();
        }catch(GitAPIException e){
            status = false;
            e.printStackTrace(listener.getLogger());
        }
    return status;
}
 
开发者ID:warriorframework,项目名称:warrior-jenkins-plugin,代码行数:25,代码来源:WarriorPluginBuilder.java

示例2: clone

import org.eclipse.jgit.api.errors.GitAPIException; //导入依赖的package包/类
/**
 * Cloning the remote git repo to local directory
 * @param remoteUri remote git url e.g. git://gitli.example.com/project/repo.git
 * @param localDir local destination clone directory
 * @throws IOException
 * @throws GitAPIException
 */
public static void clone(String remoteUri, String localDir) throws IOException, GitAPIException {
  //create local git directory
  File localGitRepo = new File(localDir);
  if (localGitRepo.exists()) {
    if (localGitRepo.isDirectory()) {
      // clean up directory
      FileUtils.cleanDirectory(localGitRepo);
    } else {
      throw new IOException("File exists: " + localDir);
    }
  } else {
    localGitRepo.mkdirs();
  }

  Git g = Git.cloneRepository().setURI(remoteUri).setDirectory(localGitRepo).call();
  g.close();
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:25,代码来源:GitUtil.java

示例3: run

import org.eclipse.jgit.api.errors.GitAPIException; //导入依赖的package包/类
@Override
protected void run () throws GitException {
    Repository repository = getRepository();
    org.eclipse.jgit.api.BlameCommand cmd = new Git(repository).blame();
    cmd.setFilePath(Utils.getRelativePath(getRepository().getWorkTree(), file));
    if (revision != null) {
        cmd.setStartCommit(Utils.findCommit(repository, revision));
    } else if (repository.getConfig().get(WorkingTreeOptions.KEY).getAutoCRLF() != CoreConfig.AutoCRLF.FALSE) {
        // work-around for autocrlf
        cmd.setTextComparator(new AutoCRLFComparator());
    }
    cmd.setFollowFileRenames(true);
    try {
        BlameResult cmdResult = cmd.call();
        if (cmdResult != null) {
            result = getClassFactory().createBlameResult(cmdResult, repository);
        }
    } catch (GitAPIException ex) {
        throw new GitException(ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:BlameCommand.java

示例4: main

import org.eclipse.jgit.api.errors.GitAPIException; //导入依赖的package包/类
public static void main(String[] args) throws IOException, GitAPIException {
        Repository repo = Commands.getRepo(Consts.META_REPO_PATH);

        Git git = new Git(repo);

        // Create a new branch
        git.branchCreate().setName("newBranch").call();
// Checkout the new branch
        git.checkout().setName("newBranch").call();
        // List the existing branches
        List<Ref> listRefsBranches = git.branchList().setListMode(ListMode.ALL).call();
        listRefsBranches.forEach((refBranch) -> {
            System.out.println("Branch : " + refBranch.getName());
        });
// Go back on "master" branch and remove the created one
        git.checkout().setName("master");
        git.branchDelete().setBranchNames("newBranch");
    }
 
开发者ID:alexmy21,项目名称:gmds,代码行数:19,代码来源:Branches.java

示例5: run

import org.eclipse.jgit.api.errors.GitAPIException; //导入依赖的package包/类
@Override
protected void run () throws GitException {
    Repository repository = getRepository();
    try {
        RevObject obj = Utils.findObject(repository, taggedObject);
        TagCommand cmd = new Git(repository).tag();
        cmd.setName(tagName);
        cmd.setForceUpdate(forceUpdate);
        cmd.setObjectId(obj);
        cmd.setAnnotated(message != null && !message.isEmpty() || signed);
        if (cmd.isAnnotated()) {
            cmd.setMessage(message);
            cmd.setSigned(signed);
        }
        cmd.call();
        ListTagCommand tagCmd = new ListTagCommand(repository, getClassFactory(), false, new DelegatingGitProgressMonitor(monitor));
        tagCmd.run();
        Map<String, GitTag> tags = tagCmd.getTags();
        tag = tags.get(tagName);
    } catch (JGitInternalException | GitAPIException ex) {
        throw new GitException(ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:CreateTagCommand.java

示例6: main

import org.eclipse.jgit.api.errors.GitAPIException; //导入依赖的package包/类
public static void main(String[] args) throws IOException, GitAPIException {
    
    Repository repo = new FileRepository(Consts.META_REPO_PATH + ".git");
    
    // get a list of all known heads, tags, remotes, ...
    Collection<Ref> allRefs = repo.getAllRefs().values();

    // a RevWalk allows to walk over commits based on some filtering that is defined
    try (RevWalk revWalk = new RevWalk(repo)) {
        for (Ref ref : allRefs) {
            revWalk.markStart(revWalk.parseCommit(ref.getObjectId()));
        }
        System.out.println("Walking all commits starting with " + allRefs.size() + " refs: " + allRefs);
        int count = 0;
        for (RevCommit commit : revWalk) {
            System.out.println("Commit: " + commit);
            count++;
        }
        System.out.println("Had " + count + " commits");
    }
}
 
开发者ID:alexmy21,项目名称:gmds,代码行数:22,代码来源:RefList.java

示例7: checkoutBranch

import org.eclipse.jgit.api.errors.GitAPIException; //导入依赖的package包/类
private Ref checkoutBranch(File projectDir, String branch)
		throws GitAPIException {
	Git git = this.gitFactory.open(projectDir);
	CheckoutCommand command = git.checkout().setName(branch);
	try {
		if (shouldTrack(git, branch)) {
			trackBranch(command, branch);
		}
		return command.call();
	}
	catch (GitAPIException e) {
		deleteBaseDirIfExists();
		throw e;
	} finally {
		git.close();
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-release-tools,代码行数:18,代码来源:GitRepo.java

示例8: main

import org.eclipse.jgit.api.errors.GitAPIException; //导入依赖的package包/类
public static void main(String[] args) throws IOException, GitAPIException {

        Repository repo = Commands.getRepo(Consts.META_REPO_PATH);

        // Get the id of the tree associated to the two commits
        ObjectId head = repo.resolve("HEAD^{tree}");
        ObjectId previousHead = repo.resolve("HEAD~^{tree}");

        List<DiffEntry> list = listDiffs(repo, previousHead, head);
        if(list != null){            
            // Simply display the diff between the two commits
            list.forEach((diff) -> {
                System.out.println(diff);
            });
        }
    }
 
开发者ID:alexmy21,项目名称:gmds,代码行数:17,代码来源:Diffs.java

示例9: cloneRepositoryToTempFolder

import org.eclipse.jgit.api.errors.GitAPIException; //导入依赖的package包/类
public Repository cloneRepositoryToTempFolder(boolean checkoutAll) throws GitAPIException, IOException {
    this.targetFolder = createTempFolder(repositoryName);
    final Repository repository = Git.cloneRepository()
                .setURI(repositoryUrl)
                .setDirectory(targetFolder)
                .setCloneAllBranches(true)
                .setBranch("master")
            .call()
        .getRepository();

    if (checkoutAll) {
        checkoutAllBranches(repository);
    }

    LOGGER.info("Cloned test repository to: " + targetFolder);
    return repository;
}
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:18,代码来源:GitCloner.java

示例10: applyStashChangesLocally

import org.eclipse.jgit.api.errors.GitAPIException; //导入依赖的package包/类
private void applyStashChangesLocally(List<RevCommit> stashesToApply) throws GitAPIException {
    RevCommit tmpCommit = null;
    // We cannot just apply changes from stash one after the other
    // as git will complain about uncommitted changes when trying
    // to apply second consecutive stash.
    // So we create temporary commits to overcome this issue
    // and reset softly on the way to have it all as local changes
    for (final RevCommit stash : stashesToApply) {
        if (stash == null){
            continue;
        }
        git.stashApply().setStashRef(stash.getName()).call();
        if (tmpCommit != null) {
            git.reset().setRef(ONE_BACK).setMode(SOFT).call();
        }
        tmpCommit = createTemporaryCommit();
    }
    if (tmpCommit != null) {
        git.reset().setRef(ONE_BACK).setMode(SOFT).call();
    }
    git.stashDrop().setAll(true).call();
}
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:23,代码来源:ChangeApplier.java

示例11: should_find_local_newly_staged_files_as_new

import org.eclipse.jgit.api.errors.GitAPIException; //导入依赖的package包/类
@Test
public void should_find_local_newly_staged_files_as_new() throws IOException, GitAPIException {
    //given
    Configuration configuration = createConfiguration("a4261d5", "1ee4abf");
    final File testFile = gitFolder.newFile("core/src/test/java/org/arquillian/smart/testing/CalculatorTest.java");
    Files.write(testFile.toPath(), getContentsOfClass().getBytes(), StandardOpenOption.APPEND);

    GitRepositoryOperations.addFile(gitFolder.getRoot(), testFile.getAbsolutePath());

    final NewTestsDetector newTestsDetector =
        new NewTestsDetector(new GitChangeResolver(), new NoopStorage(), gitFolder.getRoot(), path -> true, configuration);

    // when
    final Collection<TestSelection> newTests = newTestsDetector.getTests();

    // then
    assertThat(newTests).extracting(TestSelection::getClassName)
        .containsOnly("org.arquillian.smart.testing.CalculatorTest",
            "org.arquillian.smart.testing.vcs.git.NewFilesDetectorTest");
}
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:21,代码来源:NewTestsGitBasedDetectorTest.java

示例12: should_find_modified_staged_tests_as_changed

import org.eclipse.jgit.api.errors.GitAPIException; //导入依赖的package包/类
@Test
public void should_find_modified_staged_tests_as_changed() throws IOException, GitAPIException {
    //given
    Configuration configuration = createConfiguration("7699c2c", "04d04fe");
    final Path testFile = Paths.get(gitFolder.getRoot().getAbsolutePath(),
        "core/src/test/java/org/arquillian/smart/testing/FilesTest.java");
    Files.write(testFile, "//This is a test".getBytes(), StandardOpenOption.APPEND);
    GitRepositoryOperations.addFile(gitFolder.getRoot(), testFile.toString());

    final ChangedTestsDetector changedTestsDetector =
        new ChangedTestsDetector(new GitChangeResolver(), new NoopStorage(), gitFolder.getRoot(),
            className -> className.endsWith("Test"), configuration);

    // when
    final Collection<TestSelection> newTests = changedTestsDetector.getTests();

    // then
    assertThat(newTests).extracting(TestSelection::getClassName)
        .containsOnly("org.arquillian.smart.testing.vcs.git.NewFilesDetectorTest",
            "org.arquillian.smart.testing.FilesTest");
}
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:22,代码来源:ChangedTestsDetectorTest.java

示例13: should_fetch_all_untracked_files_for_first_commit

import org.eclipse.jgit.api.errors.GitAPIException; //导入依赖的package包/类
@Test
public void should_fetch_all_untracked_files_for_first_commit() throws IOException, GitAPIException {
    // given
    final File parent = gitFolder.newFolder("parent");
    final File newGitFolder = parent.getParentFile();

    gitFolder.newFile("parent/foo.txt");

    try (Git git = Git.init()
        .setDirectory(newGitFolder)
        .call()) {
    }

    this.gitChangeResolver = new GitChangeResolver();

    // when
    final Set<Change> untrackedChanges = gitChangeResolver.diff(newGitFolder, "HEAD~0", "HEAD");

    // then
    assertThat(untrackedChanges).hasSize(1).extracting(Change::getLocation, Change::getChangeType).containsOnly(tuple(
        relative("parent/foo.txt"), ChangeType.ADD));
}
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:23,代码来源:GitChangeResolverTest.java

示例14: testPushOK

import org.eclipse.jgit.api.errors.GitAPIException; //导入依赖的package包/类
@Test
public void testPushOK()
		throws URISyntaxException, IOException, InvalidRemoteException, TransportException, GitAPIException, NoRepositorySelected {
	gitAccess.setRepository(LOCAL_TEST_REPOSITPRY);
	final StoredConfig config = gitAccess.getRepository().getConfig();
	RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
	URIish uri = new URIish(db2.getDirectory().toURI().toURL());
	remoteConfig.addURI(uri);
	remoteConfig.update(config);
	config.save();

	gitAccess.add(new FileStatus(GitChangeType.ADD, "test.txt"));
	gitAccess.commit("file test added");

	gitAccess.push("", "");

	assertEquals(db1.resolve(gitAccess.getLastLocalCommit().getName() + "^{commit}"),
			db2.resolve(gitAccess.getLastLocalCommit().getName() + "^{commit}"));

}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:21,代码来源:GitAccessPushTest.java

示例15: deleteTag

import org.eclipse.jgit.api.errors.GitAPIException; //导入依赖的package包/类
public void deleteTag(String tag) {
  	String refName = GitUtils.tag2ref(tag);
  	ObjectId commitId = getRevCommit(refName).getId();
  	try {
	git().tagDelete().setTags(tag).call();
} catch (GitAPIException e) {
	throw new RuntimeException(e);
}
  	Subject subject = SecurityUtils.getSubject();
  	GitPlex.getInstance(UnitOfWork.class).doAsync(new Runnable() {

	@Override
	public void run() {
		ThreadContext.bind(subject);
		try {
			Project project = GitPlex.getInstance(ProjectManager.class).load(getId());
			GitPlex.getInstance(ListenerRegistry.class).post(
					new RefUpdated(project, refName, commitId, ObjectId.zeroId()));
		} finally {
			ThreadContext.unbindSubject();
		}
	}
  		
  	});
  }
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:26,代码来源:Project.java


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