in git-server/src/main/java/jetbrains/buildServer/buildTriggers/vcs/git/gitProxy/GitProxyChangesCollector.java [616:682]
private ModificationData createModificationDataGitProxy(@NotNull CommitInfo info, @NotNull CommitChange firstEdgeChange, @NotNull GitVcsRoot gitRoot, @NotNull VcsRoot root,
@Nullable List<CommitChange> mergeEdgeChanges, @Nullable Map<String, List<String>> submodulePrefixesMap,
boolean exceptionOnSubmoduleChanges) {
CommitChange change;
Map<String, LinkedHashMap<String, ChangeType>> perParentChangedFilesForMergeCommit = null;
if (mergeEdgeChanges == null) {
change = firstEdgeChange;
} else {
perParentChangedFilesForMergeCommit = new HashMap<>();
addFileChanges(perParentChangedFilesForMergeCommit, firstEdgeChange);
for (CommitChange edgeChange : mergeEdgeChanges) {
addFileChanges(perParentChangedFilesForMergeCommit, edgeChange);
}
change = inferMergeCommitChange(firstEdgeChange, perParentChangedFilesForMergeCommit);
}
List<VcsChange> vcsChanges = new ArrayList<>(change.changes.size());
for (FileChange fileChange : change.changes) {
VcsChangeInfo.Type changeType;
switch (fileChange.changeType) {
case Added: changeType = VcsChangeInfo.Type.ADDED; break;
case Deleted: changeType = VcsChangeInfo.Type.REMOVED; break;
case Modified: changeType = VcsChangeInfo.Type.CHANGED; break;
default: changeType = VcsChangeInfo.Type.NOT_CHANGED;
}
String filePath = fileChange.getDisplayPath();
if (fileChange.entryType == EntryType.GitLink) {
if (exceptionOnSubmoduleChanges) {
throw new GitProxySubmoduleChangesNotSupported();
}
if (submodulePrefixesMap != null) {
submodulePrefixesMap.computeIfAbsent(info.id, (k) -> new ArrayList<>()).add(filePath + "/");
}
// we don't list changes in submodules for now
continue;
}
vcsChanges.add(new VcsChange(changeType,
null, // TODO identify if file mode has changed and provide description in that case
filePath,
filePath,
(info.parents == null || info.parents.isEmpty()) ? ObjectId.zeroId().name() : info.parents.get(0),
info.id));
}
String author = GitServerUtil.getUser(gitRoot, new PersonIdent(info.author.name, info.author.email));
Date authorDate = new Date((long)info.authorTime * 1000);
ModificationData modificationData = new ModificationData(authorDate, vcsChanges, info.fullMessage, author, root, change.revision, change.revision);
if (perParentChangedFilesForMergeCommit != null) {
setMergeCommitAttributes(modificationData, perParentChangedFilesForMergeCommit);
}
String commiter = GitServerUtil.getUser(gitRoot, new PersonIdent(info.committer.name, info.committer.email));
Date commitDate = new Date((long)info.commitTime * 1000);
if (!Objects.equals(authorDate, commitDate)) {
modificationData.setAttribute(DBVcsModification.TEAMCITY_COMMIT_TIME, Long.toString(commitDate.getTime()));
}
if (!Objects.equals(author, commiter)) {
modificationData.setAttribute(DBVcsModification.TEAMCITY_COMMIT_USER, commiter);
}
modificationData.setParentRevisions(info.parents != null && !info.parents.isEmpty() ? info.parents : Collections.singletonList(ObjectId.zeroId().name()));
return modificationData;
}