Support gitlab archives

PY-26364 fixed.
This commit is contained in:
Semyon Proshev
2017-10-05 16:53:04 +03:00
parent 1f2abf3afd
commit 2f4dd5c73d
2 changed files with 31 additions and 33 deletions
@@ -1,18 +1,16 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2017 JetBrains s.r.o.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.jetbrains.python.packaging;
import com.intellij.openapi.editor.Document;
@@ -61,6 +59,10 @@ public class PyRequirement {
private static final Pattern GITHUB_ARCHIVE_URL =
Pattern.compile("https?://github\\.com/[^/\\s]+/(?<" + NAME_GROUP + ">[^/\\s]+)/archive/\\S+" + COMMENT_REGEXP);
@NotNull
private static final Pattern GITLAB_ARCHIVE_URL =
Pattern.compile("https?://gitlab\\.com/[^/\\s]+/(?<" + NAME_GROUP + ">[^/\\s]+)/repository/\\S+" + COMMENT_REGEXP);
@NotNull
private static final Pattern ARCHIVE_URL =
Pattern.compile("https?://\\S+/" +
@@ -309,11 +311,16 @@ public class PyRequirement {
@Nullable
public static PyRequirement fromLine(@NotNull String line) {
final PyRequirement githubArchiveUrl = parseGithubArchiveUrl(line);
final PyRequirement githubArchiveUrl = parseGitArchiveUrl(GITHUB_ARCHIVE_URL, line);
if (githubArchiveUrl != null) {
return githubArchiveUrl;
}
final PyRequirement gitlabArchiveUrl = parseGitArchiveUrl(GITLAB_ARCHIVE_URL, line);
if (gitlabArchiveUrl != null) {
return gitlabArchiveUrl;
}
final PyRequirement archiveUrl = parseArchiveUrl(line);
if (archiveUrl != null) {
return archiveUrl;
@@ -349,8 +356,8 @@ public class PyRequirement {
}
@Nullable
private static PyRequirement parseGithubArchiveUrl(@NotNull String line) {
final Matcher matcher = GITHUB_ARCHIVE_URL.matcher(line);
private static PyRequirement parseGitArchiveUrl(@NotNull Pattern pattern, @NotNull String line) {
final Matcher matcher = pattern.matcher(line);
if (matcher.matches()) {
return new PyRequirement(matcher.group(NAME_GROUP), Collections.emptyList(), Collections.singletonList(dropComments(line, matcher)));
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python.packaging;
import com.intellij.openapi.util.Pair;
@@ -80,6 +66,11 @@ public class PyRequirementTest extends PyTestCase {
doTest("https://github.com/divio/MyProject1/archive/master.zip?1450634746.0107164");
}
// PY-26364
public void testGitlabArchiveUrl() {
doTest("https://gitlab.com/mrh1997/MyProject1/repository/master/archive.zip");
}
// VCS
// PY-6328
public void testGit() {