Skip to content

Commit eab24f3

Browse files
committed
Fix full clone + non-mainline tag
1 parent b33f2c4 commit eab24f3

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

pre_commit/store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def _get_result():
138138
def _complete_clone(self, ref, git_cmd):
139139
"""Perform a complete clone of a repository and its submodules """
140140

141-
git_cmd('fetch', 'origin')
141+
git_cmd('fetch', 'origin', '--tags')
142142
git_cmd('checkout', ref)
143143
git_cmd('submodule', 'update', '--init', '--recursive')
144144

tests/store_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from pre_commit.store import _get_default_directory
1414
from pre_commit.store import Store
1515
from pre_commit.util import CalledProcessError
16+
from pre_commit.util import cmd_output
1617
from testing.fixtures import git_dir
1718
from testing.util import cwd
1819
from testing.util import git_commit
@@ -147,6 +148,20 @@ def fake_shallow_clone(self, *args, **kwargs):
147148
assert store.select_all_repos() == [(path, rev, ret)]
148149

149150

151+
def test_clone_tag_not_on_mainline(store, tempdir_factory):
152+
path = git_dir(tempdir_factory)
153+
with cwd(path):
154+
git_commit()
155+
cmd_output('git', 'checkout', 'master', '-b', 'branch')
156+
git_commit()
157+
cmd_output('git', 'tag', 'v1')
158+
cmd_output('git', 'checkout', 'master')
159+
cmd_output('git', 'branch', '-D', 'branch')
160+
161+
# previously crashed on unreachable refs
162+
store.clone(path, 'v1')
163+
164+
150165
def test_create_when_directory_exists_but_not_db(store):
151166
# In versions <= 0.3.5, there was no sqlite db causing a need for
152167
# backward compatibility

0 commit comments

Comments
 (0)