Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.AddCommand


                }
            }

            if (!status.isClean())
            {
                AddCommand add = git.add();

                MavenProject rootProject = ReleaseUtil.getRootProject(reactorProjects);
//                File rootBaseDir = rootProject.getBasedir();
                for (MavenProject project : reactorProjects)
                {
                    String pomPath = relativePath(canonicalRepoDir, project.getFile());

                    if (getLogger().isDebugEnabled())
                    {
                        getLogger().debug("(" + fullBranchName + ") adding file pattern for poms commit: " + pomPath);
                    }

                    if (isWindows)
                    {
                        pomPath = StringUtils.replace(pomPath, "\\", "/");
                    }

                    add.addFilepattern(pomPath);
                }
                add.call();
                git.commit().setMessage(message).call();
            }
        }
        catch (GitAPIException e)
        {
View Full Code Here


    // Asks for Existing Files to get added
    git.add().setUpdate(true).addFilepattern(".").call();

    // Now as for any new files (untracked)

    AddCommand addCommand = git.add();

    if (!status.getUntracked().isEmpty()) {
      for (String s : status.getUntracked()) {
        getLog().info("Adding file " + s);
        addCommand.addFilepattern(s);
      }

      addCommand.call();
    }

    git.commit().setAll(true).setMessage(versionDescription).call();

    String commitId = ObjectId.toString(git.getRepository()
View Full Code Here

     *
     * @param filePattern the file pattern
     */
    public void add(String filePattern) {

        AddCommand add = git.add();
        DirCache cache;
        try {
            cache = add.addFilepattern(filePattern).call();
            updateCache(cache);
        } catch (NoFilepatternException e) {
            throw new IllegalStateException("Unable to add file to the Git cache", e);
        } catch (IOException e) {
            throw new IllegalStateException("Unable to add file to the Git cache", e);
View Full Code Here

    if (null != masterRef)
      commitId = ObjectId.toString(masterRef.getObjectId());

    Status status = gitRepo.status().call();

    AddCommand addCommand = gitRepo.add();

    if (!status.getUntracked().isEmpty()) {
      for (String s : status.getUntracked()) {
        log("Adding file %s", s);
        addCommand.addFilepattern(s);
      }

      addCommand.call();
    }

    log("Committing");

    try {
View Full Code Here

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

        file.getParentFile().mkdirs();

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

     * Adds the given file to git
     */
    public void addFile(File file) throws IOException, GitAPIException {
        String path = Files.getRelativePath(rootDir, file);
        String filePattern = getFilePattern(path);
        AddCommand add = git.add().addFilepattern(filePattern).addFilepattern(".");
        add.call();
        requiresCommit = true;
    }
View Full Code Here

  }

  public static String commitFiles(File dir, List<String> files, String message,
      String tagName, String tagMessage) throws IOException, GitAPIException {
    Git git = Git.open(dir);
    AddCommand add = git.add();
    for (String file : files) {
      add.addFilepattern(file);
    }
    add.call();

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

        // ignore hard-coded .classpath
        sb.append("/.classpath\n")
      }
      FileUtils.writeContent(new File(newProject.dir, ".gitignore"), sb.toString());
     
      AddCommand add = git.add();
      add.addFilepattern("build.xml");
      add.addFilepattern("build.moxie");
      add.addFilepattern(".gitignore");
      if (newProject.eclipse.includeProject()) {
        add.addFilepattern(".project")
      }
      if (newProject.eclipse.includeClasspath()) {
        // MOXIE_HOME relative dependencies in .classpath
        add.addFilepattern(".classpath")
      }
        if (newProject.idea.includeProject()) {
            add.addFilepattern(".project");
        }
        if (newProject.idea.includeClasspath()) {
            // 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");
View Full Code Here

            Status status = git.status().call();
            Repository repository = git.getRepository();
            File repoDir = repository.getDirectory().getParentFile();
            if (!status.isClean())
            {
                AddCommand add = git.add();

                MavenProject rootProject = ReleaseUtil.getRootProject(reactorProjects);
//                File rootBaseDir = rootProject.getBasedir();
                for (MavenProject project : reactorProjects)
                {
                    String pomPath = relativePath(repoDir, project.getFile());

                    if (getLogger().isDebugEnabled())
                    {
                        getLogger().debug("adding file pattern for poms commit: " + pomPath);
                    }
                   
                    if(isWindows)
                    {
                        pomPath = StringUtils.replace(pomPath,"\\","/");   
                    }
                   
                    add.addFilepattern(pomPath);
                }
                add.call();
                git.commit().setMessage(message).call();
            }
        }
        catch (GitAPIException e)
        {
View Full Code Here

TOP

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

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.