Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.AddCommand


    if (paths == null) {
      paths = new JSONArray().put(pattern.isEmpty() ? ADD_ALL_PATTERN : pattern);
    }

    Git git = new Git(db);
    AddCommand add = git.add();
    for (int i = 0; i < paths.length(); i++) {
      add.addFilepattern(paths.getString(i));
    }
    // "git add {pattern}"
    try {
      add.call();
    } catch (GitAPIException e) {
      return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage(),
          e));
    }

    // TODO: we're calling "add" twice, this is inefficient, see bug 349299
    // "git add -u {pattern}"
    add = git.add().setUpdate(true);
    for (int i = 0; i < paths.length(); i++) {
      add.addFilepattern(paths.getString(i));
    }
    try {
      add.call();
    } catch (GitAPIException e) {
      return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage(),
          e));
    }
    return true;
View Full Code Here


     */
    public static List<ScmFile> addAllFiles( Git git, ScmFileSet fileSet )
        throws GitAPIException, NoFilepatternException
    {
        URI baseUri = fileSet.getBasedir().toURI();
        AddCommand add = git.add();
        for ( File file : fileSet.getFileList() )
        {
            if ( !file.isAbsolute() )
            {
                file = new File( fileSet.getBasedir().getPath(), file.getPath() );
            }

            if ( file.exists() )
            {
                String path = relativize( baseUri, file );
                add.addFilepattern( path );
                add.addFilepattern( file.getAbsolutePath() );
            }
        }
        add.call();
       
        Status status = git.status().call();

        Set<String> allInIndex = new HashSet<String>();
        allInIndex.addAll( status.getAdded() );
View Full Code Here

                    getLogger().warn( "there are no files to be added" );
                    doCommit = false;
                }
                else
                {
                    AddCommand add = git.add();
                    for ( String changed : changeds )
                    {
                        getLogger().debug( "add manualy: " + changed );
                        add.addFilepattern( changed );
                        doCommit = true;
                    }
                    add.call();
                }
            }

            List<ScmFile> checkedInFiles = Collections.emptyList();
            if ( doCommit )
View Full Code Here

        dir1.mkdirs();
      File myfile = new File(dir1, name);
      FileOutputStream os = new FileOutputStream(myfile);
      os.write(data);
      os.close();
      AddCommand add = git.add();
      add.addFilepattern(filePath).call();
      GitUser user = userMap.get(psoft_user);
      if (user == null)
        user = userMap.get("default");
      CommitCommand commit = git.commit();
      commit.setMessage(commitStr).setAuthor(user.user, user.email).setCommitter("Decode Peoplecode", "nobody@dummy.org").call();
View Full Code Here

    }
 
  private void addAndCommit(Repository r, String filePattern, String msg) throws IOException{
        try {
            Git git = new Git(r);
            AddCommand cmd = git.add();
            cmd.addFilepattern(filePattern);
            cmd.call();

            CommitCommand co = git.commit();
            co.setAuthor("Jenkow","noreply@jenkins-ci.org");
            co.setMessage(msg);
            co.call();
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

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

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

                    if (getLogger().isDebugEnabled())
                    {
                        getLogger().debug("adding file pattern for poms commit: " + 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

  }

  private void addUntracked() throws CoreException {
    if (notTracked == null || notTracked.size() == 0)
      return;
    AddCommand addCommand = new Git(repo).add();
    boolean fileAdded = false;
    for (String path : notTracked)
      if (commitFileList.contains(path)) {
        addCommand.addFilepattern(path);
        fileAdded = true;
      }
    if (fileAdded)
      try {
        addCommand.call();
      } catch (Exception e) {
        throw new CoreException(Activator.error(e.getMessage(), e));
      }
  }
View Full Code Here

      }
    }

    if (!addPaths.isEmpty())
      try {
        AddCommand add = git.add();
        for (String addPath : addPaths)
          add.addFilepattern(addPath);
        add.call();
      } catch (NoFilepatternException e1) {
        // cannot happen
      } catch (JGitInternalException e1) {
        Activator.handleError(e1.getCause().getMessage(),
            e1.getCause(), true);
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.