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


Java CreateBranchCommand.setName方法代码示例

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


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

示例1: createBranch

import org.eclipse.jgit.api.CreateBranchCommand; //导入方法依赖的package包/类
/**
 * Creates branch on provided repository - git branch name
 *
 * @param repositoryName for which repository
 * @param name of branch
 */
public void createBranch(String repositoryName, String name)
{
    RepositoryContext repositoryContext = repositoryByName.get(repositoryName);

    try
    {
        CreateBranchCommand createBranchCommand = repositoryContext.git.branchCreate();
        createBranchCommand.setName(name);
        createBranchCommand.call();
    }
    catch (GitAPIException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:22,代码来源:GitTestSupport.java

示例2: createBranch

import org.eclipse.jgit.api.CreateBranchCommand; //导入方法依赖的package包/类
/**
 * Create a new branch in the local git repository
 * (git checkout -b branchname) and finally pushes new branch on the remote repository (git push)
 *
 * @param directory the directory in which the local git repository is located
 * @param username  the username to be used while pushing
 * @param password  the password matching with the provided username to be used
 *                  for authentication
 * @param message   the commit message to be used	 
 */
public static void createBranch(@NonNull File directory, String branchName, String username,
								String password, String message) throws GitAPIException {

	try {
		final Git git = Git.open(directory);

		final UsernamePasswordCredentialsProvider userCredential = new UsernamePasswordCredentialsProvider(
				username, password);

		CreateBranchCommand branchCommand = git.branchCreate();
		branchCommand.setName(branchName);
		branchCommand.call();
		
		// and then commit
		final PersonIdent author = new PersonIdent(username, "");
		git.commit().setCommitter(author).setMessage(message)
				.setAuthor(author).call();
		log.info(message);

		git.push().setCredentialsProvider(userCredential).call();
		log.info("Pushed the changes in remote Git repository...");
	} catch (final GitAPIException | IOException e) {
		log.error(e.getMessage(), e);
	}
}
 
开发者ID:awltech,项目名称:easycukes,代码行数:36,代码来源:GitHelper.java

示例3: createBranch

import org.eclipse.jgit.api.CreateBranchCommand; //导入方法依赖的package包/类
@Override
public String createBranch(String commitId, String branchName) {
    
    Ref result = null;
    CreateBranchCommand branchCreate = _git.branchCreate();
    branchCreate.setName(branchName);
    branchCreate.setStartPoint(commitId);
    try {
        result = branchCreate.call();
    } catch (Throwable e) {
        throw new RuntimeException(String.format(
                "Failed creating branch: %s for commit [%s]",
                branchName,
                commitId), e);
    }
    
    return result.getName();
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:19,代码来源:JGitOperator.java

示例4: testPullRequest

import org.eclipse.jgit.api.CreateBranchCommand; //导入方法依赖的package包/类
/**
 * Test the ghprb constructor.
 *
 * @throws Exception
 */
@Test
public void testPullRequest() throws Exception
{
    Map<String, byte[]> expectedContents = new HashMap<String, byte[]>();
    expectedContents.put("src/pages/modifyThis.page", contents.getBytes());
    expectedContents.put("src/pages/modifyThis.page-meta.xml", contents.getBytes());
    expectedContents.put("src/triggers/addThis.trigger", contents.getBytes());
    expectedContents.put("src/triggers/addThis.trigger-meta.xml", contents.getBytes());

    String oldBranch = "refs/remotes/origin/oldBranch";
    CreateBranchCommand cbc = new Git(repository).branchCreate();
    cbc.setName(oldBranch);
    cbc.setStartPoint(oldSha);
    cbc.call();

    git = new SMAGit(gitDir, newSha, "oldBranch", SMAGit.Mode.PRB);

    Map<String, byte[]> allMetadata = git.getAllMetadata();

    assertEquals(expectedContents.size(), allMetadata.size());
}
 
开发者ID:aesanch2,项目名称:salesforce-migration-assistant,代码行数:27,代码来源:SMAGitTest.java

示例5: createBranch

import org.eclipse.jgit.api.CreateBranchCommand; //导入方法依赖的package包/类
public void createBranch(String branchName, String branchRevision) {
try {
	CreateBranchCommand command = git().branchCreate();
	command.setName(branchName);
	command.setStartPoint(getRevCommit(branchRevision));
	command.call();
} catch (GitAPIException e) {
	throw new RuntimeException(e);
}
  }
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:11,代码来源:Project.java

示例6: createLocalBranch

import org.eclipse.jgit.api.CreateBranchCommand; //导入方法依赖的package包/类
public LocalBranch createLocalBranch() throws GitAPIException {
	GitRepository gitRepository = getGitRepository();
	Repository repository = gitRepository.getRepository();
	Git git = gitRepository.getGit();
	CreateBranchCommand branchCreate = git.branchCreate();
	String name = getName();
	String shortenRefName = repository.shortenRemoteBranchName(name);
	branchCreate.setName(shortenRefName);
	branchCreate.setStartPoint(name);
	branchCreate.setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM);
	Ref call = branchCreate.call();
	return new LocalBranch(gitRepository, call);

}
 
开发者ID:link-intersystems,项目名称:GitDirStat,代码行数:15,代码来源:RemoteBranch.java

示例7: build

import org.eclipse.jgit.api.CreateBranchCommand; //导入方法依赖的package包/类
/**
 * Requires a bare repository. We clone to a random workspace
 *
 * @throws Exception
 * @return The generator currently being worked on
 */
public UniqueBranchGenerator build() throws Exception {

    Git git;

    File workDirTarget = new File(repo.getDirectory().getAbsolutePath() + "/../../" + UUID.randomUUID().toString());
    System.out.println(workDirTarget.getAbsolutePath());

    Git.cloneRepository()
            .setURI("file://" + repo.getDirectory().getAbsolutePath())
            .setBare(false)
            .setNoCheckout(false)
            .setCloneAllBranches(true)
            .setDirectory(workDirTarget).call().close();

    File gitMetaDir = new File(workDirTarget.getAbsolutePath() + System.getProperty("file.separator") + ".git");
    System.out.println("Setting .git metadata to work in directory: " + gitMetaDir.getAbsolutePath());

    git = Git.open(gitMetaDir);

    CreateBranchCommand createBranchCommand = git.branchCreate();
    createBranchCommand.setName(branchName);
    createBranchCommand.call();
    git.checkout().setName(branchName).call();

    File repoRoot = git.getRepository().getWorkTree();
    UUID rand = UUID.randomUUID();
    File randomFile = new File(repoRoot, rand.toString() + ".log");
    randomFile.createNewFile();
    git.add().addFilepattern(".").call();

    int cnt = 0;
    for (String msg : commitMessages) {
        FileUtils.writeStringToFile(randomFile, rand.toString() + "-" + cnt + "\n", true);
        CommitCommand commitCommand = git.commit();
        commitCommand.setMessage(msg);
        commitCommand.setAuthor(AUTHOR_NAME, AUTHOR_EMAIL);
        commitCommand.call();
        cnt++;
    }

    git.push().setPushAll().call();
    git.checkout().setName("master");
    git.close();

    FileUtils.deleteDirectory(workDirTarget);
    return this;
}
 
开发者ID:Praqma,项目名称:pretested-integration-plugin,代码行数:54,代码来源:UniqueBranchGenerator.java

示例8: createValidRepository

import org.eclipse.jgit.api.CreateBranchCommand; //导入方法依赖的package包/类
public static Repository createValidRepository(String repoFolderName) throws IOException, GitAPIException {
    File repo = new File(WORKDIR,repoFolderName + ".git"); // bare repo should have suffix .git, and contain what normally in .git

    if (repo.exists()) {
        System.out.format("EXIST:" + repo.getAbsolutePath());
        try {
            TestUtilsFactory.destroyDirectory(repo);
        } catch (InterruptedException e) {
            throw new IOException(e);
        }
    }

    File workDirForRepo = new File(WORKDIR, repoFolderName);
    Repository repository = new FileRepository(repo);
    repository.create(true);

    Git.cloneRepository().setURI("file:///" + repo.getAbsolutePath()).setDirectory(workDirForRepo)
            .setBare(false)
            .setCloneAllBranches(true)
            .setNoCheckout(false)
            .call().close();

    Git git = Git.open(workDirForRepo);

    String FEATURE_BRANCH_NAME = "ready/feature_1";

    File readme = new File(workDirForRepo + "/readme");
    if (!readme.exists()) {
        FileUtils.writeStringToFile(readme, "sample text\n");
    }

    git.add().addFilepattern(readme.getName()).call();
    git.commit().setMessage(TestUtilsFactory.createCommitMessageForRepo(repoFolderName, git.getRepository().getBranch(), "commit message 1")).call();

    FileUtils.writeStringToFile(readme, "changed sample text\n");

    git.add().addFilepattern(readme.getName()).call();
    git.commit().setMessage(TestUtilsFactory.createCommitMessageForRepo(repoFolderName, git.getRepository().getBranch(), "commit message 2")).call();

    CreateBranchCommand createBranchCommand = git.branchCreate();
    createBranchCommand.setName(FEATURE_BRANCH_NAME);
    createBranchCommand.call();

    git.checkout().setName(FEATURE_BRANCH_NAME).call();

    FileUtils.writeStringToFile(readme, "FEATURE_1 branch commit 1\n", true);

    git.add().addFilepattern(readme.getName()).call();
    CommitCommand commitCommand = git.commit();
    commitCommand.setMessage(TestUtilsFactory.createCommitMessageForRepo(repoFolderName, git.getRepository().getBranch(), "feature 1 commit 1"));
    commitCommand.setAuthor(AUTHOR_NAME, AUTHOR_EMAIL);
    commitCommand.call();

    FileUtils.writeStringToFile(readme, "FEATURE_1 branch commit 2\n", true);

    git.add().addFilepattern(readme.getName()).call();
    commitCommand = git.commit();
    commitCommand.setMessage(TestUtilsFactory.createCommitMessageForRepo(repoFolderName, git.getRepository().getBranch(), "feature 1 commit 2"));
    commitCommand.setAuthor(AUTHOR_NAME, AUTHOR_EMAIL);
    commitCommand.call();

    git.push().setPushAll().call();

    git.checkout().setName("master").call();

    FileUtils.deleteDirectory(workDirForRepo);
    return repository;
}
 
开发者ID:Praqma,项目名称:pretested-integration-plugin,代码行数:69,代码来源:TestUtilsFactory.java

示例9: createRepositoryWithMergeConflict

import org.eclipse.jgit.api.CreateBranchCommand; //导入方法依赖的package包/类
public static Repository createRepositoryWithMergeConflict(String repoFolderName) throws IOException, GitAPIException {
    String FEATURE_BRANCH_NAME = "ready/feature_1";

    File repo = new File(WORKDIR,repoFolderName + ".git"); // bare repo should have suffix .git, and contain what normally in .git
    File workDirForRepo = new File(WORKDIR, repoFolderName);
    Repository repository = new FileRepository(repo);
    repository.create(true);

    Git.cloneRepository().setURI("file:///" + repo.getAbsolutePath()).setDirectory(workDirForRepo)
            .setBare(false)
            .setCloneAllBranches(true)
            .setNoCheckout(false)
            .call().close();

    Git git = Git.open(workDirForRepo);

    File readme = new File(workDirForRepo + "/readme");
    if (!readme.exists()) {
        FileUtils.writeStringToFile(readme, "sample text\n");
    }

    git.add().addFilepattern(readme.getName()).call();
    git.commit().setMessage("commit message 1").call();

    FileUtils.writeStringToFile(readme, "changed sample text\n");

    git.add().addFilepattern(readme.getName()).call();
    git.commit().setMessage("commit message 2").call();

    CreateBranchCommand createBranchCommand = git.branchCreate();
    createBranchCommand.setName(FEATURE_BRANCH_NAME);
    createBranchCommand.call();

    git.checkout().setName(FEATURE_BRANCH_NAME).call();

    FileUtils.writeStringToFile(readme, "FEATURE_1 branch commit 1\n");

    git.add().addFilepattern(readme.getName()).call();
    CommitCommand commitCommand = git.commit();
    commitCommand.setMessage("feature 1 commit 1");
    commitCommand.setAuthor(AUTHOR_NAME, AUTHOR_EMAIL);
    commitCommand.call();

    FileUtils.writeStringToFile(readme, "FEATURE_1 branch commit 2\n");

    git.add().addFilepattern(readme.getName()).call();
    commitCommand = git.commit();
    commitCommand.setMessage("feature 1 commit 2");
    commitCommand.setAuthor(AUTHOR_NAME, AUTHOR_EMAIL);
    commitCommand.call();

    git.checkout().setName("master").call();

    FileUtils.writeStringToFile(readme, "Merge conflict branch commit 2\n");

    git.add().addFilepattern(readme.getName()).call();
    commitCommand = git.commit();
    commitCommand.setMessage("merge conflict message 1");
    commitCommand.setAuthor(AUTHOR_NAME, AUTHOR_EMAIL);
    commitCommand.call();

    git.push().setPushAll().call();

    FileUtils.deleteDirectory(workDirForRepo);

    return repository;
}
 
开发者ID:Praqma,项目名称:pretested-integration-plugin,代码行数:68,代码来源:TestUtilsFactory.java

示例10: createRepository

import org.eclipse.jgit.api.CreateBranchCommand; //导入方法依赖的package包/类
private void createRepository() throws IOException, GitAPIException {
    File repo = new File(TestUtilsFactory.WORKDIR,"EnvVar - " + UUID.randomUUID().toString().substring(0, 6) + "/.git");
    if (repo.getAbsoluteFile().exists()) {
        FileUtils.deleteDirectory(repo.getParentFile());
    }

    FileRepositoryBuilder builder = new FileRepositoryBuilder();

    repository = builder.setGitDir(repo.getAbsoluteFile())
            .readEnvironment() // scan environment GIT_* variables
            .findGitDir() // scan up the file system tree
            .build();

    if (!repository.isBare() && repository.getBranch() == null) {
        repository.create();
    }

    Git git = new Git(repository);

    File readme = new File(repository.getDirectory().getParent().concat("/" + "readme"));
    FileUtils.writeStringToFile(readme, "commit 1\n");
    git.add().addFilepattern(readme.getName()).call();
    git.commit().setMessage("commit message 1").call();

    CreateBranchCommand createBranchCommand = git.branchCreate();
    createBranchCommand.setName(INTEGRATION_BRANCH);
    createBranchCommand.call();

    createBranchCommand = git.branchCreate();
    createBranchCommand.setName(READY_BRANCH);
    createBranchCommand.call();

    CheckoutCommand checkout = git.checkout();
    checkout.setName(READY_BRANCH);
    checkout.call();

    FileUtils.writeStringToFile(readme, "commit 2\n");
    git.add().addFilepattern(readme.getName()).call();
    git.commit().setMessage("commit message 2").call();

    checkout = git.checkout();
    checkout.setName(INTEGRATION_BRANCH);
    checkout.call();

    DeleteBranchCommand deleteBranchCommand = git.branchDelete();
    deleteBranchCommand.setBranchNames("master");
    deleteBranchCommand.call();

    REPOSITORY = repository.getDirectory().getAbsolutePath();
}
 
开发者ID:Praqma,项目名称:pretested-integration-plugin,代码行数:51,代码来源:EnvVarsIT.java


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