use of org.apache.maven.scm.ChangeSet in project maven-scm by apache.
the class GitChangeLogConsumerTest method testConsumer2.
public void testConsumer2() throws Exception {
GitChangeLogConsumer consumer = new GitChangeLogConsumer(new DefaultLog(), null);
File f = getTestFile("/src/test/resources/git/changelog/gitwhatchanged2.gitlog");
BufferedReader r = new BufferedReader(new FileReader(f));
String line;
while ((line = r.readLine()) != null) {
consumer.consumeLine(line);
}
List<ChangeSet> modifications = consumer.getModifications();
// must use *Linked* HashMap to have predictable toString
final Map<ScmFileStatus, AtomicInteger> summary = new LinkedHashMap<ScmFileStatus, AtomicInteger>();
for (Iterator<ChangeSet> i = modifications.iterator(); i.hasNext(); ) {
ChangeSet entry = i.next();
assertEquals("Mark Struberg <struberg@yahoo.de>", entry.getAuthor());
assertNotNull(entry.getDate());
assertTrue(entry.getComment() != null && entry.getComment().length() > 0);
assertNotNull(entry.getRevision());
assertNotNull(entry.getFiles());
assertFalse(entry.getFiles().isEmpty());
for (ChangeFile file : entry.getFiles()) {
final ScmFileStatus action = file.getAction();
if (!summary.containsKey(action)) {
summary.put(action, new AtomicInteger());
}
summary.get(action).incrementAndGet();
}
}
Assert.assertEquals("Action summary differs from expectations", "{modified=21, added=88, deleted=1}", summary.toString());
assertEquals(8, modifications.size());
ChangeSet entry = modifications.get(4);
assertEquals("Mark Struberg <struberg@yahoo.de>", entry.getAuthor());
assertNotNull(entry.getDate());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
assertEquals("2007-11-27 13:05:36 +0000", sdf.format(entry.getDate()));
assertEquals("52733aa427041cafd760833cb068ffe897fd35db", entry.getRevision());
assertEquals("fixed a GitCommandLineUtil and provice first version of the checkin command.", entry.getComment());
assertNotNull(entry.getFiles());
assertEquals(10, entry.getFiles().size());
ChangeFile cf = entry.getFiles().get(0);
assertEquals("maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/GitCommandLineUtils.java", cf.getName());
assertTrue(cf.getRevision() != null && cf.getRevision().length() > 0);
}
use of org.apache.maven.scm.ChangeSet in project maven-plugins by apache.
the class ChangeLogReport method filter.
/**
* filters out unwanted files from the changesets
*/
private void filter(List<ChangeLogSet> changeSets) {
List<Pattern> include = compilePatterns(includes);
List<Pattern> exclude = compilePatterns(excludes);
if (includes == null && excludes == null) {
return;
}
for (ChangeLogSet changeLogSet : changeSets) {
List<ChangeSet> set = changeLogSet.getChangeSets();
filter(set, include, exclude);
}
}
use of org.apache.maven.scm.ChangeSet in project maven-plugins by apache.
the class ChangeLogReport method countFilesChanged.
/**
* counts the number of files that were changed in the specified SCM
*
* @param entries a collection of SCM changes
* @return number of files changed for the changedsets
*/
protected long countFilesChanged(Collection<ChangeSet> entries) {
if (entries == null) {
return 0;
}
if (entries.isEmpty()) {
return 0;
}
HashMap<String, List<ChangeFile>> fileList = new HashMap<String, List<ChangeFile>>();
for (ChangeSet entry : entries) {
for (ChangeFile file : entry.getFiles()) {
String name = file.getName();
List<ChangeFile> list = fileList.get(name);
if (list != null) {
list.add(file);
} else {
list = new LinkedList<ChangeFile>();
list.add(file);
fileList.put(name, list);
}
}
}
return fileList.size();
}
use of org.apache.maven.scm.ChangeSet in project maven-plugins by apache.
the class ChangeLogReport method doChangedSetTable.
/**
* generates the report table showing the SCM log entries
*
* @param entries a list of change log entries to generate the report from
* @param bundle the resource bundle to retrieve report phrases from
* @param sink the report formatting tool
*/
private void doChangedSetTable(Collection<ChangeSet> entries, ResourceBundle bundle, Sink sink) {
sink.table();
sink.tableRow();
sink.tableHeaderCell();
sink.text(bundle.getString("report.changelog.timestamp"));
sink.tableHeaderCell_();
sink.tableHeaderCell();
sink.text(bundle.getString("report.changelog.author"));
sink.tableHeaderCell_();
sink.tableHeaderCell();
sink.text(bundle.getString("report.changelog.details"));
sink.tableHeaderCell_();
sink.tableRow_();
initReportUrls();
List<ChangeSet> sortedEntries = new ArrayList<ChangeSet>(entries);
Collections.sort(sortedEntries, new Comparator<ChangeSet>() {
public int compare(ChangeSet changeSet0, ChangeSet changeSet1) {
return changeSet1.getDate().compareTo(changeSet0.getDate());
}
});
for (ChangeSet entry : sortedEntries) {
doChangedSetDetail(entry, sink);
}
sink.table_();
}
use of org.apache.maven.scm.ChangeSet in project maven-plugins by apache.
the class DeveloperActivityReport method countDevCommits.
/**
* counts the number of commits of each developer
*
* @param entries the change log entries used to search and count developer commits
*/
private void countDevCommits(Collection<ChangeSet> entries) {
for (ChangeSet entry : entries) {
String developer = entry.getAuthor();
List<ChangeSet> list = commits.get(developer);
if (list == null) {
list = new LinkedList<ChangeSet>();
commits.put(developer, list);
}
list.add(entry);
}
}
Aggregations