예제 #1
0
def resolve_repo_dir(template):
    """
    Determine path to local repository based on template name.
    This can be either a local path, a remote URL or a remote alias
    such as for Github.

    Sundry bits from Cookiecutter do the heavy lifting here.

    Arguments

      template [path|url|alias]

    """
    cc_home = DEFAULT_CONFIG['cookiecutters_dir']
    if template_type(template) in ['remote alias', 'url']:
        raw_url = expand_abbreviations(template, BUILTIN_ABBREVIATIONS)
        repo_type, repo_url = identify_repo(raw_url)
        repo_url = repo_url.rstrip('/')
        tail = os.path.split(repo_url)[1]
        if repo_type == 'git':
            repo_dir = os.path.normpath(
                os.path.join(cc_home,
                             tail.rsplit('.git')[0]))
        elif repo_type == 'hg':
            repo_dir = os.path.normpath(os.path.join(cc_home, tail))
            repo_dir = template
    else:
        repo_dir = os.path.abspath(template)
    return repo_dir
예제 #2
0
def test_identify_known_repo(repo_url, exp_repo_type, exp_repo_url):
    """Verify different correct repositories url syntax is correctly transformed."""
    assert vcs.identify_repo(repo_url) == (exp_repo_type, exp_repo_url)
예제 #3
0
 def test_identify_hg_mercurial(self):
     repo_url = "https://[email protected]/audreyr/cookiecutter-bitbucket"
     self.assertEqual(vcs.identify_repo(repo_url), "hg")
예제 #4
0
 def test_identify_git_gitorious(self):
     repo_url = "[email protected]:cookiecutter-gitorious/cookiecutter-gitorious.git"
     self.assertEqual(vcs.identify_repo(repo_url), "git")
예제 #5
0
 def test_identify_git_github_no_extension(self):
     repo_url = "https://github.com/audreyr/cookiecutter-pypackage"
     self.assertEqual(vcs.identify_repo(repo_url), "git")
예제 #6
0
def test_identify_git_github_no_extension():
    repo_url = 'https://github.com/audreyr/cookiecutter-pypackage'
    assert vcs.identify_repo(repo_url)[0] == 'git'
예제 #7
0
def test_identify_known_repo(repo_url, exp_repo_type, exp_repo_url):
    assert vcs.identify_repo(repo_url) == (exp_repo_type, exp_repo_url)
예제 #8
0
 def test_identify_git_gitorious(self):
     repo_url = "[email protected]:cookiecutter-gitorious/cookiecutter-gitorious.git"
     self.assertEqual(vcs.identify_repo(repo_url), "git")
예제 #9
0
def test_identify_git_gitorious():
    repo_url = (
        '[email protected]:cookiecutter-gitorious/cookiecutter-gitorious.git'
    )
    assert vcs.identify_repo(repo_url)[0] == 'git'
예제 #10
0
def test_identify_git_github_no_extension():
    repo_url = 'https://github.com/audreyr/cookiecutter-pypackage'
    assert vcs.identify_repo(repo_url)[0] == 'git'
def test_identify_git_github():
    repo_url = "https://github.com/audreyr/cookiecutter-pypackage.git"
    assert vcs.identify_repo(repo_url)[0] == "git"
예제 #12
0
def test_unknown_repo_type():
    repo_url = 'http://norepotypespecified.com'
    with pytest.raises(exceptions.UnknownRepoType):
        vcs.identify_repo(repo_url)[0]
예제 #13
0
def test_identify_hg_mercurial():
    repo_url = 'https://[email protected]/audreyr/cookiecutter-bitbucket'
    assert vcs.identify_repo(repo_url)[0] == 'hg'
예제 #14
0
def test_identify_git_gitorious():
    repo_url = (
        '[email protected]:cookiecutter-gitorious/cookiecutter-gitorious.git')
    assert vcs.identify_repo(repo_url)[0] == 'git'
예제 #15
0
def test_identify_raise_on_unknown_repo(unknown_repo_type_url):
    """Verify different incorrect repositories url syntax trigger error raising."""
    with pytest.raises(exceptions.UnknownRepoType):
        vcs.identify_repo(unknown_repo_type_url)
예제 #16
0
 def test_identify_git_github_no_extension(self):
     repo_url = "https://github.com/audreyr/cookiecutter-pypackage"
     self.assertEqual(vcs.identify_repo(repo_url), "git")
예제 #17
0
def test_identify_hg_mercurial():
    repo_url = 'https://[email protected]/audreyr/cookiecutter-bitbucket'
    assert vcs.identify_repo(repo_url)[0] == 'hg'
예제 #18
0
 def test_identify_hg_mercurial(self):
     repo_url = "https://[email protected]/audreyr/cookiecutter-bitbucket"
     self.assertEqual(vcs.identify_repo(repo_url), "hg")
예제 #19
0
def test_unknown_repo_type():
    repo_url = 'http://norepotypespecified.com'
    with pytest.raises(exceptions.UnknownRepoType):
        vcs.identify_repo(repo_url)[0]
예제 #20
0
def test_identify_raise_on_unknown_repo(unknown_repo_type_url):
    with pytest.raises(exceptions.UnknownRepoType):
        vcs.identify_repo(unknown_repo_type_url)
예제 #21
0
 def test_identify_git_github(self):
     repo_url = "git+https://github.com/audreyr/cookiecutter-pypackage.git"
     self.assertEqual(vcs.identify_repo(repo_url), "git")