use of org.apache.maven.scm.ChangeFile in project maven-plugins by apache.
the class FileActivityReport method getOrderedFileList.
/**
* reads the change log entries and generates a list of files changed order by the number of times edited. This
* used the FileActivityComparator Object to sort the list
*
* @param entries the changelog entries to generate the report
* @return list of changed files within the SCM with the number of times changed in descending order
*/
private List<List<ChangeFile>> getOrderedFileList(Collection<ChangeSet> entries) {
List<List<ChangeFile>> list = new LinkedList<List<ChangeFile>>();
Map<String, List<ChangeFile>> map = new HashMap<String, List<ChangeFile>>();
for (ChangeSet entry : entries) {
for (ChangeFile file : entry.getFiles()) {
List<ChangeFile> revisions = map.get(file.getName());
if (revisions == null) {
revisions = new LinkedList<ChangeFile>();
map.put(file.getName(), revisions);
}
revisions.add(file);
}
}
list.addAll(map.values());
Collections.sort(list, new FileActivityComparator());
return list;
}
use of org.apache.maven.scm.ChangeFile 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.ChangeFile in project maven-plugins by apache.
the class FileActivityComparator method sortByName.
/**
* compares list1 and list2 by comparing their filenames. Least priority sorting when both number of commits and
* and revision are the same
*
* @param list1 the first object in a compare statement
* @param list2 the object to compare list1 against
* @return an integer describing the order comparison of list1 and list2
*/
private int sortByName(List<ChangeFile> list1, List<ChangeFile> list2) {
ChangeFile file1 = list1.get(0);
ChangeFile file2 = list2.get(0);
return file1.getName().compareTo(file2.getName());
}
use of org.apache.maven.scm.ChangeFile in project maven-plugins by apache.
the class ChangeLogTest method testReadFile.
public void testReadFile() throws Exception {
List<ChangeLogSet> changedLogs = readChangeLogXml("min-changelog.xml");
assertNotNull("Test changedSets were parsed", changedLogs);
assertEquals("Test number of changelog entries", 2, changedLogs.size());
ChangeLogSet changelogSets = changedLogs.get(0);
assertEquals("Test number of revisions on changelog 1", 2, changelogSets.getChangeSets().size());
ChangeSet changeSet = changelogSets.getChangeSets().get(0);
assertEquals("Test changelog 1 set 1 date/time", "1977-08-06 05:30:00", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(changeSet.getDate()));
assertEquals("Test changelog 1 set 1 author", "Edwin Punzalan", changeSet.getAuthor());
assertEquals("Test changelog 1 set 1 msg", "First commit msg", changeSet.getComment());
assertEquals("Test changelog 1 set 1 files", 1, changeSet.getFiles().size());
ChangeFile changeFile = changeSet.getFiles().get(0);
assertEquals("Test changelog 1 set 1 file 1 filename", "/path/to/file.extension", changeFile.getName());
assertEquals("Test changelog 1 set 1 file 1 revision", "1", changeFile.getRevision());
changeSet = changelogSets.getChangeSets().get(1);
assertEquals("Test changelog 1 set 2 date/time", "2005-02-24 21:30:00", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(changeSet.getDate()));
assertEquals("Test changelog 1 set 2 author", "Edwin Punzalan", changeSet.getAuthor());
assertEquals("Test changelog 1 set 2 msg", "Second commit msg", changeSet.getComment());
assertEquals("Test changelog 1 set 2 files", 2, changeSet.getFiles().size());
changeFile = changeSet.getFiles().get(0);
assertEquals("Test changelog 1 set 2 file 1 filename", "/path/to/file.extension", changeFile.getName());
assertEquals("Test changelog 1 set 2 file 1 revision", "2", changeFile.getRevision());
changeFile = changeSet.getFiles().get(1);
assertEquals("Test changelog 1 set 2 file 2 filename", "/path/to/file2.extension", changeFile.getName());
assertEquals("Test changelog 1 set 2 file 2 revision", "2", changeFile.getRevision());
changelogSets = changedLogs.get(1);
assertEquals("Test number of revisions on changelog 2", 2, changelogSets.getChangeSets().size());
changeSet = changelogSets.getChangeSets().get(0);
assertEquals("Test changelog 2 set 1 date/time", "2005-02-25 22:45:00", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(changeSet.getDate()));
assertEquals("Test changelog 2 set 1 author", "Keogh Edrich Punzalan", changeSet.getAuthor());
assertEquals("Test changelog 2 set 1 msg", "Third commit msg", changeSet.getComment());
assertEquals("Test changelog 2 set 1 files", 1, changeSet.getFiles().size());
changeFile = changeSet.getFiles().get(0);
assertEquals("Test changelog 2 set 1 file 1 filename", "/path/to/file.extension", changeFile.getName());
assertEquals("Test changelog 2 set 1 file 1 revision", "3", changeFile.getRevision());
changeSet = changelogSets.getChangeSets().get(1);
assertEquals("Test changelog 2 set 2 date/time", "2100-02-25 05:30:00", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(changeSet.getDate()));
assertEquals("Test changelog 2 set 2 author", "Keogh Edrich Punzalan", changeSet.getAuthor());
assertEquals("Test changelog 2 set 2 msg", "Last commit msg", changeSet.getComment());
assertEquals("Test changelog 2 set 2 files", 2, changeSet.getFiles().size());
changeFile = changeSet.getFiles().get(0);
assertEquals("Test changelog 2 set 2 file 1 filename", "/path/to/file.extension", changeFile.getName());
assertEquals("Test changelog 2 set 2 file 1 revision", "4", changeFile.getRevision());
changeFile = changeSet.getFiles().get(1);
assertEquals("Test changelog 2 set 2 file 2 filename", "/path/to/file2.extension", changeFile.getName());
assertEquals("Test changelog 2 set 2 file 2 revision", "4", changeFile.getRevision());
}
use of org.apache.maven.scm.ChangeFile in project maven-plugins by apache.
the class FileActivityComparatorTest method testCompareByNumberOfCommits.
public void testCompareByNumberOfCommits() {
List<ChangeFile> list1 = new ArrayList<ChangeFile>();
list1.add(new ChangeFile("anything"));
List<ChangeFile> list2 = new ArrayList<ChangeFile>();
assertTrue("Test compare by commits, less than", comparator.compare(list1, list2) < 0);
list1 = new ArrayList<ChangeFile>();
list1.add(new ChangeFile("anything"));
list2 = new ArrayList<ChangeFile>();
list2.add(new ChangeFile("one thing"));
list2.add(new ChangeFile("something"));
assertTrue("Test compare by commits, greater than", comparator.compare(list1, list2) > 0);
}
Aggregations