Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix change log line parsing.

  • Loading branch information...
commit 5d273e82e5ab515a4f8038056fe9a8f6265890d6 1 parent b12893c
Graylin Kim authored April 12, 2012
11  src/main/java/gov/nysenate/openleg/scripts/Push.java
@@ -10,6 +10,8 @@
10 10
 import java.util.ArrayList;
11 11
 import java.util.Arrays;
12 12
 import java.util.HashMap;
  13
+import java.util.regex.Matcher;
  14
+import java.util.regex.Pattern;
13 15
 
14 16
 import org.apache.commons.cli.CommandLine;
15 17
 import org.apache.commons.cli.Options;
@@ -20,16 +22,17 @@
20 22
 
21 23
 public class Push {
22 24
     private static Logger logger = Logger.getLogger(Push.class);
23  
-
  25
+    private static Pattern changePattern = Pattern.compile("(.*)\\s+(NEW|DELETE|MODIFIED)");
24 26
     public static HashMap<String, Storage.Status> parseChanges(Iterable<String> lines) {
25 27
         HashMap<String, Storage.Status> changes = new HashMap<String, Storage.Status>();
26 28
         for (String line : lines) {
27  
-            String[] parts = line.split("\\s+");
28  
-            if (parts.length != 2) {
  29
+            Matcher changeLine = changePattern.matcher(line);
  30
+            if (changeLine.find()) {
  31
+                changes.put(changeLine.group(1), Storage.Status.valueOf(changeLine.group(2).toUpperCase()));
  32
+            } else {
29 33
                 logger.fatal("Malformed change line: "+line);
30 34
                 System.exit(0);
31 35
             }
32  
-            changes.put(parts[0], Storage.Status.valueOf(parts[1].toUpperCase()));
33 36
         }
34 37
         return changes;
35 38
     }

0 notes on commit 5d273e8

Please sign in to comment.
Something went wrong with that request. Please try again.