mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Merge pull request #998 from pre-commit/full_clone_non_mainline_tag
Fix full clone + non-mainline tag
This commit is contained in:
commit
2d4ea61c93
2 changed files with 16 additions and 1 deletions
|
|
@ -138,7 +138,7 @@ class Store(object):
|
||||||
def _complete_clone(self, ref, git_cmd):
|
def _complete_clone(self, ref, git_cmd):
|
||||||
"""Perform a complete clone of a repository and its submodules """
|
"""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('checkout', ref)
|
||||||
git_cmd('submodule', 'update', '--init', '--recursive')
|
git_cmd('submodule', 'update', '--init', '--recursive')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ from pre_commit import git
|
||||||
from pre_commit.store import _get_default_directory
|
from pre_commit.store import _get_default_directory
|
||||||
from pre_commit.store import Store
|
from pre_commit.store import Store
|
||||||
from pre_commit.util import CalledProcessError
|
from pre_commit.util import CalledProcessError
|
||||||
|
from pre_commit.util import cmd_output
|
||||||
from testing.fixtures import git_dir
|
from testing.fixtures import git_dir
|
||||||
from testing.util import cwd
|
from testing.util import cwd
|
||||||
from testing.util import git_commit
|
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)]
|
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):
|
def test_create_when_directory_exists_but_not_db(store):
|
||||||
# In versions <= 0.3.5, there was no sqlite db causing a need for
|
# In versions <= 0.3.5, there was no sqlite db causing a need for
|
||||||
# backward compatibility
|
# backward compatibility
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue