Skip to content
Permalink
Browse files
402: Properly parse issue titles starting with non-alphanumeric chara…
…cters

Reviewed-by: jvernee
  • Loading branch information
rwestberg committed May 26, 2020
1 parent c95cf5a commit 96f757338c26a8a8b9a4f1d1d91dadd4d30804b6
Showing with 44 additions and 1 deletion.
  1. +1 −1 vcs/src/main/java/org/openjdk/skara/vcs/openjdk/Issue.java
  2. +43 −0 vcs/src/test/java/org/openjdk/skara/vcs/openjdk/IssueTests.java
@@ -30,7 +30,7 @@ public class Issue {
private final String shortId;
private final String description;

private final static Pattern relaxedIssueParsePattern = Pattern.compile("^((?:[A-Z][A-Z0-9]+-)?[0-9]+)[^\\p{Alnum}]+(\\S.*)$");
private final static Pattern relaxedIssueParsePattern = Pattern.compile("^((?:[A-Z][A-Z0-9]+-)?[0-9]+)[^\\p{Alnum}]*\\s(\\S.*)$");

public Issue(String id, String description) {
if (id.contains("-")) {
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.skara.vcs.openjdk;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class IssueTests {
@Test
void parseRelaxed() {
assertEquals("Description", Issue.fromStringRelaxed("1234: Description").orElseThrow().description());
assertEquals("Description", Issue.fromStringRelaxed("1234 Description").orElseThrow().description());
assertEquals("Description", Issue.fromStringRelaxed("1234 Description").orElseThrow().description());
assertEquals("Description", Issue.fromStringRelaxed("1234 - Description").orElseThrow().description());
assertEquals("Description", Issue.fromStringRelaxed("1234 - Description").orElseThrow().description());
assertEquals("-Description", Issue.fromStringRelaxed("1234 -Description").orElseThrow().description());
assertEquals("-Description", Issue.fromStringRelaxed("1234 - -Description").orElseThrow().description());
assertEquals("[Description]", Issue.fromStringRelaxed("1234: [Description]").orElseThrow().description());
assertEquals("[Description]", Issue.fromStringRelaxed("1234 [Description]").orElseThrow().description());
assertEquals("[Description]", Issue.fromStringRelaxed("1234 - [Description]").orElseThrow().description());
}
}

0 comments on commit 96f7573

Please sign in to comment.