Search in sources :

Example 56 with ChangeSet

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);
}
Also used : DefaultLog(org.apache.maven.scm.log.DefaultLog) LinkedHashMap(java.util.LinkedHashMap) ScmFileStatus(org.apache.maven.scm.ScmFileStatus) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ChangeFile(org.apache.maven.scm.ChangeFile) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) ChangeFile(org.apache.maven.scm.ChangeFile) File(java.io.File) ChangeSet(org.apache.maven.scm.ChangeSet) SimpleDateFormat(java.text.SimpleDateFormat)

Example 57 with ChangeSet

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);
    }
}
Also used : Pattern(java.util.regex.Pattern) ChangeLogSet(org.apache.maven.scm.command.changelog.ChangeLogSet) ChangeSet(org.apache.maven.scm.ChangeSet)

Example 58 with ChangeSet

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();
}
Also used : HashMap(java.util.HashMap) ChangeFile(org.apache.maven.scm.ChangeFile) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) ChangeSet(org.apache.maven.scm.ChangeSet)

Example 59 with ChangeSet

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_();
}
Also used : ArrayList(java.util.ArrayList) ChangeSet(org.apache.maven.scm.ChangeSet)

Example 60 with ChangeSet

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);
    }
}
Also used : ChangeSet(org.apache.maven.scm.ChangeSet)

Aggregations

ChangeSet (org.apache.maven.scm.ChangeSet)62 ChangeFile (org.apache.maven.scm.ChangeFile)34 ArrayList (java.util.ArrayList)21 Date (java.util.Date)18 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)16 File (java.io.File)15 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)15 Matcher (java.util.regex.Matcher)8 ScmException (org.apache.maven.scm.ScmException)8 BufferedReader (java.io.BufferedReader)7 SimpleDateFormat (java.text.SimpleDateFormat)7 ScmFile (org.apache.maven.scm.ScmFile)6 ScmFileSet (org.apache.maven.scm.ScmFileSet)5 ScmResult (org.apache.maven.scm.ScmResult)5 DefaultLog (org.apache.maven.scm.log.DefaultLog)5 FileReader (java.io.FileReader)4 List (java.util.List)4 ScmFileStatus (org.apache.maven.scm.ScmFileStatus)4 FileInputStream (java.io.FileInputStream)3 InputStreamReader (java.io.InputStreamReader)3