Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.CommitCommand


     *
     * @param identification The person identification
     * @param message the commit message
     */
    public void commit(PersonIdent identification, String message) {
        CommitCommand commit = git.commit();
        commit.setAuthor(identification);
        commit.setCommitter(identification);
        commit.setMessage(message);
        try {
            commit.call();
        } catch (NoHeadException e) {
            throw new IllegalStateException("Unable to commit into Git repository", e);
        } catch (NoMessageException e) {
            throw new IllegalStateException("Unable to commit into Git repository", e);
        } catch (ConcurrentRefUpdateException e) {
View Full Code Here


        File gitAttributes = new File(rootFolder, ".gitattributes");
        if (!gitAttributes.exists()) {
            try {
                IOHelper.write(gitAttributes, getDefaultGitAttributes());
                git.add().addFilepattern(".gitattributes").call();
                CommitCommand commit = git.commit().setAll(true).setAuthor(personIdent).setMessage("Added default .gitattributes");
                try {
                    commitThenPush(git, branch, commit);
                } catch (Exception e) {
                    LOG.warn("Failed to commit initial .gitattributes. " + e, e);
                }
            } catch (Exception e) {
                LOG.warn("Failed to write git " + gitAttributes + ". " + e, e);
            }
        }
        System.out.println("Importing initial URLs: " + initialImportURLs);
        if (Strings.isNotBlank(initialImportURLs)) {
            String[] split = initialImportURLs.split(",");
            if (split != null) {
                for (String importURL : split) {
                    if (Strings.isNotBlank(importURL)) {
                        InputStream inputStream = null;
                        try {
                            inputStream = ConfigFacade.getSingleton().openURL(importURL);
                        } catch (IOException e) {
                            LOG.warn("Could not load initial import URL: " + importURL + ". " + e, e);
                            return;
                        }
                        if (inputStream == null) {
                            LOG.warn("Could not load initial import URL: " + importURL);
                            return;
                        }

                        try {
                            Zips.unzip(inputStream, rootFolder);
                        } catch (IOException e) {
                            LOG.warn("Failed to unzip initial import URL: " + importURL + ". " + e, e);
                        }
                    }
                }
            }
        }

        // now lets add any expanded stuff to git
        int count = 0;
        File[] files = rootFolder.listFiles();
        if (files != null) {
            for (File file : files) {
                String name = file.getName();
                if (!Objects.equals(".git", name) && !Objects.equals(".gitattributes", name)) {
                    try {
                        count += addFiles(git, rootFolder, file);
                    } catch (Exception e) {
                        LOG.warn("Failed to add file " + name + ". " + e, e);
                    }
                }
            }
        }

        // commit any changes
        if (count > 0) {
            CommitCommand commit = git.commit().setAll(true).setAuthor(personIdent).setMessage("Added import URLs: " + initialImportURLs);
            try {
                commitThenPush(git, branch, commit);
            } catch (Exception e) {
                LOG.warn("Failed to commit initial import of " + initialImportURLs + ". " + e, e);
            }
View Full Code Here

        file.mkdirs();
        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, branch, commit);
        return createCommitInfo(revCommit);
    }
View Full Code Here

                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(commitMessage);
            return commitThenPush(git, branch, commit);
        } else {
            return null;
        }
    }
View Full Code Here

        if (file.exists()) {
            Files.recursiveDelete(file);

            String filePattern = getFilePattern(path);
            git.rm().addFilepattern(filePattern).call();
            CommitCommand commit = git.commit().setAll(true).setAuthor(personIdent).setMessage(commitMessage);
            return commitThenPush(git, branch, commit);
        } else {
            return null;
        }
    }
View Full Code Here

            PersonIdent author = context.getAuthor();
            String message = context.getMessage();
            if (Strings.isBlank(message)) {
                message = "Updated " + Files.getRelativePath(rootDir, file);
            }
            CommitCommand command = git.commit().setAll(true).setMessage(message);
            if (author != null) {
                command = command.setAuthor(author);
            }
            RevCommit revCommit = commitThenPush(git, branch, command);
            createCommitInfo(revCommit);
        }
        return results;
View Full Code Here

        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, branch, commit);
        return createCommitInfo(revCommit);
    }
View Full Code Here

      add.addFilepattern(file);
    }
    add.call();

    // execute the commit
    CommitCommand commit = git.commit();
    commit.setMessage(message);
    RevCommit revCommit = commit.call();

    if (!StringUtils.isEmpty(tagName) && !StringUtils.isEmpty(tagMessage)) {
      // tag the commit
      TagCommand tagCommand = git.tag();
      tagCommand.setName(tagName);
View Full Code Here

            // MOXIE_HOME relative dependencies in .iml
            add.addFilepattern("*.iml");
        }
      try {
        add.call();
        CommitCommand commit = git.commit();
        PersonIdent moxie = new PersonIdent("Moxie", "moxie@localhost");
        commit.setAuthor(moxie);
        commit.setCommitter(moxie);
        commit.setMessage("Project structure created");
        commit.call();
      } catch (Exception e) {
        throw new MoxieException(e);
      }
    }
View Full Code Here

     *
     * @param identification The person identification
     * @param message the commit message
     */
    public void commit(PersonIdent identification, String message) {
        CommitCommand commit = git.commit();
        commit.setAuthor(identification);
        commit.setCommitter(identification);
        commit.setMessage(message);
        try {
            commit.call();
        } catch (NoHeadException e) {
            throw new IllegalStateException("Unable to commit into Git repository", e);
        } catch (NoMessageException e) {
            throw new IllegalStateException("Unable to commit into Git repository", e);
        } catch (UnmergedPathException e) {
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.api.CommitCommand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.