Merge "notedb: Use user/account pair as author instead of committer"
This commit is contained in:
@@ -171,7 +171,7 @@ public class ChangeNotes extends VersionedMetaData {
|
|||||||
|
|
||||||
private Account.Id parseIdent(RevCommit commit)
|
private Account.Id parseIdent(RevCommit commit)
|
||||||
throws ConfigInvalidException {
|
throws ConfigInvalidException {
|
||||||
return parseIdent(commit.getCommitterIdent());
|
return parseIdent(commit.getAuthorIdent());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Account.Id parseIdent(PersonIdent ident)
|
private Account.Id parseIdent(PersonIdent ident)
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ import org.eclipse.jgit.revwalk.RevCommit;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single delta to apply atomically to a change.
|
* A single delta to apply atomically to a change.
|
||||||
@@ -76,8 +75,8 @@ public class ChangeUpdate extends VersionedMetaData {
|
|||||||
private final MetaDataUpdate.User updateFactory;
|
private final MetaDataUpdate.User updateFactory;
|
||||||
private final LabelTypes labelTypes;
|
private final LabelTypes labelTypes;
|
||||||
private final ChangeControl ctl;
|
private final ChangeControl ctl;
|
||||||
|
private final PersonIdent serverIdent;
|
||||||
private final Date when;
|
private final Date when;
|
||||||
private final TimeZone tz;
|
|
||||||
private final Map<String, Short> approvals;
|
private final Map<String, Short> approvals;
|
||||||
private final Map<Account.Id, ReviewerState> reviewers;
|
private final Map<Account.Id, ReviewerState> reviewers;
|
||||||
private String subject;
|
private String subject;
|
||||||
@@ -132,7 +131,7 @@ public class ChangeUpdate extends VersionedMetaData {
|
|||||||
this.labelTypes = labelTypes;
|
this.labelTypes = labelTypes;
|
||||||
this.ctl = ctl;
|
this.ctl = ctl;
|
||||||
this.when = when;
|
this.when = when;
|
||||||
this.tz = serverIdent.getTimeZone();
|
this.serverIdent = serverIdent;
|
||||||
this.approvals = Maps.newTreeMap(labelTypes.nameComparator());
|
this.approvals = Maps.newTreeMap(labelTypes.nameComparator());
|
||||||
this.reviewers = Maps.newLinkedHashMap();
|
this.reviewers = Maps.newLinkedHashMap();
|
||||||
}
|
}
|
||||||
@@ -193,7 +192,8 @@ public class ChangeUpdate extends VersionedMetaData {
|
|||||||
|
|
||||||
md.setAllowEmpty(true);
|
md.setAllowEmpty(true);
|
||||||
CommitBuilder cb = md.getCommitBuilder();
|
CommitBuilder cb = md.getCommitBuilder();
|
||||||
cb.setCommitter(newCommitter());
|
cb.setAuthor(newIdent(getUser().getAccount()));
|
||||||
|
cb.setCommitter(new PersonIdent(serverIdent, when));
|
||||||
return super.commit(md);
|
return super.commit(md);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,11 +201,7 @@ public class ChangeUpdate extends VersionedMetaData {
|
|||||||
return new PersonIdent(
|
return new PersonIdent(
|
||||||
author.getFullName(),
|
author.getFullName(),
|
||||||
author.getId().get() + "@" + GERRIT_PLACEHOLDER_HOST,
|
author.getId().get() + "@" + GERRIT_PLACEHOLDER_HOST,
|
||||||
when, tz);
|
when, serverIdent.getTimeZone());
|
||||||
}
|
|
||||||
|
|
||||||
public PersonIdent newCommitter() {
|
|
||||||
return newIdent(getUser().getAccount());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -87,9 +87,6 @@ public class ChangeNotesTest {
|
|||||||
private static final TimeZone TZ =
|
private static final TimeZone TZ =
|
||||||
TimeZone.getTimeZone("America/Los_Angeles");
|
TimeZone.getTimeZone("America/Los_Angeles");
|
||||||
|
|
||||||
private static final PersonIdent SERVER_IDENT =
|
|
||||||
new PersonIdent("Gerrit Server", "noreply@gerrit.com", new Date(), TZ);
|
|
||||||
|
|
||||||
private static final LabelTypes LABEL_TYPES = new LabelTypes(ImmutableList.of(
|
private static final LabelTypes LABEL_TYPES = new LabelTypes(ImmutableList.of(
|
||||||
category("Verified",
|
category("Verified",
|
||||||
value(1, "Verified"),
|
value(1, "Verified"),
|
||||||
@@ -100,6 +97,7 @@ public class ChangeNotesTest {
|
|||||||
value(0, "No score"),
|
value(0, "No score"),
|
||||||
value(-1, "Do Not Submit"))));
|
value(-1, "Do Not Submit"))));
|
||||||
|
|
||||||
|
private PersonIdent serverIdent;
|
||||||
private Project.NameKey project;
|
private Project.NameKey project;
|
||||||
private InMemoryRepositoryManager repoManager;
|
private InMemoryRepositoryManager repoManager;
|
||||||
private InMemoryRepository repo;
|
private InMemoryRepository repo;
|
||||||
@@ -110,6 +108,10 @@ public class ChangeNotesTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
setMillisProvider();
|
||||||
|
|
||||||
|
serverIdent = new PersonIdent(
|
||||||
|
"Gerrit Server", "noreply@gerrit.com", TimeUtil.nowTs(), TZ);
|
||||||
project = new Project.NameKey("test-project");
|
project = new Project.NameKey("test-project");
|
||||||
repoManager = new InMemoryRepositoryManager();
|
repoManager = new InMemoryRepositoryManager();
|
||||||
repo = repoManager.createRepository(project);
|
repo = repoManager.createRepository(project);
|
||||||
@@ -146,8 +148,7 @@ public class ChangeNotesTest {
|
|||||||
otherUser = userFactory.create(ou.getId());
|
otherUser = userFactory.create(ou.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
private void setMillisProvider() {
|
||||||
public void setMillisProvider() {
|
|
||||||
clockStepMs = MILLISECONDS.convert(1, SECONDS);
|
clockStepMs = MILLISECONDS.convert(1, SECONDS);
|
||||||
final AtomicLong clockMs = new AtomicLong(
|
final AtomicLong clockMs = new AtomicLong(
|
||||||
MILLISECONDS.convert(ChangeUtil.SORT_KEY_EPOCH_MINS, MINUTES)
|
MILLISECONDS.convert(ChangeUtil.SORT_KEY_EPOCH_MINS, MINUTES)
|
||||||
@@ -192,14 +193,14 @@ public class ChangeNotesTest {
|
|||||||
|
|
||||||
PersonIdent author = commit.getAuthorIdent();
|
PersonIdent author = commit.getAuthorIdent();
|
||||||
assertEquals("Change Owner", author.getName());
|
assertEquals("Change Owner", author.getName());
|
||||||
assertEquals("change@owner.com", author.getEmailAddress());
|
assertEquals("1@gerrit", author.getEmailAddress());
|
||||||
assertEquals(new Date(c.getCreatedOn().getTime() + 1000),
|
assertEquals(new Date(c.getCreatedOn().getTime() + 1000),
|
||||||
author.getWhen());
|
author.getWhen());
|
||||||
assertEquals(TimeZone.getTimeZone("GMT-8:00"), author.getTimeZone());
|
assertEquals(TimeZone.getTimeZone("GMT-8:00"), author.getTimeZone());
|
||||||
|
|
||||||
PersonIdent committer = commit.getCommitterIdent();
|
PersonIdent committer = commit.getCommitterIdent();
|
||||||
assertEquals("Change Owner", committer.getName());
|
assertEquals("Gerrit Server", committer.getName());
|
||||||
assertEquals("1@gerrit", committer.getEmailAddress());
|
assertEquals("noreply@gerrit.com", committer.getEmailAddress());
|
||||||
assertEquals(author.getWhen(), committer.getWhen());
|
assertEquals(author.getWhen(), committer.getWhen());
|
||||||
assertEquals(author.getTimeZone(), committer.getTimeZone());
|
assertEquals(author.getTimeZone(), committer.getTimeZone());
|
||||||
} finally {
|
} finally {
|
||||||
@@ -419,7 +420,7 @@ public class ChangeNotesTest {
|
|||||||
|
|
||||||
private ChangeUpdate newUpdate(Change c, IdentifiedUser user)
|
private ChangeUpdate newUpdate(Change c, IdentifiedUser user)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
return new ChangeUpdate(SERVER_IDENT, repoManager,
|
return new ChangeUpdate(serverIdent, repoManager,
|
||||||
NotesMigration.allEnabled(), accountCache, null, LABEL_TYPES,
|
NotesMigration.allEnabled(), accountCache, null, LABEL_TYPES,
|
||||||
stubChangeControl(c, user),
|
stubChangeControl(c, user),
|
||||||
TimeUtil.nowTs());
|
TimeUtil.nowTs());
|
||||||
|
|||||||
Reference in New Issue
Block a user