* in the commit)
* @throws GitImporterException
* if problems arise while parsing the commit date
*/
public void createTransaction(Commit commit, Map<String, String> filesContent) throws GitImporterException {
Transaction currTrans;
if (fTransactions.containsKey(commit.getSha())) {
LOGGER
.debug("This commit was already extracted for a previous release, so, I'll just attach its related FileVersions to the current release");
currTrans = fTransactions.get(commit.getSha());
for (Revision rev : currTrans.getInvolvedRevisions()) {
fCurrRelease.addRevision(rev);
rev.addRelease(fCurrRelease);
}
} else {
if (commit.getFiles() != null) {
currTrans = new Transaction();
fTransactions.put(commit.getSha(), currTrans);
try {
currTrans.setStarted(this.translateDateString(commit.getDateString()));
currTrans.setFinished(this.translateDateString(commit.getDateString()));
} catch (ParseException e) {
throw new GitImporterException("Error while parsing a commit date:\n" + e.getMessage());
}
// List<String> res = commit.getMergeDetails();
for (CommitFile commitFile : commit.getFiles()) {
LOGGER.debug("found file " + commitFile.getName());
// Check if the file in this commit has already been found in an earlier commit
VersionedFile file = this.createFile(commitFile.getName());
Revision revision = new Revision(commit.getSha());
revision.setFile(file);
if (filesContent != null && !filesContent.isEmpty()) {
String source = filesContent.get(commitFile.getName());
if (source != null) {
revision.setSource(source);
}
}
revision.setState(commitFile.getChangeType());
Person author = this.createPerson(commit.getAuthor());
this.createModificationReport(commitFile, commit, revision, author);
// Getting the committer role and adding this new revision to it
for (Role r : author.getRoles()) {
if (r instanceof CommitterRole) {
((CommitterRole) r).addRevision(revision);
break;
}
}
Revision latestRevision = file.getLatestRevision();
if (latestRevision != null) {
latestRevision.setNextRevision(revision);
revision.setPreviousRevision(latestRevision);
}
file.addRevision(revision);
revision.addRelease(fCurrRelease);
fCurrRelease.addRevision(revision);
currTrans.addRevision(revision);
LOGGER.debug("Created Revision " + revision.getNumber() + " for file " + file.getName()
+ " in release " + fCurrRelease.getName());
}
} else {
LOGGER.info("Commit " + commit.getSha() + " was empty so I'm skipping it");