use of jetbrains.buildServer.vcs.VcsChange in project teamcity-git by JetBrains.
the class ModificationDataRevWalk method createModificationData.
@NotNull
public ModificationData createModificationData() throws IOException, VcsException {
checkCurrentCommit();
final String commitId = getCurrentCommit().getId().name();
String message = GitServerUtil.getFullMessage(getCurrentCommit());
final PersonIdent authorIdent = GitServerUtil.getAuthorIdent(getCurrentCommit());
final Date authorDate = authorIdent.getWhen();
if (LOG.isDebugEnabled()) {
LOG.debug("Collecting changes in commit " + commitId + ":" + message + " (" + authorDate + ") for " + getGitRoot().debugInfo());
}
final String parentVersion = getFirstParentVersion(getCurrentCommit());
final CommitChangesBuilder builder = new CommitChangesBuilder(getCurrentCommit(), commitId, parentVersion);
builder.collectCommitChanges();
final List<VcsChange> changes = builder.getChanges();
final String author = GitServerUtil.getUser(getGitRoot(), authorIdent);
final ModificationData result = new ModificationData(authorDate, changes, message, author, getGitRoot().getOriginalRoot(), commitId, commitId);
Map<String, String> attributes = builder.getAttributes();
if (!attributes.isEmpty())
result.setAttributes(attributes);
final PersonIdent commiterIdent = GitServerUtil.getCommitterIdent(getCurrentCommit());
final String commiter = GitServerUtil.getUser(getGitRoot(), commiterIdent);
final Date commitDate = commiterIdent.getWhen();
if (!Objects.equals(authorDate, commitDate)) {
result.setAttribute("teamcity.commit.time", Long.toString(commitDate.getTime()));
}
if (!Objects.equals(author, commiter)) {
result.setAttribute("teamcity.commit.user", commiter);
}
if (getCurrentCommit().getParentCount() > 0) {
for (RevCommit parent : getCurrentCommit().getParents()) {
parseBody(parent);
result.addParentRevision(parent.getId().name());
}
} else {
result.addParentRevision(ObjectId.zeroId().name());
}
return result;
}
Aggregations