Java Code Examples for org.eclipse.jgit.lib.ObjectId#toString()

The following examples show how to use org.eclipse.jgit.lib.ObjectId#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Issues.java    From SZZUnleashed with MIT License 5 votes vote down vote up
/**
 * Return the three dates for a change. The dates are the commit date, the resolution date and the
 * creation date.
 *
 * @param commit the referencing commit.
 * @return a map containing all dates.
 */
public Map<String, String> get(RevCommit commit) {
  String rev = ObjectId.toString(commit.toObjectId());

  try {
    return dates.get(rev);
  } catch (Exception e) {
    return new HashMap<>();
  }
}
 
Example 2
Source File: GitRevisionInfo.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * @return commit ids of this commit's parents
 */
public String[] getParents () {
    String[] parents = new String[revCommit.getParentCount()];
    for (int i = 0; i < revCommit.getParentCount(); ++i) {
        parents[i] = ObjectId.toString(revCommit.getParent(i).getId());
    }
    return parents;
}
 
Example 3
Source File: GitMergeResult.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private String[] getMergedCommits (MergeResult result) {
    ObjectId[] mergedObjectIds = result.getMergedCommits();
    String[] commits = new String[mergedObjectIds.length];
    for (int i = 0; i < mergedObjectIds.length; ++i) {
        commits[i] = ObjectId.toString(mergedObjectIds[i]);
    }
    return commits;
}
 
Example 4
Source File: GitTag.java    From netbeans with Apache License 2.0 5 votes vote down vote up
GitTag (String tagName, RevObject revObject) {
    this.id = ObjectId.toString(revObject.getId());
    this.name = tagName;
    this.message = null;
    this.taggedObject = id;
    this.tagger = null;
    this.type = getType(revObject);
    this.lightWeight = true;
}
 
Example 5
Source File: GitRevisionInfo.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * @return id of the commit
 */
public String getRevision () {
    return ObjectId.toString(revCommit.getId());
}
 
Example 6
Source File: GitBranch.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * @return commit id of the HEAD commit in the branch.
 */
public String getId () {
    return ObjectId.toString(id);
}
 
Example 7
Source File: CommitTask.java    From ant-git-tasks with Apache License 2.0 4 votes vote down vote up
@Override
protected void doExecute() throws BuildException {
        try {
                setFailOnError(true);
                CommitCommand cmd = git.commit();

                if (!GitTaskUtils.isNullOrBlankString(message)) {
                        cmd.setMessage(brandedMessage ? GitTaskUtils.BRANDING_MESSAGE + " " + message : message);
                }
                else {
                        cmd.setMessage(GitTaskUtils.BRANDING_MESSAGE);
                }

                String prefix = getDirectory().getCanonicalPath();
                String[] allFiles = getPath().list();

                if (!GitTaskUtils.isNullOrBlankString(only)) {
                        cmd.setOnly(only);
                }
                else if (allFiles.length > 0) {
                        for (String file : allFiles) {
                                String modifiedFile = translateFilePathUsingPrefix(file, prefix);
                                log("Will commit " + modifiedFile);
                                cmd.setOnly(modifiedFile);
                        }
                }
                else {
                        cmd.setAll(true);
                }

                GitSettings gitSettings = lookupSettings();

                if (gitSettings == null) {
                        throw new MissingRequiredGitSettingsException();
                }

                cmd.setAmend(amend).setAuthor(gitSettings.getIdentity()).setCommitter(gitSettings.getIdentity());

                if (reflogComment != null) {
                        cmd.setReflogComment(reflogComment);
                }

                RevCommit revCommit = cmd.call();

                if (revCommitIdProperty != null) {
                        String revisionId = ObjectId.toString(revCommit.getId());
                        getProject().setProperty(revCommitIdProperty, revisionId);
                }

                log(revCommit.getFullMessage());
        } catch (IOException ioe) {
                throw new GitBuildException(MESSAGE_COMMIT_FAILED, ioe);
        } catch (GitAPIException ex) {
                throw new GitBuildException(MESSAGE_COMMIT_FAILED, ex);
        }
}
 
Example 8
Source File: Commit.java    From SZZUnleashed with MIT License 2 votes vote down vote up
/**
 * Return the hash representation of the commit.
 *
 * @return a hash representation as a string.
 */
public String getHashString() {
  return ObjectId.toString(commit.toObjectId());
}