diff --git a/advisors/test/__init__.py b/advisors/test/__init__.py new file mode 100755 index 0000000000000000000000000000000000000000..a2a80e2a36f8bea115d24a02548324844ee075fe --- /dev/null +++ b/advisors/test/__init__.py @@ -0,0 +1,18 @@ +#!/usr/bin/python3 +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# +# ******************************************************************************/ + +import sys +import os + +sys.path.append(os.path.dirname(__file__) + "/../") \ No newline at end of file diff --git a/advisors/test/test_yaml2url.py b/advisors/test/test_yaml2url.py new file mode 100644 index 0000000000000000000000000000000000000000..f27ce1e2c4e78dbaa61064e4152cd17013054ca3 --- /dev/null +++ b/advisors/test/test_yaml2url.py @@ -0,0 +1,167 @@ +# !/usr/bin/python3 +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# +# ******************************************************************************/ +""" +This is an test script for get url from repo name +""" +import yaml + +import yaml2url + +YAML_DOC = """ + version_control: {version_control} + src_repo: {src_repo} +""" + + +def test_get_hg_url(): + """ + Test hg repo url + """ + doc = YAML_DOC.format(version_control="hg", + src_repo="https://hg.mozilla.org/projects/python-nss") + + pkg_info = yaml.load(doc, Loader=yaml.Loader) + url = yaml2url.yaml2url(pkg_info) + assert url == "https://hg.mozilla.org/projects/python-nss/raw-tags" + + +def test_get_hg_raw_url(): + """ + Test hg raw repo url + """ + doc = YAML_DOC.format(version_control="hg-raw", + src_repo="http://hg.libsdl.org/SDL") + + pkg_info = yaml.load(doc, Loader=yaml.Loader) + url = yaml2url.yaml2url(pkg_info) + assert url == "http://hg.libsdl.org/SDL/json-tags" + + +def test_get_github_url(): + """ + Test github repo url + """ + doc = YAML_DOC.format(version_control="github", + src_repo="pixel/hexedit") + + pkg_info = yaml.load(doc, Loader=yaml.Loader) + url = yaml2url.yaml2url(pkg_info) + assert url == "https://github.com/pixel/hexedit.git" + + +def test_get_gnome_url(): + """ + Test gnome repo url + """ + doc = YAML_DOC.format(version_control="gitlab.gnome", + src_repo="gdm") + + pkg_info = yaml.load(doc, Loader=yaml.Loader) + url = yaml2url.yaml2url(pkg_info) + assert url == "https://gitlab.gnome.org/GNOME/gdm.git" + + +def test_get_git_url(): + """ + Test git repo url + """ + doc = YAML_DOC.format(version_control="git", + src_repo="git://sourceware.org/git/glibc.git") + + pkg_info = yaml.load(doc, Loader=yaml.Loader) + url = yaml2url.yaml2url(pkg_info) + assert url == "git://sourceware.org/git/glibc.git" + + +def test_get_svn_url(): + """ + Test svn repo url + """ + doc = YAML_DOC.format(version_control="svn", + src_repo="https://svn.apache.org/repos/asf/apr/apr") + + pkg_info = yaml.load(doc, Loader=yaml.Loader) + url = yaml2url.yaml2url(pkg_info) + assert url == "https://svn.apache.org/repos/asf/apr/apr/tags" + + +def test_get_metacpan_url(): + """ + Test metacpan repo url + """ + doc = YAML_DOC.format(version_control="metacpan", + src_repo="File-Which") + + pkg_info = yaml.load(doc, Loader=yaml.Loader) + url = yaml2url.yaml2url(pkg_info) + assert url == "https://metacpan.org/release/File-Which" + + +def test_get_rubygem_url(): + """ + Test rubygem repo url + """ + doc = YAML_DOC.format(version_control="rubygem", + src_repo="path") + + pkg_info = yaml.load(doc, Loader=yaml.Loader) + url = yaml2url.yaml2url(pkg_info) + assert url == "https://rubygems.org/api/v1/versions/path.json" + + +def test_get_gitee_url(): + """ + Test gitee repo url + """ + doc = YAML_DOC.format(version_control="gitee", + src_repo="openEuler/lcr") + + pkg_info = yaml.load(doc, Loader=yaml.Loader) + url = yaml2url.yaml2url(pkg_info) + assert url == "https://gitee.com/openEuler/lcr" + + +def test_get_gnu_ftp_url(): + """ + Test gnu ftp repo url + """ + doc = YAML_DOC.format(version_control="gnu-ftp", + src_repo="bc") + + pkg_info = yaml.load(doc, Loader=yaml.Loader) + url = yaml2url.yaml2url(pkg_info) + assert url == "https://ftp.gnu.org/gnu/bc/" + +def test_get_ftp_url(): + """ + Test ftp repo url + """ + doc = YAML_DOC.format(version_control="ftp", + src_repo="https://ftp.gnu.org/pub/gnu/mailman") + + pkg_info = yaml.load(doc, Loader=yaml.Loader) + url = yaml2url.yaml2url(pkg_info) + assert url == "https://ftp.gnu.org/pub/gnu/mailman/" + + +def test_get_pypi_url(): + """ + Test pypi repo url + """ + doc = YAML_DOC.format(version_control="pypi", + src_repo="pygments") + + pkg_info = yaml.load(doc, Loader=yaml.Loader) + url = yaml2url.yaml2url(pkg_info) + assert url == "https://pypi.org/pypi/pygments/json" diff --git a/advisors/yaml2url.py b/advisors/yaml2url.py index e886d3def6d474914ff7580c72ec925f08a7e7c1..27ca68b4d035353ac9956bb60280a99a79205cf7 100755 --- a/advisors/yaml2url.py +++ b/advisors/yaml2url.py @@ -79,14 +79,6 @@ def __get_metacpan_url(pkg_info): return url -def _get_rubygem_url(pkg_info): - """ - Get rubygem repo url of package - """ - url = urljoin("https://rubygems.org/api/v1/versions/", pkg_info["src_repo"] + ".json") - return url - - def __get_gitee_url(pkg_info): """ Get gitee repo url of package diff --git a/upstream-info/acpid.yaml b/upstream-info/acpid.yaml index d63055df694d4253e247e87139ed5e4b02ab5616..d54f733d947f341cd455379ed4dca9dde1cfa3fc 100644 --- a/upstream-info/acpid.yaml +++ b/upstream-info/acpid.yaml @@ -3,4 +3,4 @@ version_control: git src_repo: git://git.code.sf.net/p/acpid2/code tag_prefix: separator: "." -git_url: git://git.code.sf.net/p/acpid2/code acpid2-code +git_url: git://git.code.sf.net/p/acpid2/code diff --git a/upstream-info/clucene.yaml b/upstream-info/clucene.yaml index 3e3c882f6fe00ce385e6d8fb5e759f1f5eb25559..fdd8a940cc4c7249404a548e1289f3ebd8a17975 100644 --- a/upstream-info/clucene.yaml +++ b/upstream-info/clucene.yaml @@ -1,8 +1,8 @@ --- version_control: git -src_repo: https://git.code.sf.net/p/clucene/code +src_repo: https://git.code.sf.net/p/clucene/code.git tag_prefix: "^clucene-src-" separator: "." -git_url: https://git.code.sf.net/p/clucene/code +git_url: https://git.code.sf.net/p/clucene/code.git git_tag: - 2011-03-17 clucene-src-2.3.3.4 diff --git a/upstream-info/desktop-file-utils.yaml b/upstream-info/desktop-file-utils.yaml index 62bbc786ade716b6ac0ec06306ad775929337d21..743af5f87217e098e287a2b29c56b5b704dcaf08 100644 --- a/upstream-info/desktop-file-utils.yaml +++ b/upstream-info/desktop-file-utils.yaml @@ -1,6 +1,6 @@ --- version_control: git -src_repo: https://anongit.freedesktop.org/git/xdg/desktop-file-utils +src_repo: https://anongit.freedesktop.org/git/xdg/desktop-file-utils.git tag_prefix: "^" separator: "." -git_url: https://anongit.freedesktop.org/git/xdg/desktop-file-utils +git_url: https://anongit.freedesktop.org/git/xdg/desktop-file-utils.git diff --git a/upstream-info/hunspell-lt.yaml b/upstream-info/hunspell-lt.yaml index 302a16e6a052172dedf86ff1b4dba0b5be14f2da..0a6a8c8b80e7ca0970cadc04e75c45e5ea9114cb 100644 --- a/upstream-info/hunspell-lt.yaml +++ b/upstream-info/hunspell-lt.yaml @@ -1,5 +1,5 @@ --- -git_url: https://github.com/ispell-lt/ispell-lt +git_url: https://github.com/ispell-lt/ispell-lt.git version_control: github src_repo: ispell-lt/ispell-lt tag_prefix: "^rel-" diff --git a/upstream-info/libksba.yaml b/upstream-info/libksba.yaml index 0b8de66b898d32d3860fbec365a787d6ba157433..098a049d9fd4a046d8eec45a0583143ef71e6780 100644 --- a/upstream-info/libksba.yaml +++ b/upstream-info/libksba.yaml @@ -3,4 +3,4 @@ version_control: git src_repo: https://dev.gnupg.org/source/libksba.git tag_prefix: "^libksba-" separator: "." -git_url: https://git.gnupg.org/cgi-bin/gitweb.cgi?p=libksba.git;a=summary +git_url: https://dev.gnupg.org/source/libksba.git diff --git a/upstream-info/libxklavier.yaml b/upstream-info/libxklavier.yaml index eed589774b312cd36eca955538fac3a47555b10b..dbd2f1db2d7102674287b567d12a05f0487795a6 100644 --- a/upstream-info/libxklavier.yaml +++ b/upstream-info/libxklavier.yaml @@ -1,6 +1,6 @@ --- version_control: git -src_repo: https://anongit.freedesktop.org/git/libxklavier +src_repo: https://anongit.freedesktop.org/git/libxklavier.git tag_prefix: "^libxklavier-" separator: "." -git_url: https://anongit.freedesktop.org/git/libxklavier +git_url: https://anongit.freedesktop.org/git/libxklavier.git diff --git a/upstream-info/motif.yaml b/upstream-info/motif.yaml index 25a2fa767d4fa2bb13cc64bfff2345db1ab587a9..0875920b25a5c3f03c9afbbcac4f0e81854f0692 100644 --- a/upstream-info/motif.yaml +++ b/upstream-info/motif.yaml @@ -1,8 +1,8 @@ --- version_control: git -src_repo: https://git.code.sf.net/p/motif/code +src_repo: https://git.code.sf.net/p/motif/code.git tag_prefix: release_ separator: _ -git_url: https://git.code.sf.net/p/motif/code +git_url: https://git.code.sf.net/p/motif/code.git git_tag: - 2016-03-17 release_2_3_5 diff --git a/upstream-info/upower.yaml b/upstream-info/upower.yaml index 1caba9ff07509d28de7a46b587f462cb19c39d64..045f9123677ba341206d772cb12b7cd4d060322c 100644 --- a/upstream-info/upower.yaml +++ b/upstream-info/upower.yaml @@ -3,7 +3,7 @@ version_control: git src_repo: https://gitlab.freedesktop.org/upower/upower.git tag_prefix: "^UPOWER_" separator: _ -git_url: git://anongit.freedesktop.org/upower +git_url: https://gitlab.freedesktop.org/upower/upower.git git_tag: - 2019-09-03 UPOWER_0_99_11 - 2019-02-20 UPOWER_0_99_10 diff --git a/upstream-info/wayland-protocols.yaml b/upstream-info/wayland-protocols.yaml index 9af8ce60a6e17083a26fdb6611a6d9b24593f93d..9c3a40b7d7e037533ec6843808aaed3fbbfd46e7 100644 --- a/upstream-info/wayland-protocols.yaml +++ b/upstream-info/wayland-protocols.yaml @@ -3,4 +3,4 @@ version_control: git src_repo: https://gitlab.freedesktop.org/wayland/wayland-protocols.git tag_prefix: separator: "." -git_url: https://cgit.freedesktop.org/wayland/wayland-protocols/ +git_url: https://gitlab.freedesktop.org/wayland/wayland-protocols.git diff --git a/upstream-info/webrtc-audio-processing.yaml b/upstream-info/webrtc-audio-processing.yaml index ff796ecb41ca8a5e6d8639da2dba54a962bd5845..e6a3129e1b4ce21263eba9ac9781b6e8fb6f42f8 100644 --- a/upstream-info/webrtc-audio-processing.yaml +++ b/upstream-info/webrtc-audio-processing.yaml @@ -1,6 +1,6 @@ --- version_control: git -src_repo: https://anongit.freedesktop.org/git/pulseaudio/webrtc-audio-processing +src_repo: https://anongit.freedesktop.org/git/pulseaudio/webrtc-audio-processing.git tag_prefix: "^v" separator: "." -git_url: https://anongit.freedesktop.org/git/pulseaudio/webrtc-audio-processing +git_url: https://anongit.freedesktop.org/git/pulseaudio/webrtc-audio-processing.git diff --git a/upstream-info/zsh.yaml b/upstream-info/zsh.yaml index aee43726d0771fbd2ec3e934de6188189ceb4ea4..ba60e32bf8b16e9b6750c7750f8c91e79fa87a6e 100644 --- a/upstream-info/zsh.yaml +++ b/upstream-info/zsh.yaml @@ -1,8 +1,8 @@ --- version_control: git -src_repo: https://git.code.sf.net/p/zsh/code +src_repo: https://git.code.sf.net/p/zsh/code.git tag_prefix: "^zsh-" separator: -git_url: https://git.code.sf.net/p/zsh/code +git_url: https://git.code.sf.net/p/zsh/code.git git_tag: - 2020-07-05 show