Fixed parsing VCS requirements with '/' in revision (PY-8623)

This commit is contained in:
Andrey Vlasovskikh
2013-01-28 17:01:09 +04:00
parent abbbfce09a
commit bd508c2dcc
2 changed files with 10 additions and 2 deletions
@@ -25,7 +25,7 @@ public class PyRequirement {
private static final Pattern VERSION_SPEC = Pattern.compile("\\s*(<=?|>=?|==|!=)\\s*((\\w|[-.])+)");
private static final Pattern EDITABLE_EGG = Pattern.compile("\\s*(-e)?\\s*([^#]*)(#egg=(.*))?");
private static final Pattern RECURSIVE_REQUIREMENT = Pattern.compile("\\s*-r\\s+(.*)");
private static final Pattern VCS_PATH = Pattern.compile(".*/([^@/]+)/?(@.*)?");
private static final Pattern VCS_PATH = Pattern.compile(".*/([^/]+)/?");
public enum Relation {
LT("<"),
@@ -408,8 +408,10 @@ public class PyRequirement {
try {
final URI uri = new URI(url);
if (uri.getScheme() != null) {
final String path = uri.getPath();
String path = uri.getPath();
if (path != null) {
final String[] split = path.split("@", 2);
path = split[0];
final Matcher vcsPathMatcher = VCS_PATH.matcher(path);
if (!vcsPathMatcher.matches()) {
return null;
@@ -79,6 +79,12 @@ public class PyRequirementTest extends PyTestCase {
PyRequirement.fromString("hg+ssh://hg@bitbucket.org/jespern/django-piston/"));
}
// PY-8623
public void testGitRevisionWithSlash() {
assertEquals(new PyRequirement("django", null, "git+git://github.com/django/django.git@stable/1.5.x", false),
PyRequirement.fromString("git+git://github.com/django/django.git@stable/1.5.x"));
}
private static <T> List<T> list(T... xs) {
return Arrays.asList(xs);
}