Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.AddCommand


        FS.DETECTED)) {
      throw new BuildException("Specified path (" + src
          + ") is not a git repository.");
    }

    AddCommand gitAdd;
    try {
      Repository repo = new FileRepositoryBuilder().readEnvironment()
          .findGitDir(src).build();
      gitAdd = new Git(repo).add();
    } catch (IOException e) {
      throw new BuildException("Could not access repository " + src, e);
    }

    try {
      String prefix = src.getCanonicalPath();
      String[] allFiles = getPath().list();

      for (String file : allFiles) {
        String toAdd = translateFilePathUsingPrefix(file, prefix);
        log("Adding " + toAdd, Project.MSG_VERBOSE);
        gitAdd.addFilepattern(toAdd);
      }
      gitAdd.call();
    } catch (Exception e) {
      throw new BuildException("Could not add files to index." + src, e);
    }

  }
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

    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

      // 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();

      masterRef = git.getRepository()
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();

      masterRef = git.getRepository()
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

     */
    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

        FS.DETECTED)) {
      throw new BuildException("Specified path (" + src
          + ") is not a git repository.");
    }

    AddCommand gitAdd;
    try {
      Repository repo = new FileRepositoryBuilder().readEnvironment()
          .findGitDir(src).build();
      gitAdd = new Git(repo).add();
    } catch (IOException e) {
      throw new BuildException("Could not access repository " + src, e);
    }

    try {
      String prefix = src.getCanonicalPath();
      String[] allFiles = getPath().list();

      for (String file : allFiles) {
        String toAdd = translateFilePathUsingPrefix(file, prefix);
        log("Adding " + toAdd, Project.MSG_VERBOSE);
        gitAdd.addFilepattern(toAdd);
      }
      gitAdd.call();
    } catch (Exception e) {
      throw new BuildException("Could not add files to index." + src, e);
    }

  }
View Full Code Here

  @Argument(required = true, metaVar = "metaVar_filepattern", usage = "usage_filesToAddContentFrom")
  private List<String> filepatterns = new ArrayList<String>();

  @Override
  protected void run() throws Exception {
    AddCommand addCmd = new Git(db).add();
    addCmd.setUpdate(update);
    for (String p : filepatterns)
      addCmd.addFilepattern(p);
    addCmd.call();
  }
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.