Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.Status


      repo.close();
    }
  }

  private static Set<String> getModifiedFiles(Git git) throws NoWorkTreeException, GitAPIException {
    Status status = git.status().call();
    return status.getModified();
  }
View Full Code Here


public class ShowStatus {

    public static void main(String[] args) throws IOException, GitAPIException {
        Repository repository = CookbookHelper.openJGitCookbookRepository();

        Status status = new Git(repository).status().call();
        System.out.println("Added: " + status.getAdded());
        System.out.println("Changed: " + status.getChanged());
        System.out.println("Conflicting: " + status.getConflicting());
        System.out.println("ConflictingStageState: " + status.getConflictingStageState());
        System.out.println("IgnoredNotInIndex: " + status.getIgnoredNotInIndex());
        System.out.println("Missing: " + status.getMissing());
        System.out.println("Modified: " + status.getModified());
        System.out.println("Removed: " + status.getRemoved());
        System.out.println("Untracked: " + status.getUntracked());
        System.out.println("UntrackedFolders: " + status.getUntrackedFolders());

        repository.close();
    }
View Full Code Here

    compareEditor.save();


    // then file FILE1 should be in index
    Repository repo = lookupRepository(repositoryFile);
    Status status = new Git(repo).status().call();
    assertThat(Long.valueOf(status.getChanged().size()),
        is(Long.valueOf(1L)));
    assertThat(status.getChanged().iterator().next(), is(PROJ1 + "/"
        + FOLDER + "/" + FILE1));
  }
View Full Code Here

    });
    compareEditor.save();

    // then file FILE1 should be unchanged in working tree
    Repository repo = lookupRepository(repositoryFile);
    Status status = new Git(repo).status().call();
    assertThat(Long.valueOf(status.getModified().size()),
        is(Long.valueOf(1)));
    assertThat(status.getModified().iterator().next(), is(PROJ1 + "/"
        + FOLDER + "/" + FILE2));
  }
View Full Code Here

    @Override
    public void commitAllChanges(Git git, String message) throws JGitFlowReleaseException
    {
        try
        {
            Status status = git.status().call();
            if (!status.isClean())
            {
                git.add().addFilepattern(".").call();
                git.commit().setMessage(message).call();
            }
        }
View Full Code Here

    @Override
    public void commitAllPoms(Git git, List<MavenProject> reactorProjects, String message) throws JGitFlowReleaseException
    {
        try
        {
            Status status = git.status().call();
            if (!status.isClean())
            {
                AddCommand add = git.add();

                MavenProject rootProject = ReleaseUtil.getRootProject(reactorProjects);
                File rootBaseDir = rootProject.getBasedir();
View Full Code Here

    }
    return builder.toString();
  }

  private void commit(Git git, String message, String author) throws GitAPIException {
    Status status = git.status().call();
    if (!status.getAdded().isEmpty() || !status.getChanged().isEmpty() || !status.getRemoved().isEmpty()) {
      if (author==null)
        author = "";
      // set the commit author (if given) but ignores the email
      git.commit().setAuthor(author, "").setMessage(message).call();
    }
View Full Code Here

  }

  @VisibleForTesting
  boolean findDirtyState(Repository repo) throws GitAPIException {
    Git git = Git.wrap(repo);
    Status status = git.status().call();

    // Git describe doesn't mind about untracked files when checking if
    // repo is dirty. JGit does this, so we cannot use the isClean method
    // to get the same behaviour. Instead check dirty state without
    // status.getUntracked().isEmpty()
    boolean isDirty = !(status.getAdded().isEmpty()
        && status.getChanged().isEmpty()
        && status.getRemoved().isEmpty()
        && status.getMissing().isEmpty()
        && status.getModified().isEmpty()
        && status.getConflicting().isEmpty());

    log("Repo is in dirty state [", isDirty, "]");
    return isDirty;
  }
View Full Code Here

    Ref masterRef = git.getRepository()
        .getRef("master");
    if (null != masterRef)
      commitId = ObjectId.toString(masterRef.getObjectId());

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

    boolean pushAhead = false;

    if (null != commitId && status.isClean()) {
      versionLabel = lookupVersionLabelForCommitId(commitId);

      if (null == versionLabel) {
        getLog().info("No Changes. However, we've didn't get something close in AWS Elastic Beanstalk and we're pushing ahead");
        pushAhead = true;
      } else {
        getLog().info("No Changes. However, we've got something close in AWS Elastic Beanstalk and we're continuing");

        project.getProperties().put("beanstalk.versionLabel", versionLabel);

        return null;
      }
    }

    if (!pushAhead) {
      // 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();
View Full Code Here

    if (CleanupMode.NONE.equals(cleanup)) {
      log("skip cleanup");
      return;
    }
    //TODO handle all cleanup modes properly
    final Status st = git.status().call();
    if (st.isClean()) {
      log("ready");
    } else {
      log("not clean");
      git.reset().setMode(ResetType.HARD).call();
      final Status st2 = git.status().call();
      if (st2.isClean() || !st.getUntracked().isEmpty()) {
        log("ready");
      }
    }
  }
View Full Code Here

TOP

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

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.