• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CommitCommand类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: doRename

import org.eclipse.jgit.api.CommitCommand; //导入依赖的package包/类
protected CommitInfo doRename(Git git, String oldPath, String newPath) throws Exception {
    File file = getRelativeFile(oldPath);
    File newFile = getRelativeFile(newPath);
    if (file.exists()) {
        File parentFile = newFile.getParentFile();
        parentFile.mkdirs();
        if (!parentFile.exists()) {
            throw new IOException("Could not create directory " + parentFile + " when trying to move " + file + " to " + newFile + ". Maybe a file permission issue?");
        }
        file.renameTo(newFile);
        String filePattern = getFilePattern(newPath);
        git.add().addFilepattern(filePattern).call();
        CommitCommand commit = git.commit().setAll(true).setAuthor(personIdent).setMessage(message);
        return createCommitInfo(commitThenPush(git, commit));
    } else {
        return null;
    }
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:19,代码来源:RepositoryResource.java


示例2: doRemove

import org.eclipse.jgit.api.CommitCommand; //导入依赖的package包/类
protected CommitInfo doRemove(Git git, List<String> paths) throws Exception {
    if (paths != null && paths.size() > 0) {
        int count = 0;
        for (String path : paths) {
            File file = getRelativeFile(path);
            if (file.exists()) {
                count++;
                Files.recursiveDelete(file);
                String filePattern = getFilePattern(path);
                git.rm().addFilepattern(filePattern).call();
            }
        }
        if (count > 0) {
            CommitCommand commit = git.commit().setAll(true).setAuthor(personIdent).setMessage(message);
            return createCommitInfo(commitThenPush(git, commit));
        }
    }
    return null;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:20,代码来源:RepositoryResource.java


示例3: writeFileAndCommitWithAuthor

import org.eclipse.jgit.api.CommitCommand; //导入依赖的package包/类
private RevCommit writeFileAndCommitWithAuthor(Git git, String authorName, String email, String fileName, String commitMessage,
                                               String... lines) throws IOException, GitAPIException {
    StringBuilder sb = new StringBuilder();
    for (String line : lines) {
        sb.append(line);
        sb.append('\n');
    }
    writeTrashFile(fileName, sb.toString());
    git.add().addFilepattern(fileName).call();

    CommitCommand commitCommand = git.commit().setMessage(commitMessage);

    if (authorName != null && email != null) {
        return commitCommand.setAuthor(authorName, email).call();
    } else {
        return commitCommand.call();
    }
}
 
开发者ID:Coding,项目名称:WebIDE-Backend,代码行数:19,代码来源:GitManagerTest.java


示例4: addAndCommitSelectedFiles

import org.eclipse.jgit.api.CommitCommand; //导入依赖的package包/类
/**
 * Adds the files that were selected and commits them. Note: the {@link AddCommand}
 * and {@link CommitCommand} are used in this method. {@link AddCommand#setWorkingTreeIterator(WorkingTreeIterator)}
 * can be configured fia {@link #setWorkingTreeIterator(WorkingTreeIterator)} before calling this method,
 * and the {@code CommitCommand} can be configured via {@link #configureCommitCommand(CommitCommand)}.
 * @return the result of {@link #createResult(DirCache, RevCommit, List)} or null if
 *         a {@link GitAPIException} is thrown.
 */
protected final R addAndCommitSelectedFiles() {
    List<String> selectedFiles = getDialogPane().getSelectedFiles();
    try {
        AddCommand add = getGitOrThrow().add();
        selectedFiles.forEach(add::addFilepattern);
        workingTreeIterator.ifPresent(add::setWorkingTreeIterator);
        DirCache cache = add.call();

        CommitCommand commit = getGitOrThrow().commit();
        configureCommitCommand(commit);
        RevCommit revCommit = commit.call();

        return createResult(cache, revCommit, selectedFiles);
    } catch (GitAPIException e) {
        handleGitAPIException(e);
        return null;
    }
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:27,代码来源:CommitDialogBase.java


示例5: 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


示例6: commit

import org.eclipse.jgit.api.CommitCommand; //导入依赖的package包/类
@Override
public String commit(String author, String email, String message) {
    
    RevCommit revCommit = null;
    CommitCommand command = _git.commit();
    command.setCommitter(author, email);
    command.setMessage(message);
    command.setAll(true);
    try {
        revCommit = command.call();
    } catch (Throwable e) {
        throw new RuntimeException("Failed to commit", e);
    }
    
    return revCommit.getId().getName();
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:17,代码来源:JGitOperator.java


示例7: AccumuloConfigurations

import org.eclipse.jgit.api.CommitCommand; //导入依赖的package包/类
public AccumuloConfigurations(Configuration config) throws Exception {
	Preconditions.checkNotNull(config, "Configuration must be supplied");
	gitDir = new File(config.getDataDir()+"/git");
	LOG.debug("Creating Git repository at {}", gitDir);
	if (!gitDir.exists()) {
		if (!gitDir.mkdir()) {
			throw new IOException("Error creating directory: "+gitDir.getAbsolutePath());
		}
		InitCommand initCommand = Git.init();
		initCommand.setBare(false);
		initCommand.setDirectory(gitDir);
		git = initCommand.call();
		CommitCommand commit = git.commit();
		commit.setMessage("Initial commit").call();
		repo = git.getRepository();
	} else {
		git = Git.open(gitDir);
		repo = git.getRepository();			
	}
	LOG.info("Accumulo configuration store initialized");
}
 
开发者ID:dlmarion,项目名称:raccovery,代码行数:22,代码来源:AccumuloConfigurations.java


示例8: createGitRepoWithPom

import org.eclipse.jgit.api.CommitCommand; //导入依赖的package包/类
public static String createGitRepoWithPom(final File path, final InputStream pom, final File... files) throws Exception {
    File repo = new File(path, "repo");
    if(repo.exists() == false) {
        Files.createDirectory(repo.toPath());
    }
    Git git = Git.init().setDirectory(repo).call();
    String gitUrl = "file://" + repo.getAbsolutePath();

    FileUtils.copyInputStreamToFile(pom, new File(repo, "pom.xml"));
    AddCommand add = git.add();
    add.addFilepattern("pom.xml");
    for (File f : files) {
        add.addFilepattern(f.getName());
    }
    add.call();
    CommitCommand commit = git.commit();
    commit.setMessage("initial commit").call();
    return gitUrl;
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:20,代码来源:MavenTestUtils.java


示例9: addAllAndCommit

import org.eclipse.jgit.api.CommitCommand; //导入依赖的package包/类
static void addAllAndCommit(Git git, UserProfile user, String commitMsg) throws GitAPIException {
    AddCommand addCommand = git.add()
        .addFilepattern(".")
        .addFilepattern("application.json");

    CommitCommand commitCmd = git.commit();

    if (user != null && user.name() != null && user.email() != null) {
        commitCmd.setCommitter(user.name(), user.email());
    }
    if (commitMsg != null) {
        commitCmd.setMessage(commitMsg);
    }

    GitHandler.commit(() -> {
        addCommand.call();
        return commitCmd.call();
    });
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:20,代码来源:GitHelper.java


示例10: 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


示例11: doCreateDirectory

import org.eclipse.jgit.api.CommitCommand; //导入依赖的package包/类
protected CommitInfo doCreateDirectory(Git git, String path) throws Exception {
    File file = getRelativeFile(path);
    if (file.exists()) {
        return null;
    }
    file.mkdirs();
    String filePattern = getFilePattern(path);
    AddCommand add = git.add().addFilepattern(filePattern).addFilepattern(".");
    add.call();

    CommitCommand commit = git.commit().setAll(true).setAuthor(personIdent).setMessage(message);
    RevCommit revCommit = commitThenPush(git, commit);
    return createCommitInfo(revCommit);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:15,代码来源:RepositoryResource.java


示例12: doWrite

import org.eclipse.jgit.api.CommitCommand; //导入依赖的package包/类
protected CommitInfo doWrite(Git git, String path, byte[] contents, PersonIdent personIdent, String commitMessage) throws Exception {
    File file = getRelativeFile(path);
    file.getParentFile().mkdirs();

    Files.writeToFile(file, contents);

    String filePattern = getFilePattern(path);
    AddCommand add = git.add().addFilepattern(filePattern).addFilepattern(".");
    add.call();

    CommitCommand commit = git.commit().setAll(true).setAuthor(personIdent).setMessage(commitMessage);
    RevCommit revCommit = commitThenPush(git, commit);
    return createCommitInfo(revCommit);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:15,代码来源:RepositoryResource.java


示例13: commitThenPush

import org.eclipse.jgit.api.CommitCommand; //导入依赖的package包/类
protected RevCommit commitThenPush(Git git, CommitCommand commit) throws Exception {
    RevCommit answer = commit.call();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Committed " + answer.getId() + " " + answer.getFullMessage());
    }
    if (isPushOnCommit()) {
        Iterable<PushResult> results = doPush(git);
        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-forge,代码行数:16,代码来源:RepositoryResource.java


示例14: dumpConfiguration

import org.eclipse.jgit.api.CommitCommand; //导入依赖的package包/类
public void dumpConfiguration(Configuration config, Entry e) throws Exception {
	Preconditions.checkNotNull(config, "Configuration must be supplied.");
	Preconditions.checkNotNull(e, "Entry must be supplied.");
	AddCommand add = git.add();
	CommitCommand commit = git.commit();
	try {
		//Dump Zookeeper
		String instanceId = config.getConnector().getInstance().getInstanceID();
		String zkPath = Constants.ZROOT + "/" + instanceId;
		File zkDump = new File(gitDir, ZK_DUMP_FILE);
		LOG.debug("Dump ZooKeeper configuration at {} to {}", zkPath, zkDump);
		FileOutputStream out = new FileOutputStream(zkDump);
		DumpZookeeper.run(out, zkPath);
		out.close();
		//Dump the configuration
		LOG.debug("Dumping Accumulo configuration to {}", gitDir);
		DumpConfigCommand command = new DumpConfigCommand();
		command.allConfiguration = true;
		command.directory = gitDir.getAbsolutePath();
		Instance instance = config.getConnector().getInstance();
		String principal = config.getUsername();
		PasswordToken token = new PasswordToken(config.getPassword().getBytes());
		Admin.printConfig(instance, principal, token, command);
		//Add, commit, and tag
		add.addFilepattern(".").call();
		commit.setMessage("Backup " + e.getUUID().toString()).call();
		git.tag().setName(e.getUUID().toString()).call();
		LOG.debug("Git tag {} created.", e.getUUID());
		//Should we remove all of the files from the existing git workspace?
	} catch (Exception ex) {
		LOG.error("Error saving configuration", ex);
		git.reset().setMode(ResetType.HARD).setRef("HEAD").call();
		throw ex;
	}
}
 
开发者ID:dlmarion,项目名称:raccovery,代码行数:36,代码来源:AccumuloConfigurations.java


示例15: commit

import org.eclipse.jgit.api.CommitCommand; //导入依赖的package包/类
RevCommit commit(String message) {
    try {
        CommitCommand commitCmd = git.commit().setAll(true).setMessage(message).setCommitter(getDefaultCommiter());
        return commitCmd.call();
    } catch (GitAPIException ex) {
        throw new IllegalStateException("Cannot commit: " + message, ex);
    }
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:9,代码来源:ProfileRegistry.java


示例16: call

import org.eclipse.jgit.api.CommitCommand; //导入依赖的package包/类
public Git call(final GitOperationsStep gitOperationsStep, Git git,
    CredentialsProvider cp, String gitRepoUrl, File gitRepoFolder)
    throws IllegalArgumentException, IOException, NoHeadException,
    NoMessageException, UnmergedPathsException,
    ConcurrentRefUpdateException, WrongRepositoryStateException,
    GitAPIException {
  CommitCommand cc = git
      .commit()
      .setAuthor(
          gitOperationsStep
              .environmentSubstitute(this.authorName == null ? ""
                  : this.authorName),
          gitOperationsStep
              .environmentSubstitute(this.authorEmail == null ? ""
                  : this.authorEmail))
      .setCommitter(
          gitOperationsStep
              .environmentSubstitute(this.committerName == null ? ""
                  : this.committerName),
          gitOperationsStep
              .environmentSubstitute(this.committerEmail == null ? ""
                  : this.committerName));

  if (!Const.isEmpty(this.commitMessage)) {
    cc = cc.setMessage(gitOperationsStep
        .environmentSubstitute(this.commitMessage));
  }
  cc.setAll(all).setInsertChangeId(insertChangeId).setAmend(amend).call();
  return git;
}
 
开发者ID:ivylabs,项目名称:ivy-pdi-git-steps,代码行数:31,代码来源:CommitGitCommand.java


示例17: createMember

import org.eclipse.jgit.api.CommitCommand; //导入依赖的package包/类
@Override
public void createMember(RequestContext ctx, ResourceState state, Responder responder) throws Exception {
    String commitMsg = state.getPropertyAsString("msg");
    Boolean includeUntracked = state.getPropertyAsBoolean("include-untracked");

    if (includeUntracked == null) {
        // Default to include all untracked files
        includeUntracked = Boolean.TRUE;
    }

    // Add changed files to staging ready for commit
    AddCommand addCmd = parent.git().add().addFilepattern(".");

    if (!includeUntracked) {
        // This will prevent new files from being added to the index, and therefore the commit
        addCmd.setUpdate(true);
    }

    // Commit staged changes
    RevCommit commit;
    CommitCommand commitCmd = parent.git().commit();

    if (ctx.securityContext() != null) {
        UserProfile user = ctx.securityContext().getUser();
        if (user != null && user.name() != null && user.email() != null) {
            commitCmd.setCommitter(user.name(), user.email());
        }
    }

    if (commitMsg != null) {
        commitCmd.setMessage(commitMsg);
    }

    commit = GitHandler.commit(() -> {
        addCmd.call();
        return commitCmd.call();
    });

    responder.resourceCreated(new GitCommitResource(this, commit));
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:41,代码来源:CommitsResource.java


示例18: 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


示例19: commitAll

import org.eclipse.jgit.api.CommitCommand; //导入依赖的package包/类
/**
 * Commit all.
 *
 * @param msg the msg
 * @throws GitAPIException the git api exception
 */
public void commitAll(String msg) throws GitAPIException {
	CommitCommand command = git.commit().setMessage(msg).setAll(true);
	RevCommit result = command.call();
	String message=result.getFullMessage();
	if (message.length()>0){
		Notification.show("Commit ok, message: " + message);			
	}else{
		Notification.show("Commit ok, no commit message :( ?");
	}	
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:17,代码来源:GitRepository.java


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultMuleMessage类代码示例发布时间:2022-05-21
下一篇:
Java Xpp3DomBuilder类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap