Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.AddCommand


  }

  private Action createAddAction(final IStructuredSelection selection) {
    return new Action(UIText.CommitDialog_AddFileOnDiskToIndex) {
      public void run() {
        AddCommand addCommand = new Git(repository).add();
        for (Iterator<?> it = selection.iterator(); it.hasNext();) {
          CommitItem commitItem = (CommitItem) it.next();
          addCommand.addFilepattern(commitItem.path);
        }
        try {
          addCommand.call();
        } catch (Exception e) {
          Activator.logError(UIText.CommitDialog_ErrorAddingFiles, e);
        }
        for (Iterator<?> it = selection.iterator(); it.hasNext();) {
          CommitItem commitItem = (CommitItem) it.next();
View Full Code Here


  }

  private void addToCommand(IResource resource, Map<RepositoryMapping, AddCommand> addCommands) {
    IProject project = resource.getProject();
    RepositoryMapping map = RepositoryMapping.getMapping(project);
    AddCommand command = addCommands.get(map);
    if (command == null) {
      Repository repo = map.getRepository();
      Git git = new Git(repo);
      AdaptableFileTreeIterator it = new AdaptableFileTreeIterator(repo,
          resource.getWorkspace().getRoot());
      command = git.add().setWorkingTreeIterator(it);
      addCommands.put(map, command);
    }
    String filepattern = map.getRepoRelativePath(resource);
    if ("".equals(filepattern)) //$NON-NLS-1$
      filepattern = "."; //$NON-NLS-1$
    command.addFilepattern(filepattern);
  }
View Full Code Here

      return null;

    Repository repository = selectedNodes.get(0).getRepository();
    IPath workTreePath = new Path(repository.getWorkTree().getAbsolutePath());

    AddCommand addCommand = new Git(repository).add();

    Collection<IPath> paths = getSelectedFileAndFolderPaths(event);
    for (IPath path : paths) {
      String repoRelativepath;
      if (path.equals(workTreePath))
        repoRelativepath = "."; //$NON-NLS-1$
      else
        repoRelativepath = path.removeFirstSegments(
                path.matchingFirstSegments(workTreePath))
            .setDevice(null).toString();
      addCommand.addFilepattern(repoRelativepath);
    }
    try {
      addCommand.call();
    } catch (GitAPIException e) {
      Activator.logError(UIText.AddToIndexCommand_addingFilesFailed,
          e);
    }
    return null;
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);
                    }
                   
                    if(isWindows)
                    {
                        pomPath = StringUtils.replace(pomPath,"\\","/");   
                    }
                   
                    add.addFilepattern(pomPath);
                }
                add.call();
                git.commit().setMessage(message).call();
            }
        }
        catch (GitAPIException e)
        {
View Full Code Here

  public VersionInfo makeVersion(FileVersion... fileVersions) throws IOException {
    persistence.makeVersion(fileVersions);
    Repository repository = getRepository(fileVersions[0].getFile());
    Git git = new Git(repository);
    try {
      AddCommand adder = git.add();
      for (FileVersion fileVersion : fileVersions) {
        adder.addFilepattern(getPath(fileVersion.getFile(), repository));
      }
      adder.call();
      commit(git, String.format("[FitNesse] Updated files: %s.", formatFileVersions(fileVersions)), fileVersions[0].getAuthor());
    } catch (GitAPIException e) {
      throw new IOException("Unable to commit changes", e);
    }
    return VersionInfo.makeVersionInfo(fileVersions[0].getAuthor(), fileVersions[0].getLastModificationTime());
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 {
      final File dir = worktree.getCanonicalFile().getAbsoluteFile();

      final Git git = Git.init().setDirectory(dir).call();

      final AddCommand add = git.add();
      for (final File f : dir.listFiles()) {
        final String name = f.getName();
        if (!".git".equals(name)) {
          log("adding %s", name);
          add.addFilepattern(name);
        }
      }
      final DirCache index = add.call();
      final int cnt = index.getEntryCount();
      log("%d entries added", cnt);
      final String msg = "snapshot";
      final RevCommit head = git.commit().setMessage(msg).call();
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

            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);
                    }
                   
                    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.