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


Java CommitCommand.setAuthor方法代码示例

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


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

示例1: doCommitAndPush

import org.eclipse.jgit.api.CommitCommand; //导入方法依赖的package包/类
public static RevCommit doCommitAndPush(Git git, String message, UserDetails userDetails, PersonIdent author, String branch, String origin, boolean pushOnCommit) throws GitAPIException {
    CommitCommand commit = git.commit().setAll(true).setMessage(message);
    if (author != null) {
        commit = commit.setAuthor(author);
    }

    RevCommit answer = commit.call();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Committed " + answer.getId() + " " + answer.getFullMessage());
    }

    if (pushOnCommit) {
        PushCommand push = git.push();
        configureCommand(push, userDetails);
        Iterable<PushResult> results = push.setRemote(origin).call();
        for (PushResult result : results) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Pushed " + result.getMessages() + " " + result.getURI() + " branch: " + branch + " updates: " + toString(result.getRemoteUpdates()));
            }
        }
    }
    return answer;
}
 
开发者ID:fabric8io,项目名称:fabric8-devops,代码行数:24,代码来源:GitHelpers.java

示例2: commit

import org.eclipse.jgit.api.CommitCommand; //导入方法依赖的package包/类
protected void commit(String comment) {
	CommitCommand ci = git.commit();
	ci.setMessage(comment);
	ci.setAuthor(user);
	ci.setCommitter(user);
	try {
		ci.call();
	} catch (GitAPIException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:12,代码来源:AbstractGitTest.java

示例3: commit

import org.eclipse.jgit.api.CommitCommand; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void commit(String message) throws GitException {
    try (Repository repo = getRepository()) {
        CommitCommand cmd = git(repo).commit().setMessage(message);
        if (author!=null)
            cmd.setAuthor(author);
        if (committer!=null)
            cmd.setCommitter(new PersonIdent(committer,new Date()));
        cmd.call();
    } catch (GitAPIException e) {
        throw new GitException(e);
    }
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:14,代码来源:JGitAPIImpl.java

示例4: commit

import org.eclipse.jgit.api.CommitCommand; //导入方法依赖的package包/类
public static void commit(Repo repo, boolean stageAll, boolean isAmend,
        String msg, String authorName, String authorEmail) throws Exception, NoHeadException, NoMessageException,
        UnmergedPathsException, ConcurrentRefUpdateException,
        WrongRepositoryStateException, GitAPIException, StopTaskException {
    Context context = SGitApplication.getContext();
    StoredConfig config = repo.getGit().getRepository().getConfig();
    String committerEmail = config.getString("user", null, "email");
    String committerName = config.getString("user", null, "name");

    if (committerName == null || committerName.equals("")) {
        committerName = Profile.getUsername(context);
    }
    if (committerEmail == null || committerEmail.equals("")) {
        committerEmail = Profile.getEmail(context);
    }
    if (committerName.isEmpty() || committerEmail.isEmpty()) {
        throw new Exception("Please set your name and email");
    }
    if (msg.isEmpty()) {
        throw new Exception("Please include a commit message");
    }
    CommitCommand cc = repo.getGit().commit()
            .setCommitter(committerName, committerEmail).setAll(stageAll)
            .setAmend(isAmend).setMessage(msg);
    if (authorName != null && authorEmail != null) {
        cc.setAuthor(authorName, authorEmail);
    }
    cc.call();
    repo.updateLatestCommitInfo();
}
 
开发者ID:sheimi,项目名称:SGit,代码行数:31,代码来源:CommitChangesTask.java

示例5: build

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

示例6: createRepoWithoutBranches

import org.eclipse.jgit.api.CommitCommand; //导入方法依赖的package包/类
/**
 * Creates a bare git repository with initial commit and a 'readme.md' file
 * containing one line. Author and email is set on commit.
 *
 * @param repoFolderName
 * @return
 * @throws IOException
 * @throws GitAPIException
 */
public static Repository createRepoWithoutBranches(String repoFolderName) throws IOException, GitAPIException {
    //'git init --bare test.git' :
    //Initialized empty Git repository in /home/bue/gitlab-repos/pretested-integration-plugin/test.git/
    //'ls -al test.git/' :
    //total 40
    //drwxrwxr-x  7 doe usr 4096 dec 11 00:23 .
    //drwxrwxr-x 12 doe usr 4096 dec 11 00:23 ..
    //drwxrwxr-x  2 doe usr 4096 dec 11 00:23 branches
    //-rw-rw-r--  1 doe usr   66 dec 11 00:23 config
    //-rw-rw-r--  1 doe usr   73 dec 11 00:23 description
    //-rw-rw-r--  1 doe usr   23 dec 11 00:23 HEAD
    //drwxrwxr-x  2 doe usr 4096 dec 11 00:23 hooks
    //drwxrwxr-x  2 doe usr 4096 dec 11 00:23 info
    //drwxrwxr-x  4 doe usr 4096 dec 11 00:23 objects
    //drwxrwxr-x  4 doe usr 4096 dec 11 00:23 refs
    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);

    System.out.format(workDirForRepo.getAbsolutePath());

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

    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.md");
    if (!readme.exists()) {
        FileUtils.writeStringToFile(readme, "#My first repository");
    }

    git.add().addFilepattern(".");
    CommitCommand commit = git.commit();
    commit.setMessage(TestUtilsFactory.createCommitMessageForRepo(repoFolderName, repository.getBranch(), "Initial commit"));
    commit.setAuthor(AUTHOR_NAME, AUTHOR_EMAIL);
    commit.call();

    git.push().setPushAll().setRemote("origin").call();

    git.close();

    FileUtils.deleteDirectory(workDirForRepo);

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

示例7: createValidRepository

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

示例8: createRepositoryWithMergeConflict

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


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