org.eclipse.jgit.util
Class ChangeIdUtil

java.lang.Object
  extended by org.eclipse.jgit.util.ChangeIdUtil

public class ChangeIdUtil
extends Object

Utilities for creating and working with Change-Id's, like the one used by Gerrit Code Review.

A Change-Id is a SHA-1 computed from the content of a commit, in a similar fashion to how the commit id is computed. Unlike the commit id a Change-Id is retained in the commit and subsequent revised commits in the footer of the commit text.


Constructor Summary
ChangeIdUtil()
           
 
Method Summary
static ObjectId computeChangeId(ObjectId treeId, ObjectId firstParentId, PersonIdent author, PersonIdent committer, String message)
          Compute a Change-Id.
static String insertId(String message, ObjectId changeId)
          Find the right place to insert a Change-Id and return it.
static String insertId(String message, ObjectId changeId, boolean replaceExisting)
          Find the right place to insert a Change-Id and return it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChangeIdUtil

public ChangeIdUtil()
Method Detail

computeChangeId

public static ObjectId computeChangeId(ObjectId treeId,
                                       ObjectId firstParentId,
                                       PersonIdent author,
                                       PersonIdent committer,
                                       String message)
                                throws IOException
Compute a Change-Id.

Parameters:
treeId - The id of the tree that would be committed
firstParentId - parent id of previous commit or null
author - the PersonIdent for the presumed author and time
committer - the PersonIdent for the presumed committer and time
message - The commit message
Returns:
the change id SHA1 string (without the 'I') or null if the message is not complete enough
Throws:
IOException

insertId

public static String insertId(String message,
                              ObjectId changeId)
Find the right place to insert a Change-Id and return it.

The Change-Id is inserted before the first footer line but after a Bug line.

Parameters:
message -
changeId -
Returns:
a commit message with an inserted Change-Id line

insertId

public static String insertId(String message,
                              ObjectId changeId,
                              boolean replaceExisting)
Find the right place to insert a Change-Id and return it.

If no Change-Id is found the Change-Id is inserted before the first footer line but after a Bug line. If Change-Id is found and replaceExisting is set to false, the message is unchanged. If Change-Id is found and replaceExisting is set to true, the Change-Id is replaced with changeId.

Parameters:
message -
changeId -
replaceExisting -
Returns:
a commit message with an inserted Change-Id line


Copyright © 2012. All Rights Reserved.