Merge pull request #998 from pre-commit/full_clone_non_mainline_tag

Fix full clone + non-mainline tag
This commit is contained in:
Anthony Sottile
2019-04-16 11:30:57 -07:00
committed by GitHub
2 changed files with 16 additions and 1 deletions

View File

@@ -138,7 +138,7 @@ class Store(object):
def _complete_clone(self, ref, git_cmd):
"""Perform a complete clone of a repository and its submodules """
git_cmd('fetch', 'origin')
git_cmd('fetch', 'origin', '--tags')
git_cmd('checkout', ref)
git_cmd('submodule', 'update', '--init', '--recursive')

View File

@@ -13,6 +13,7 @@ from pre_commit import git
from pre_commit.store import _get_default_directory
from pre_commit.store import Store
from pre_commit.util import CalledProcessError
from pre_commit.util import cmd_output
from testing.fixtures import git_dir
from testing.util import cwd
from testing.util import git_commit
@@ -147,6 +148,20 @@ def test_clone_shallow_failure_fallback_to_complete(
assert store.select_all_repos() == [(path, rev, ret)]
def test_clone_tag_not_on_mainline(store, tempdir_factory):
path = git_dir(tempdir_factory)
with cwd(path):
git_commit()
cmd_output('git', 'checkout', 'master', '-b', 'branch')
git_commit()
cmd_output('git', 'tag', 'v1')
cmd_output('git', 'checkout', 'master')
cmd_output('git', 'branch', '-D', 'branch')
# previously crashed on unreachable refs
store.clone(path, 'v1')
def test_create_when_directory_exists_but_not_db(store):
# In versions <= 0.3.5, there was no sqlite db causing a need for
# backward compatibility