示例#1
0
 /**
  * It returns a <code>GitStatusResonse</code> object that contains all the details of the output
  * of &lt;git-status&gt; command. It has no path passed as parameter to the method.
  *
  * @param repositoryPath Directory path to the root of the repository.
  * @param options Options that are passed to &lt;git-status&gt; command.
  * @return <code>GitStatusResponse</code> object
  * @throws JavaGitException Exception thrown if the repositoryPath is null or if options or paths
  *     are invalid.
  * @throws IOException Exception is thrown if any of the IO operations fail.
  */
 public GitStatusResponse status(File repositoryPath, GitStatusOptions options)
     throws JavaGitException, IOException {
   CheckUtilities.checkFileValidity(repositoryPath);
   IClient client = ClientManager.getInstance().getPreferredClient();
   IGitStatus gitStatus = client.getGitStatusInstance();
   return gitStatus.status(repositoryPath, options);
 }
示例#2
0
  /**
   * It returns a <code>GitFileSystemObject.Status</code> for a single file
   *
   * @param repositoryPath Directory path to the root of the repository.
   * @param path
   * @return <code>GitFileSystemObject.Status</code>
   * @throws JavaGitException Exception thrown if the repositoryPath is null
   * @throws IOException Exception is thrown if any of the IO operations fail.
   */
  public GitFileSystemObject.Status getFileStatus(File repositoryPath, File path)
      throws JavaGitException, IOException {
    // check validity of a repository path
    CheckUtilities.checkFileValidity(repositoryPath);

    // run git status
    IClient client = ClientManager.getInstance().getPreferredClient();
    IGitStatus gitStatus = client.getGitStatusInstance();
    GitStatusResponse response = gitStatus.status(repositoryPath);

    return response.getFileStatus(path);
    /*
     * TODO: quote from Michael Schidlowsky: "this block of if statements is a little smelly... I'd
     * prefer to see something like return response.asStatus()...
     */
    /*
    if (response.getUntrackedFilesSize() > 0) {
      return Status.UNTRACKED;
    }

    if (response.getNewFilesToCommitSize() > 0) {
      return Status.NEW_TO_COMMIT;
    }

    if (response.getDeletedFilesNotUpdatedSize() > 0) {
      return Status.DELETED;
    }

    if (response.getDeletedFilesToCommitSize() > 0) {
      return Status.DELETED_TO_COMMIT;
    }

    if (response.getModifiedFilesNotUpdatedSize() > 0) {
      return Status.MODIFIED;
    }

    if (response.getModifiedFilesToCommitSize() > 0) {
      return Status.MODIFIED_TO_COMMIT;
    }

    // default
    return Status.IN_REPOSITORY;
    */
  }