AbstractChangeUpdate: Set author/committer in superclass

This is always set to the same value. Don't rely on implementations to
set it, just do it once in the wrapper.

Change-Id: I963f5130215b2b8114e8d8729824371e6e182041
This commit is contained in:
Dave Borowitz
2016-02-23 11:15:32 -05:00
parent 15cddfecc0
commit f5c06d8e2a
3 changed files with 8 additions and 10 deletions

View File

@@ -44,8 +44,8 @@ public abstract class AbstractChangeUpdate {
protected final GitRepositoryManager repoManager;
protected final ChangeControl ctl;
protected final String anonymousCowardName;
protected final PersonIdent serverIdent;
protected final Date when;
private final PersonIdent serverIdent;
protected PatchSet.Id psId;
private ObjectId result;
@@ -93,7 +93,7 @@ public abstract class AbstractChangeUpdate {
this.psId = psId;
}
protected PersonIdent newAuthorIdent() {
private PersonIdent newAuthorIdent() {
CurrentUser u = getUser();
if (u instanceof IdentifiedUser) {
return ChangeNoteUtil.newIdent(u.asIdentifiedUser().getAccount(), when,
@@ -143,6 +143,8 @@ public abstract class AbstractChangeUpdate {
result = z;
return z; // Impl intends to delete the ref.
}
cb.setAuthor(newAuthorIdent());
cb.setCommitter(new PersonIdent(serverIdent, when));
if (!curr.equals(z)) {
cb.setParentId(curr);
} else {
@@ -165,10 +167,10 @@ public abstract class AbstractChangeUpdate {
*
* @param ins inserter to write to; callers should not flush.
* @return a new commit builder representing this commit, or null to indicate
* the meta ref should be deleted as a result of this update. The parent
* field in the return value is always overwritten. The tree ID may be
* unset by this method, which indicates to the caller that it should be
* copied from the parent commit.
* the meta ref should be deleted as a result of this update. The parent,
* author, and committer fields in the return value are always
* overwritten. The tree ID may be unset by this method, which indicates
* to the caller that it should be copied from the parent commit.
* @throws OrmException if a Gerrit-level error occurred.
* @throws IOException if a lower-level error occurred.
*/

View File

@@ -234,8 +234,6 @@ public class ChangeDraftUpdate extends AbstractChangeUpdate {
protected CommitBuilder applyImpl(ObjectInserter ins)
throws OrmException, IOException {
CommitBuilder cb = new CommitBuilder();
cb.setAuthor(newAuthorIdent());
cb.setCommitter(new PersonIdent(serverIdent, when));
cb.setMessage("Update draft comments");
AtomicBoolean removedAllComments = new AtomicBoolean();
ObjectId treeId = storeCommentsInNotes(ins, removedAllComments);

View File

@@ -479,8 +479,6 @@ public class ChangeUpdate extends AbstractChangeUpdate {
protected CommitBuilder applyImpl(ObjectInserter ins)
throws OrmException, IOException {
CommitBuilder cb = new CommitBuilder();
cb.setAuthor(newAuthorIdent());
cb.setCommitter(new PersonIdent(serverIdent, when));
int ps = psId != null ? psId.get() : getChange().currentPatchSetId().get();
StringBuilder msg = new StringBuilder();