use of jetbrains.buildServer.vcs.ModificationData 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;
}
use of jetbrains.buildServer.vcs.ModificationData in project teamcity-git by JetBrains.
the class BranchSupportTest method test.
/**
* o ee886e4adb70fbe3bdc6f3f6393598b3f02e8009 (change1)
* |
* |
* | o 1391281d33a83a7205f2f05d3eb64c349c636e87 (change2)
* | |
* | /
* |/
* o f3f826ce85d6dad25156b2d7550cedeb1a422f4c
* |
* |
* |
*/
public void test() throws VcsException {
VcsRoot originalRoot = vcsRoot().withFetchUrl(GitUtils.toURL(myRepositoryDir)).withBranch("master").build();
VcsRoot substitutionRoot = vcsRoot().withFetchUrl(GitUtils.toURL(myRepositoryDir)).withBranch("personal-branch1").build();
final String originalRootVersion = "3b9fbfbb43e7edfad018b482e15e7f93cca4e69f";
final String substitutionRootVersion = "1391281d33a83a7205f2f05d3eb64c349c636e87";
GitVcsSupport vcsSupport = gitSupport().withServerPaths(myServerPaths).build();
List<ModificationData> changes = vcsSupport.collectChanges(originalRoot, originalRootVersion, substitutionRoot, substitutionRootVersion, CheckoutRules.DEFAULT);
assertEquals(1, changes.size());
assertEquals(substitutionRoot, changes.get(0).getVcsRootObject());
assertEquals(substitutionRootVersion, changes.get(0).getVersion());
}
Aggregations