mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-13 04:20:28 -06:00
Use hash of repository name to allow tags.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import hashlib
|
||||
import io
|
||||
import logging
|
||||
import os
|
||||
@@ -74,7 +75,9 @@ class Store(object):
|
||||
self.require_created()
|
||||
|
||||
# Check if we already exist
|
||||
sha_path = os.path.join(self.directory, sha)
|
||||
sha_path = os.path.join(
|
||||
self.directory, sha + '_' + hashlib.md5(url).hexdigest()
|
||||
)
|
||||
if os.path.exists(sha_path):
|
||||
return os.readlink(sha_path)
|
||||
|
||||
|
||||
@@ -17,15 +17,6 @@ from testing.fixtures import make_repo
|
||||
from testing.util import skipif_slowtests_false
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_install_python_repo_in_env(tmpdir_factory, store):
|
||||
path = make_repo(tmpdir_factory, 'python_hooks_repo')
|
||||
config = make_config_from_repo(path)
|
||||
repo = Repository.create(config, store)
|
||||
repo.install()
|
||||
assert os.path.exists(os.path.join(store.directory, repo.sha, 'py_env'))
|
||||
|
||||
|
||||
def _test_hook_repo(
|
||||
tmpdir_factory,
|
||||
store,
|
||||
@@ -274,7 +265,6 @@ def _create_repo_with_tags(tmpdir_factory, src, tag):
|
||||
return path
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
@pytest.mark.integration
|
||||
def test_tags_on_repositories(in_tmpdir, tmpdir_factory, store):
|
||||
tag = 'v1.1'
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import hashlib
|
||||
import io
|
||||
import mock
|
||||
import os
|
||||
@@ -104,7 +105,9 @@ def test_clone(store, tmpdir_factory, log_info_mock):
|
||||
assert get_head_sha(ret) == sha
|
||||
|
||||
# Assert that we made a symlink from the sha to the repo
|
||||
sha_path = os.path.join(store.directory, sha)
|
||||
sha_path = os.path.join(
|
||||
store.directory, sha + '_' + hashlib.md5(path).hexdigest(),
|
||||
)
|
||||
assert os.path.exists(sha_path)
|
||||
assert os.path.islink(sha_path)
|
||||
assert os.readlink(sha_path) == ret
|
||||
@@ -136,7 +139,12 @@ def test_clone_when_repo_already_exists(store):
|
||||
store.require_created()
|
||||
repo_dir_path = os.path.join(store.directory, 'repo_dir')
|
||||
os.mkdir(repo_dir_path)
|
||||
os.symlink(repo_dir_path, os.path.join(store.directory, 'fake_sha'))
|
||||
os.symlink(
|
||||
repo_dir_path,
|
||||
os.path.join(
|
||||
store.directory, 'fake_sha' + '_' + hashlib.md5('url').hexdigest(),
|
||||
),
|
||||
)
|
||||
|
||||
ret = store.clone('url', 'fake_sha')
|
||||
assert ret == repo_dir_path
|
||||
|
||||
Reference in New Issue
Block a user