use of org.eclipse.jgit.lib.PersonIdent in project gerrit by GerritCodeReview.
the class AccountsOnInit method insert.
public void insert(ReviewDb db, Account account) throws OrmException, IOException {
db.accounts().insert(ImmutableSet.of(account));
File path = getPath();
if (path != null) {
try (Repository repo = new FileRepository(path);
ObjectInserter oi = repo.newObjectInserter()) {
PersonIdent serverIdent = new GerritPersonIdentProvider(flags.cfg).get();
AccountsUpdate.createUserBranch(repo, oi, serverIdent, serverIdent, account);
}
}
}
use of org.eclipse.jgit.lib.PersonIdent in project gerrit by GerritCodeReview.
the class ChangeNotesParser method parseAddApproval.
private PatchSetApproval parseAddApproval(PatchSet.Id psId, Account.Id committerId, Account.Id realAccountId, Timestamp ts, String line) throws ConfigInvalidException {
// There are potentially 3 accounts involved here:
// 1. The account from the commit, which is the effective IdentifiedUser
// that produced the update.
// 2. The account in the label footer itself, which is used during submit
// to copy other users' labels to a new patch set.
// 3. The account in the Real-user footer, indicating that the whole
// update operation was executed by this user on behalf of the effective
// user.
Account.Id effectiveAccountId;
String labelVoteStr;
int s = line.indexOf(' ');
if (s > 0) {
// Account in the label line (2) becomes the effective ID of the
// approval. If there is a real user (3) different from the commit user
// (2), we actually don't store that anywhere in this case; it's more
// important to record that the real user (3) actually initiated submit.
labelVoteStr = line.substring(0, s);
PersonIdent ident = RawParseUtils.parsePersonIdent(line.substring(s + 1));
checkFooter(ident != null, FOOTER_LABEL, line);
effectiveAccountId = noteUtil.parseIdent(ident, id);
} else {
labelVoteStr = line;
effectiveAccountId = committerId;
}
LabelVote l;
try {
l = LabelVote.parseWithEquals(labelVoteStr);
} catch (IllegalArgumentException e) {
ConfigInvalidException pe = parseException("invalid %s: %s", FOOTER_LABEL, line);
pe.initCause(e);
throw pe;
}
PatchSetApproval psa = new PatchSetApproval(new PatchSetApproval.Key(psId, effectiveAccountId, new LabelId(l.label())), l.value(), ts);
psa.setTag(tag);
if (!Objects.equals(realAccountId, committerId)) {
psa.setRealAccountId(realAccountId);
}
ApprovalKey k = ApprovalKey.create(psId, effectiveAccountId, l.label());
if (!approvals.containsKey(k)) {
approvals.put(k, psa);
}
return psa;
}
use of org.eclipse.jgit.lib.PersonIdent in project gerrit by GerritCodeReview.
the class ChangeNotesParser method parseReviewer.
private void parseReviewer(Timestamp ts, ReviewerStateInternal state, String line) throws ConfigInvalidException {
PersonIdent ident = RawParseUtils.parsePersonIdent(line);
if (ident == null) {
throw invalidFooter(state.getFooterKey(), line);
}
Account.Id accountId = noteUtil.parseIdent(ident, id);
reviewerUpdates.add(ReviewerStatusUpdate.create(ts, ownerId, accountId, state));
if (!reviewers.containsRow(accountId)) {
reviewers.put(accountId, state, ts);
}
}
use of org.eclipse.jgit.lib.PersonIdent in project gerrit by GerritCodeReview.
the class ChangeNotesParser method parseSubmitRecords.
private void parseSubmitRecords(List<String> lines) throws ConfigInvalidException {
SubmitRecord rec = null;
for (String line : lines) {
int c = line.indexOf(": ");
if (c < 0) {
rec = new SubmitRecord();
submitRecords.add(rec);
int s = line.indexOf(' ');
String statusStr = s >= 0 ? line.substring(0, s) : line;
rec.status = Enums.getIfPresent(SubmitRecord.Status.class, statusStr).orNull();
checkFooter(rec.status != null, FOOTER_SUBMITTED_WITH, line);
if (s >= 0) {
rec.errorMessage = line.substring(s);
}
} else {
checkFooter(rec != null, FOOTER_SUBMITTED_WITH, line);
SubmitRecord.Label label = new SubmitRecord.Label();
if (rec.labels == null) {
rec.labels = new ArrayList<>();
}
rec.labels.add(label);
label.status = Enums.getIfPresent(SubmitRecord.Label.Status.class, line.substring(0, c)).orNull();
checkFooter(label.status != null, FOOTER_SUBMITTED_WITH, line);
int c2 = line.indexOf(": ", c + 2);
if (c2 >= 0) {
label.label = line.substring(c + 2, c2);
PersonIdent ident = RawParseUtils.parsePersonIdent(line.substring(c2 + 2));
checkFooter(ident != null, FOOTER_SUBMITTED_WITH, line);
label.appliedBy = noteUtil.parseIdent(ident, id);
} else {
label.label = line.substring(c + 2);
}
}
}
}
use of org.eclipse.jgit.lib.PersonIdent in project gerrit by GerritCodeReview.
the class ChangeNotesParser method parseIdent.
private Account.Id parseIdent(ChangeNotesCommit commit) throws ConfigInvalidException {
// Check if the author name/email is the same as the committer name/email,
// i.e. was the server ident at the time this commit was made.
PersonIdent a = commit.getAuthorIdent();
PersonIdent c = commit.getCommitterIdent();
if (a.getName().equals(c.getName()) && a.getEmailAddress().equals(c.getEmailAddress())) {
return null;
}
return noteUtil.parseIdent(commit.getAuthorIdent(), id);
}
Aggregations