Details

    • Type: Improvement Improvement
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.8.1
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      maven-changelog-plugin v.1.7.3
      VSS v. 6.0
      Windows XP pro
    • Testcase included:
      yes
    • Number of attachments :
      1

      Description

      The issue 'MPCHANGELOG-65' raises a real problem since vss feed is formatted according to regional settings of the machine. Moreover there is no way in java to get those regional settings (cf: http://forum.java.sun.com/thread.jspa?threadID=24929&messageID=2636438). So, by default we can expect to get the following VSS date format : 'MM/dd/yy h:mma' which could be overwritten if necessary with property 'maven.changelog.vsslib.dateFormat'.

      For instance, in Geneva (fr_CH), the correct date format is 'dd/MM/yy HH:mm'.

      The patch enclosed include this improvement with others minor changes:

      • Add jUnit tests with dummy VSS history feed
      • Fix bug when vss project specified in the scm connection string ended with '/'. In that case we got an exception 'String out of range : -1'
      • Patch submitted with issue 'MPCHANGELOG-65' to fix bug when vss history feed contained label items didn't pass junit tests.

      thanks

        Activity

        Hide
        Brett Porter added a comment -

        can you please include this as a diff against the latest version from subversion?

        Thanks.

        Show
        Brett Porter added a comment - can you please include this as a diff against the latest version from subversion? Thanks.
        Hide
        Freddy Mallet added a comment -

        Modifications in VssConnection:.java:
        Fix bug when vss project specified in the scm connection string ended with '/'. In that case we got an exception 'String out of range : -1'
        =========================================
        BEFORE:
        vssProject = splitedConnection[4];
        NOW:
        vssProject = splitedConnection[4];
        if(vssProject.lastIndexOf("/") == vssProject.length() - 1)

        { vssProject = vssProject.substring(0, vssProject.length() - 1); }

        Modifications in VssChangeLogParser:.java:
        Patch submitted with issue 'MPCHANGELOG-65' to fix bug when vss history feed contained label items didn't pass junit tests.
        =========================================
        BEFORE:
        private static final String START_FILE = "***** "
        NOW:
        private static final String START_FILE = "****";


        BEFORE:
        setCurrentFile(new ChangeLogFile(fileLine[2]));
        NOW:
        if (fileLine.length > 2)

        { setCurrentFile(new ChangeLogFile(fileLine[2])); }

        Modifications in VssChangeLogParser:.java:
        Solve regional setting issue (MPCHANGELOG-65)
        =========================================

        BEFORE:
        entry.setDate(parseDate((String) vector.get(3) + " "
        + (String) vector.get(5)));
        NOW:
        String date = (String) vector.get(3);
        String time = (String) vector.get(5);
        time = time.replaceAll("a", "AM");
        time = time.replaceAll("p", "PM");
        entry.setDate(parseDate(date
        + " " + time));


        BEFORE:
        SimpleDateFormat format = new SimpleDateFormat("dd.MM.yy HH:mm");
        NOW:
        SimpleDateFormat format = getLocalVssDateFormat();


        BEFORE:
        try

        { SimpleDateFormat format = new SimpleDateFormat("dd.MM.yy HH:mm"); Date date = format.parse(dateString); return date; }

        catch (ParseException e)

        { LOG.error("ParseException Caught", e); return null; }

        NOW:
        try

        { SimpleDateFormat format = getLocalVssDateFormat(); Date date = format.parse(dateString); return date; }

        catch (ParseException e)

        { throw new RuntimeException( "VSS date : '" + dateString + "' doesn't match following date format : '" + getLocalVssDateFormat().toPattern() + "'. Please specify appropriate date format with 'maven.changelog.vsslib.dateFormat' property.", e); }

        /**

        • Vss client format history feed is based on the regional settings of the
        • machine. There's no way to get the pattern that is set on the system's
        • settings (expect through JNI calls). The default format 'MM/dd/yy h:mma'
        • correspond to en_US regional settings. This format can be overwritten
        • with property 'maven.changelog.vsslib.dateFormat'.
          */
          private SimpleDateFormat getLocalVssDateFormat()
          Unknown macro: { String dateFormat = null; try { org.apache.maven.jelly.MavenJellyContext mavenJellyContext = org.apache.maven.MavenUtils .createContext(new java.io.File(".")); dateFormat = (String) mavenJellyContext .getVariable("maven.changelog.vsslib.dateFormat"); } catch (Exception e) { logger.debug("Unexpected error occurred when trying to read" + " 'maven.changelog.vsslib.dateFormat' property", e); } if (dateFormat == null) { dateFormat = "MM/dd/yy h:mma"; } return new SimpleDateFormat(dateFormat); }

        Show
        Freddy Mallet added a comment - Modifications in VssConnection:.java: Fix bug when vss project specified in the scm connection string ended with '/'. In that case we got an exception 'String out of range : -1' ========================================= BEFORE: vssProject = splitedConnection [4] ; NOW: vssProject = splitedConnection [4] ; if(vssProject.lastIndexOf("/") == vssProject.length() - 1) { vssProject = vssProject.substring(0, vssProject.length() - 1); } Modifications in VssChangeLogParser:.java: Patch submitted with issue ' MPCHANGELOG-65 ' to fix bug when vss history feed contained label items didn't pass junit tests. ========================================= BEFORE: private static final String START_FILE = "***** " NOW: private static final String START_FILE = "****"; BEFORE: setCurrentFile(new ChangeLogFile(fileLine [2] )); NOW: if (fileLine.length > 2) { setCurrentFile(new ChangeLogFile(fileLine[2])); } Modifications in VssChangeLogParser:.java: Solve regional setting issue ( MPCHANGELOG-65 ) ========================================= BEFORE: entry.setDate(parseDate((String) vector.get(3) + " " + (String) vector.get(5))); NOW: String date = (String) vector.get(3); String time = (String) vector.get(5); time = time.replaceAll("a", "AM"); time = time.replaceAll("p", "PM"); entry.setDate(parseDate(date + " " + time)); BEFORE: SimpleDateFormat format = new SimpleDateFormat("dd.MM.yy HH:mm"); NOW: SimpleDateFormat format = getLocalVssDateFormat(); BEFORE: try { SimpleDateFormat format = new SimpleDateFormat("dd.MM.yy HH:mm"); Date date = format.parse(dateString); return date; } catch (ParseException e) { LOG.error("ParseException Caught", e); return null; } NOW: try { SimpleDateFormat format = getLocalVssDateFormat(); Date date = format.parse(dateString); return date; } catch (ParseException e) { throw new RuntimeException( "VSS date : '" + dateString + "' doesn't match following date format : '" + getLocalVssDateFormat().toPattern() + "'. Please specify appropriate date format with 'maven.changelog.vsslib.dateFormat' property.", e); } /** Vss client format history feed is based on the regional settings of the machine. There's no way to get the pattern that is set on the system's settings (expect through JNI calls). The default format 'MM/dd/yy h:mma' correspond to en_US regional settings. This format can be overwritten with property 'maven.changelog.vsslib.dateFormat'. */ private SimpleDateFormat getLocalVssDateFormat() Unknown macro: { String dateFormat = null; try { org.apache.maven.jelly.MavenJellyContext mavenJellyContext = org.apache.maven.MavenUtils .createContext(new java.io.File(".")); dateFormat = (String) mavenJellyContext .getVariable("maven.changelog.vsslib.dateFormat"); } catch (Exception e) { logger.debug("Unexpected error occurred when trying to read" + " 'maven.changelog.vsslib.dateFormat' property", e); } if (dateFormat == null) { dateFormat = "MM/dd/yy h:mma"; } return new SimpleDateFormat(dateFormat); }
        Hide
        Emmanuel Venisse added a comment -

        Can you send a diff file? it will be more easy to apply.

        Show
        Emmanuel Venisse added a comment - Can you send a diff file? it will be more easy to apply.

          People

          • Assignee:
            Unassigned
            Reporter:
            Freddy Mallet
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: