Search in sources :

Example 1 with ChangeFile

use of org.apache.maven.scm.ChangeFile in project maven-plugins by apache.

the class ChangeLogHandler method startElement.

/**
     * {@inheritDoc}
     */
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    bufData = "";
    if ("file".equals(qName)) {
        bufFile = new ChangeFile("");
    } else if ("changelog-entry".equals(qName)) {
        bufEntry = new ChangeSet();
    } else if ("date".equals(qName)) {
        currentPattern = attributes.getValue("pattern");
        if (currentPattern == null) {
            currentPattern = "yyyy-MM-dd";
        }
    } else if ("time".equals(qName)) {
        currentPattern = attributes.getValue("pattern");
        if (currentPattern == null) {
            currentPattern = "HH:mm:ss";
        }
    } else if ("changeset".equals(qName)) {
        bufEntries = new LinkedList<ChangeSet>();
        currentPattern = attributes.getValue("datePattern");
        if (currentPattern == null) {
            currentPattern = "yyyy-MM-dd";
        }
        SimpleDateFormat formatter = new SimpleDateFormat(currentPattern);
        String start = attributes.getValue("start");
        String end = attributes.getValue("end");
        Date startDate = null;
        Date endDate = null;
        if (start != null) {
            try {
                startDate = formatter.parse(start);
            } catch (ParseException e) {
                throw new SAXException("Can't parse start date '" + start + "'.", e);
            }
        }
        if (end != null) {
            try {
                endDate = formatter.parse(end);
            } catch (ParseException e) {
                throw new SAXException("Can't parse end date '" + end + "'.", e);
            }
        }
        bufSet = new ChangeLogSet(bufEntries, startDate, endDate);
        String startVersion = attributes.getValue("startVersion");
        if (startVersion != null) {
            bufSet.setStartVersion(new ScmTag(startVersion));
        }
        String endVersion = attributes.getValue("endVersion");
        if (endVersion != null) {
            bufSet.setEndVersion(new ScmTag(endVersion));
        }
    }
}
Also used : ChangeLogSet(org.apache.maven.scm.command.changelog.ChangeLogSet) ChangeFile(org.apache.maven.scm.ChangeFile) ScmTag(org.apache.maven.scm.ScmTag) ParseException(java.text.ParseException) ChangeSet(org.apache.maven.scm.ChangeSet) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) SAXException(org.xml.sax.SAXException)

Example 2 with ChangeFile

use of org.apache.maven.scm.ChangeFile in project maven-plugins by apache.

the class ChangeLogReport method filter.

private void filter(List<ChangeSet> sets, List<Pattern> includes, List<Pattern> excludes) {
    Iterator<ChangeSet> it = sets.iterator();
    while (it.hasNext()) {
        ChangeSet changeSet = it.next();
        List<ChangeFile> files = changeSet.getFiles();
        Iterator<ChangeFile> iterator = files.iterator();
        while (iterator.hasNext()) {
            ChangeFile changeFile = iterator.next();
            String name = changeFile.getName();
            if (!isIncluded(includes, name) || isExcluded(excludes, name)) {
                iterator.remove();
            }
        }
        if (files.isEmpty()) {
            it.remove();
        }
    }
}
Also used : ChangeFile(org.apache.maven.scm.ChangeFile) ChangeSet(org.apache.maven.scm.ChangeSet)

Example 3 with ChangeFile

use of org.apache.maven.scm.ChangeFile in project maven-plugins by apache.

the class DeveloperActivityReport method countDevFiles.

/**
     * counts the number of files changed by each developer
     *
     * @param entries the change log entries used to search and count file changes
     */
private void countDevFiles(Collection<ChangeSet> entries) {
    for (ChangeSet entry : entries) {
        String developer = entry.getAuthor();
        Map<String, ChangeFile> filesMap = files.get(developer);
        if (filesMap == null) {
            filesMap = new HashMap<String, ChangeFile>();
            files.put(developer, filesMap);
        }
        for (ChangeFile file : entry.getFiles()) {
            filesMap.put(file.getName(), file);
        }
    }
}
Also used : ChangeFile(org.apache.maven.scm.ChangeFile) ChangeSet(org.apache.maven.scm.ChangeSet)

Example 4 with ChangeFile

use of org.apache.maven.scm.ChangeFile in project maven-plugins by apache.

the class FileActivityReport method doRows.

/**
     * generates the row details for the file activity report
     *
     * @param set  the changelog set to generate a report with
     * @param sink the report formatting tool
     */
private void doRows(ChangeLogSet set, Sink sink) {
    List<List<ChangeFile>> list = getOrderedFileList(set.getChangeSets());
    initReportUrls();
    for (List<ChangeFile> revision : list) {
        ChangeFile file = revision.get(0);
        sink.tableRow();
        sink.tableCell();
        try {
            generateLinks(getConnection(), file.getName(), sink);
        } catch (Exception e) {
            if (getLog().isDebugEnabled()) {
                getLog().error(e.getMessage(), e);
            } else {
                getLog().error(e.getMessage());
            }
            sink.text(file.getName());
        }
        sink.tableCell_();
        sink.tableCell();
        sink.text("" + revision.size());
        sink.tableCell_();
        sink.tableRow_();
    }
}
Also used : ChangeFile(org.apache.maven.scm.ChangeFile) List(java.util.List) LinkedList(java.util.LinkedList)

Example 5 with ChangeFile

use of org.apache.maven.scm.ChangeFile in project maven-plugins by apache.

the class FileActivityComparatorTest method testCompareByRevision.

public void testCompareByRevision() {
    List<ChangeFile> list1 = new ArrayList<ChangeFile>();
    list1.add(new ChangeFile("changefile-1", "123"));
    list1.add(new ChangeFile("changefile-1", "234"));
    List<ChangeFile> list2 = new ArrayList<ChangeFile>();
    list2.add(new ChangeFile("changefile-2", "246"));
    list2.add(new ChangeFile("changefile-2", "468"));
    assertTrue("Test compare by revision, less than", comparator.compare(list1, list2) < 0);
    list1 = new ArrayList<ChangeFile>();
    list1.add(new ChangeFile("changefile-1", "246"));
    list1.add(new ChangeFile("changefile-1", "468"));
    list2 = new ArrayList<ChangeFile>();
    list2.add(new ChangeFile("changefile-2", "123"));
    list2.add(new ChangeFile("changefile-2", "234"));
    assertTrue("Test compare by revision, greater than", comparator.compare(list1, list2) > 0);
}
Also used : ChangeFile(org.apache.maven.scm.ChangeFile) ArrayList(java.util.ArrayList)

Aggregations

ChangeFile (org.apache.maven.scm.ChangeFile)11 ChangeSet (org.apache.maven.scm.ChangeSet)6 ArrayList (java.util.ArrayList)4 LinkedList (java.util.LinkedList)3 List (java.util.List)3 SimpleDateFormat (java.text.SimpleDateFormat)2 HashMap (java.util.HashMap)2 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)2 ParseException (java.text.ParseException)1 Date (java.util.Date)1 ScmTag (org.apache.maven.scm.ScmTag)1 SAXException (org.xml.sax.SAXException)1