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


Java Git.open方法代码示例

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


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

示例1: GitTool

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
public GitTool() {
    File gitWorkDir = new File(".");
    try {
        Git git = Git.open(gitWorkDir);
        Iterable<RevCommit> commits = git.log().all().call();
        Repository repo = git.getRepository();
        branch = repo.getBranch();
        RevCommit latestCommit = commits.iterator().next();
        name = latestCommit.getName();
        message = latestCommit.getFullMessage();
    } catch (Throwable e) {
        name = "";
        message = "";
        branch = "";
    }
}
 
开发者ID:yacy,项目名称:yacy_grid_mcp,代码行数:17,代码来源:GitTool.java

示例2: should_push_success

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
@Test
public void should_push_success() throws Throwable {
    File localGitFolder = folder.newFolder("info.git");
    // when: init bareGit
    JGitUtil.init(localGitFolder.toPath(), true);

    // then: tag list is 0
    Assert.assertEquals(0, Git.open(localGitFolder).tagList().call().size());

    File onlineGitFolder = folder.newFolder("info");
    JGitUtil.clone(GIT_URL, onlineGitFolder.toPath());
    JGitUtil.remoteSet(onlineGitFolder.toPath(), "local", localGitFolder.toString());
    Git git = Git.open(onlineGitFolder);
    String tag = JGitUtil.tags(git.getRepository()).get(0);

    // when: push latest tag
    JGitUtil.push(onlineGitFolder.toPath(), "local", tag);

    // then: tag size is 1
    Assert.assertEquals(1, Git.open(localGitFolder).tagList().call().size());

    // then: tag is v1.1
    Assert.assertEquals("v1.1", JGitUtil.tags(localGitFolder.toPath()).get(0));
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:25,代码来源:JGitUtilTest.java

示例3: commitSomething

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
private void commitSomething(Path path) {
    try (Git git = Git.open(path.toFile())) {
        Path emptyFilePath = Paths.get(path.toString(), EMPTY_FILE);

        try {
            Files.createFile(emptyFilePath);
        } catch (FileAlreadyExistsException ignore) {
        }

        git.add()
            .addFilepattern(".")
            .call();

        git.commit()
            .setMessage("add test branch")
            .call();

    } catch (Throwable e) {
        LOGGER.error("Method: commitSomething Exception", e);
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:22,代码来源:PluginServiceImpl.java

示例4: open

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
Git open(File file) {
	try {
		return Git.open(file);
	}
	catch (IOException e) {
		throw new IllegalStateException(e);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-release-tools,代码行数:9,代码来源:GitRepo.java

示例5: getRepo

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
public static Repository getRepo(Path path) throws GitException {
    try (Git git = Git.open(path.toFile())) {
        return git.getRepository();
    } catch (IOException e) {
        throw new GitException(e.getMessage());
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:8,代码来源:JGitUtil.java

示例6: tags

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
public static List<String> tags(Path gitPath) throws GitException {
    try (Git git = Git.open(gitPath.toFile())) {
        try (Repository repo = git.getRepository()) {
            return tags(repo);
        }
    } catch (IOException e) {
        throw new GitException(e.getMessage());
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:10,代码来源:JGitUtil.java

示例7: push

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
/**
 * Push code to remote repo
 *
 * @param path
 * @param remote
 * @param branchOrTag
 * @return
 * @throws GitException
 */
public static Path push(Path path, String remote, String branchOrTag) throws GitException {
    try (Git git = Git.open(path.toFile())) {
        git.push()
            .setRemote(remote)
            .setRefSpecs(new RefSpec(branchOrTag))
            .call();
    } catch (Throwable throwable) {
        throw new GitException("Fail to Push ", throwable);
    }

    return path;
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:22,代码来源:JGitUtil.java

示例8: tryToOpenExistingRepoAndCheckRemote

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
private static Git tryToOpenExistingRepoAndCheckRemote( final File repoFolder, final String expectedRepoUrl ) {
	try {
		final Git repo = Git.open( repoFolder );
		if ( originIsRepoUrl( repo, expectedRepoUrl ) ) {
			return repo;
		} else {
			log.error( "Repo has wrong remote URL!" );
			return null;
		}
	} catch ( final Exception e ) {
		log.error( "Exception while open repo!", e );
		return null;
	}
}
 
开发者ID:retest,项目名称:rebazer,代码行数:15,代码来源:RebaseService.java

示例9: fetchTags

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
/**
 * fetch tags from remote
 * @param path
 * @param remoteName
 * @return
 * @throws GitException
 */
public static Path fetchTags(Path path, String remoteName) throws GitException {
    try (Git git = Git.open(path.toFile())) {
        git.fetch()
            .setRemote(remoteName)
            .setRefSpecs(new RefSpec("refs/tags/*:refs/tags/*"))
            .setTagOpt(TagOpt.FETCH_TAGS)
            .call();
    } catch (Throwable throwable) {
        throw new GitException("fetch tags error", throwable);
    }

    return path;
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:21,代码来源:JGitUtil.java

示例10: checkout

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
public static Path checkout(Path path, String branch) throws GitException {
    try (Git git = Git.open(path.toFile())) {
        git
            .checkout()
            .setName(branch)
            .call();
    } catch (Throwable throwable) {
        throw new GitException("fetch tags error", throwable);
    }

    return path;
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:13,代码来源:JGitUtil.java

示例11: listCommits

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
/**
 * List branch commits
 * @param path
 * @return
 * @throws GitException
 */
public static List<RevCommit> listCommits(Path path) throws GitException {
    try (Git git = Git.open(path.toFile())) {
        Iterable<RevCommit> iterable = git.log().call();
        List<RevCommit> commits = stream(iterable.spliterator(), false).collect(toList());
        return commits;
    } catch (Throwable throwable) {
        throw new GitException("get commits error", throwable);
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:16,代码来源:JGitUtil.java

示例12: gitOpen

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
private Git gitOpen() throws GitException {
    try {
        return Git.open(getGitPath().toFile());
    } catch (IOException e) {
        throw new GitException("Fail to open .git folder", e);
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:8,代码来源:JGitBasedClient.java

示例13: init

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
@Override
public void init(MavenSession session, Logger logger) throws RevisionGeneratorException {
    Git git = null;
    try {
        if (session.getExecutionRootDirectory() == null) {
            revision = "1.0-SNAPSHOT";
            dirty = true;
        } else {
            File gitDir = new FileRepositoryBuilder()
                    .findGitDir(new F‌ile(session.getExecutionRootDirectory()))
                    .getGitDir();
            if (gitDir != null && gitDir.exists()) {
                git = Git.open(gitDir);
                init(git, logger);
            } else {
                revision = "1.0-SNAPSHOT";
                dirty = true;
            }
        }
    } catch (IOException ex) {
        throw new RevisionGeneratorException("Issue opening Git repository for the project", ex);
    } finally {
        if (git != null) {
            git.close();
        }
    }
}
 
开发者ID:IG-Group,项目名称:cdversion-maven-extension,代码行数:28,代码来源:GitRevisionGenerator.java

示例14: should_fetch_tags_success

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
@Test
public void should_fetch_tags_success() throws Throwable {
    File localGitFolder = folder.newFolder("info.git");
    File onlineGitFolder = folder.newFolder("info");
    JGitUtil.init(onlineGitFolder.toPath(), false);
    JGitUtil.init(localGitFolder.toPath(), true);
    JGitUtil.remoteSet(onlineGitFolder.toPath(), "origin", GIT_URL);
    JGitUtil.remoteSet(onlineGitFolder.toPath(), "local", localGitFolder.toString());
    JGitUtil.fetchTags(onlineGitFolder.toPath(), GIT_URL);
    Git git = Git.open(onlineGitFolder);
    Assert.assertEquals(2, git.remoteList().call().size());
    Assert.assertEquals(false, JGitUtil.tags(git.getRepository()).isEmpty());
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:14,代码来源:JGitUtilTest.java

示例15: commitRepo

import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
public void commitRepo() {
    try {
        Git git = Git.open(worldsDir);
        new CustomAddCommand(git.getRepository()).addFilepattern(".").call();
        git.commit().setAuthor("voxelgameslib", "[email protected]")
                .setMessage("Update " + LocalDateTime.now().toString()).call();
        // don't push here, thats need to be done manually
    } catch (IOException | GitAPIException e) {
        e.printStackTrace();
    }
}
 
开发者ID:VoxelGamesLib,项目名称:VoxelGamesLibv2,代码行数:12,代码来源:WorldRepository.java


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