Skip to content

Commit

Permalink
Improve robustness of change log parsing.
Browse files Browse the repository at this point in the history
Enable blank lines, leading white space, and comments inside of the
change log text.
  • Loading branch information
GraylinKim committed Apr 30, 2012
1 parent 74149d0 commit be950fa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/gov/nysenate/openleg/scripts/Push.java
Expand Up @@ -22,10 +22,13 @@

public class Push {
private static Logger logger = Logger.getLogger(Push.class);
private static Pattern changePattern = Pattern.compile("(.*)\\s+(NEW|DELETE|MODIFIED)");
private static Pattern changePattern = Pattern.compile("\\s*(.*)\\s+(NEW|DELETE|MODIFIED)");
public static HashMap<String, Storage.Status> parseChanges(Iterable<String> lines) {
HashMap<String, Storage.Status> changes = new HashMap<String, Storage.Status>();
for (String line : lines) {
if (line.isEmpty() || line.matches("\\s*#")) {
continue;
}
Matcher changeLine = changePattern.matcher(line);
if (changeLine.find()) {
changes.put(changeLine.group(1), Storage.Status.valueOf(changeLine.group(2).toUpperCase()));
Expand Down

0 comments on commit be950fa

Please sign in to comment.