コード例 #1
0
ファイル: npm.py プロジェクト: vsurge/barista
def vcs_repository_mapper(repo, package, vcs_revision=None):
    """
    https://docs.npmjs.com/files/package.json#repository
    "repository" :
      { "type" : "git"
      , "url" : "https://github.com/npm/npm.git"
      }
    "repository" :
      { "type" : "svn"
      , "url" : "https://v8.googlecode.com/svn/trunk/"
      }
    """
    if not repo:
        return package

    if isinstance(repo, list):
        # There is a case where we can have a list with a single element
        repo = repo[0]

    vcs_tool = ''
    vcs_repository = ''

    if isinstance(repo, string_types):
        vcs_repository = parse_repo_url(repo)

    elif isinstance(repo, dict):
        repo_url = parse_repo_url(repo.get('url'))
        if repo_url:
            vcs_tool = repo.get('type') or 'git'
            # remove vcs_tool string if repo_url already contains it
            if repo_url.startswith(vcs_tool):
                vcs_tool = ''
            vcs_repository = repo_url

    if vcs_repository:
        if vcs_tool:
            vcs_url = '{}+{}'.format(vcs_tool, vcs_repository)
        else:
            vcs_url = vcs_repository

        if vcs_revision:
            vcs_url += '@' + vcs_revision
        package.vcs_url = vcs_url
    return package
コード例 #2
0
def repository_mapper(repo, package):
    """
    https://docs.npmjs.com/files/package.json#repository
    "repository" :
      { "type" : "git"
      , "url" : "https://github.com/npm/npm.git"
      }
    "repository" :
      { "type" : "svn"
      , "url" : "https://v8.googlecode.com/svn/trunk/"
      }
    """
    if not repo:
        return package
    if isinstance(repo, basestring):
        package.vcs_repository = parse_repo_url(repo)
    elif isinstance(repo, dict):
        package.vcs_tool = repo.get('type') or 'git'
        package.vcs_repository = parse_repo_url(repo.get('url'))
    return package
コード例 #3
0
ファイル: npm.py プロジェクト: ocabrisses/scancode-toolkit
def repository_mapper(repo, package):
    """
    https://docs.npmjs.com/files/package.json#repository
    "repository" :
      { "type" : "git"
      , "url" : "https://github.com/npm/npm.git"
      }
    "repository" :
      { "type" : "svn"
      , "url" : "https://v8.googlecode.com/svn/trunk/"
      }
    """
    if not repo:
        return package
    if isinstance(repo, basestring):
        package.vcs_repository = parse_repo_url(repo)
    elif isinstance(repo, dict):
        repurl = parse_repo_url(repo.get('url'))
        if repurl:
            package.vcs_tool = repo.get('type') or 'git'
            package.vcs_repository = repurl
    return package
コード例 #4
0
 def test_parse_repo_url_10(self):
     test = 'https://github.com/chaijs/chai'
     expected = 'https://github.com/chaijs/chai'
     assert expected == parse_repo_url(test)
コード例 #5
0
 def test_parse_repo_url_6(self):
     test = 'git://github.com/hapijs/boom'
     expected = 'git://github.com/hapijs/boom'
     assert expected == parse_repo_url(test)
コード例 #6
0
 def test_parse_repo_url_8(self):
     test = 'http://github.com/ariya/esprima.git'
     expected = 'http://github.com/ariya/esprima.git'
     assert expected == parse_repo_url(test)
コード例 #7
0
 def test_parse_repo_url_2(self):
     test = 'bitbucket:example/repo'
     expected = 'https://bitbucket.org/example/repo'
     assert expected == parse_repo_url(test)
コード例 #8
0
 def test_parse_repo_url_4(self):
     test = 'expressjs/serve-static'
     expected = 'https://github.com/expressjs/serve-static'
     assert expected == parse_repo_url(test)
コード例 #9
0
 def test_parse_git_repo_url_without_slash_slash(self):
     test = '[email protected]/Filirom1/npm2aur.git'
     expected = 'https://github.com/Filirom1/npm2aur.git'
     assert expected == parse_repo_url(test)
コード例 #10
0
 def test_parse_repo_url_0(self):
     test = 'npm/npm'
     expected = 'https://github.com/npm/npm'
     assert expected == parse_repo_url(test)
コード例 #11
0
 def test_parse_repo_url_0(self):
     test = 'npm/npm'
     expected = 'https://github.com/npm/npm'
     assert expected == parse_repo_url(test)
コード例 #12
0
 def test_parse_repo_url_1(self):
     test = 'gist:11081aaa281'
     expected = 'https://gist.github.com/11081aaa281'
     assert expected == parse_repo_url(test)
コード例 #13
0
 def test_parse_git_repo_url_without_slash_slash(self):
     test = '[email protected]/Filirom1/npm2aur.git'
     expected = 'https://github.com/Filirom1/npm2aur.git'
     assert expected == parse_repo_url(test)
コード例 #14
0
 def test_parse_repo_url_does_not_fail_on_empty(self):
     assert None == parse_repo_url(None)
     assert None == parse_repo_url('')
     assert None == parse_repo_url(' ')
コード例 #15
0
 def test_parse_repo_url_does_not_fail_on_empty(self):
     assert None == parse_repo_url(None)
     assert None == parse_repo_url('')
     assert None == parse_repo_url(' ')
コード例 #16
0
 def test_parse_repo_url_bitbucket(self):
     url = '[email protected]:vendor/my-private-repo.git'
     result = parse_repo_url(url)
     expected = 'https://bitbucket.org/vendor/my-private-repo.git'
     assert expected == result
コード例 #17
0
 def test_parse_repo_url_github(self):
     url = 'https://github.com/igorw/monolog'
     result = parse_repo_url(url)
     expected = 'https://github.com/igorw/monolog'
     assert expected == result
コード例 #18
0
 def test_parse_repo_url_13(self):
     test = '[email protected]:foo/private.git'
     expected = 'https://gitlab.com/foo/private.git'
     assert expected == parse_repo_url(test)
コード例 #19
0
 def test_parse_repo_url_2(self):
     test = 'bitbucket:example/repo'
     expected = 'https://bitbucket.org/example/repo'
     assert expected == parse_repo_url(test)
コード例 #20
0
 def test_parse_repo_url_svn(self):
     url = 'http://svn.example.org/projectA/'
     result = parse_repo_url(url)
     expected = 'http://svn.example.org/projectA/'
     assert expected == result
コード例 #21
0
 def test_parse_repo_url_3(self):
     test = 'gitlab:another/repo'
     expected = 'https://gitlab.com/another/repo'
     assert expected == parse_repo_url(test)
コード例 #22
0
 def test_parse_repo_url_13(self):
     test = '[email protected]:foo/private.git'
     expected = 'https://gitlab.com/foo/private.git'
     assert expected == parse_repo_url(test)
コード例 #23
0
 def test_parse_repo_url_4(self):
     test = 'expressjs/serve-static'
     expected = 'https://github.com/expressjs/serve-static'
     assert expected == parse_repo_url(test)
コード例 #24
0
 def test_parse_repo_url_1(self):
     test = 'gist:11081aaa281'
     expected = 'https://gist.github.com/11081aaa281'
     assert expected == parse_repo_url(test)
コード例 #25
0
 def test_parse_repo_url_5(self):
     test = 'git://github.com/angular/di.js.git'
     expected = 'git://github.com/angular/di.js.git'
     assert expected == parse_repo_url(test)
コード例 #26
0
 def test_parse_repo_url_3(self):
     test = 'gitlab:another/repo'
     expected = 'https://gitlab.com/another/repo'
     assert expected == parse_repo_url(test)
コード例 #27
0
 def test_parse_repo_url_6(self):
     test = 'git://github.com/hapijs/boom'
     expected = 'git://github.com/hapijs/boom'
     assert expected == parse_repo_url(test)
コード例 #28
0
 def test_parse_repo_url_5(self):
     test = 'git://github.com/angular/di.js.git'
     expected = 'git://github.com/angular/di.js.git'
     assert expected == parse_repo_url(test)
コード例 #29
0
 def test_parse_repo_url_7(self):
     test = '[email protected]:balderdashy/waterline-criteria.git'
     expected = 'https://github.com/balderdashy/waterline-criteria.git'
     assert expected == parse_repo_url(test)
コード例 #30
0
 def test_parse_repo_url_7(self):
     test = '[email protected]:balderdashy/waterline-criteria.git'
     expected = 'https://github.com/balderdashy/waterline-criteria.git'
     assert expected == parse_repo_url(test)
コード例 #31
0
def repository_mapper(repos, package):
    """
    https://getcomposer.org/doc/04-schema.md#repositories
    "repositories": [
        {
            "type": "composer",
            "url": "http://packages.example.com"
        },
        {
            "type": "composer",
            "url": "https://packages.example.com",
            "options": {
                "ssl": {
                    "verify_peer": "true"
                }
            }
        },
        {
            "type": "vcs",
            "url": "https://github.com/Seldaek/monolog"
        },
        {
            "type": "pear",
            "url": "https://pear2.php.net"
        },
        {
            "type": "package",
            "package": {
                "name": "smarty/smarty",
                "version": "3.1.7",
                "dist": {
                    "url": "http://www.smarty.net/files/Smarty-3.1.7.zip",
                    "type": "zip"
                },
                "source": {
                    "url": "https://smarty-php.googlecode.com/svn/",
                    "type": "svn",
                    "reference": "tags/Smarty_3_1_7/distribution/"
                }
            }
        }
    ]
    """
    if not repos:
        return package
    if isinstance(repos, basestring):
        package.vcs_repository = parse_repo_url(repos)
    elif isinstance(repos, list):
        for repo in repos:
            if repo.get('type') == 'vcs':
                # vcs type includes git, svn, fossil or hg.
                # refer to https://getcomposer.org/doc/05-repositories.md#vcs
                repo_url = repo.get('url')
                if repo_url.startswith(
                        'svn') or 'subversion.apache.org' in repo_url:
                    package.vcs_tool = 'svn'
                elif repo_url.startswith(
                        'hg') or 'mercurial.selenic.com' in repo_url:
                    package.vcs_tool = 'hg'
                elif repo_url.startswith(
                        'fossil') or 'fossil-scm.org' in repo_url:
                    package.vcs_tool = 'fossil'
                else:
                    package.vcs_tool = 'git'
                package.vcs_repository = parse_repo_url(repo.get('url'))
    return package
コード例 #32
0
 def test_parse_repo_url_9(self):
     test = 'http://github.com/isaacs/nopt'
     expected = 'http://github.com/isaacs/nopt'
     assert expected == parse_repo_url(test)
コード例 #33
0
 def test_parse_repo_url_basic(self):
     url = 'https://pear2.php.net'
     result = parse_repo_url(url)
     expected = 'https://pear2.php.net'
     assert expected == result
コード例 #34
0
 def test_parse_repo_url_11(self):
     test = 'https://github.com/christkv/kerberos.git'
     expected = 'https://github.com/christkv/kerberos.git'
     assert expected == parse_repo_url(test)
コード例 #35
0
 def test_parse_repo_url_github(self):
     url = 'https://github.com/igorw/monolog'
     result = parse_repo_url(url)
     expected = 'https://github.com/igorw/monolog'
     assert expected == result
コード例 #36
0
 def test_parse_repo_url_8(self):
     test = 'http://github.com/ariya/esprima.git'
     expected = 'http://github.com/ariya/esprima.git'
     assert expected == parse_repo_url(test)
コード例 #37
0
 def test_parse_repo_url_basic(self):
     url = 'https://pear2.php.net'
     result = parse_repo_url(url)
     expected = 'https://pear2.php.net'
     assert expected == result
コード例 #38
0
def repository_mapper(repos, package):
    """
    https://getcomposer.org/doc/04-schema.md#repositories
    "repositories": [
        {
            "type": "composer",
            "url": "http://packages.example.com"
        },
        {
            "type": "composer",
            "url": "https://packages.example.com",
            "options": {
                "ssl": {
                    "verify_peer": "true"
                }
            }
        },
        {
            "type": "vcs",
            "url": "https://github.com/Seldaek/monolog"
        },
        {
            "type": "pear",
            "url": "https://pear2.php.net"
        },
        {
            "type": "package",
            "package": {
                "name": "smarty/smarty",
                "version": "3.1.7",
                "dist": {
                    "url": "http://www.smarty.net/files/Smarty-3.1.7.zip",
                    "type": "zip"
                },
                "source": {
                    "url": "https://smarty-php.googlecode.com/svn/",
                    "type": "svn",
                    "reference": "tags/Smarty_3_1_7/distribution/"
                }
            }
        }
    ]
    """
    if not repos:
        return package
    if isinstance(repos, basestring):
        package.vcs_repository = parse_repo_url(repos)
    elif isinstance(repos, list):
        for repo in repos:
            if repo.get('type') == 'vcs':
                # vcs type includes git, svn, fossil or hg.
                # refer to https://getcomposer.org/doc/05-repositories.md#vcs
                repo_url = repo.get('url')
                if repo_url.startswith('svn') or 'subversion.apache.org' in repo_url:
                    package.vcs_tool = 'svn'
                elif repo_url.startswith('hg') or 'mercurial.selenic.com' in repo_url:
                    package.vcs_tool = 'hg'
                elif repo_url.startswith('fossil') or 'fossil-scm.org' in repo_url:
                    package.vcs_tool = 'fossil'
                else:
                    package.vcs_tool = 'git'
                package.vcs_repository = parse_repo_url(repo.get('url'))
    return package
コード例 #39
0
 def test_parse_repo_url_9(self):
     test = 'http://github.com/isaacs/nopt'
     expected = 'http://github.com/isaacs/nopt'
     assert expected == parse_repo_url(test)
コード例 #40
0
 def test_parse_repo_url_svn(self):
     url = 'http://svn.example.org/projectA/'
     result = parse_repo_url(url)
     expected = 'http://svn.example.org/projectA/'
     assert expected == result
コード例 #41
0
 def test_parse_repo_url_10(self):
     test = 'https://github.com/chaijs/chai'
     expected = 'https://github.com/chaijs/chai'
     assert expected == parse_repo_url(test)
コード例 #42
0
 def test_parse_repo_url_bitbucket(self):
     url = '[email protected]:vendor/my-private-repo.git'
     result = parse_repo_url(url)
     expected = 'https://bitbucket.org/vendor/my-private-repo.git'
     assert expected == result
コード例 #43
0
 def test_parse_repo_url_11(self):
     test = 'https://github.com/christkv/kerberos.git'
     expected = 'https://github.com/christkv/kerberos.git'
     assert expected == parse_repo_url(test)