mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 09:04:41 +04:00
Use hash of repository name to allow tags.
This commit is contained in:
parent
d2a349a0d8
commit
4ec877628d
3 changed files with 14 additions and 13 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import hashlib
|
||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
@ -74,7 +75,9 @@ class Store(object):
|
||||||
self.require_created()
|
self.require_created()
|
||||||
|
|
||||||
# Check if we already exist
|
# 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):
|
if os.path.exists(sha_path):
|
||||||
return os.readlink(sha_path)
|
return os.readlink(sha_path)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,15 +17,6 @@ from testing.fixtures import make_repo
|
||||||
from testing.util import skipif_slowtests_false
|
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(
|
def _test_hook_repo(
|
||||||
tmpdir_factory,
|
tmpdir_factory,
|
||||||
store,
|
store,
|
||||||
|
|
@ -274,7 +265,6 @@ def _create_repo_with_tags(tmpdir_factory, src, tag):
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail
|
|
||||||
@pytest.mark.integration
|
@pytest.mark.integration
|
||||||
def test_tags_on_repositories(in_tmpdir, tmpdir_factory, store):
|
def test_tags_on_repositories(in_tmpdir, tmpdir_factory, store):
|
||||||
tag = 'v1.1'
|
tag = 'v1.1'
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import hashlib
|
||||||
import io
|
import io
|
||||||
import mock
|
import mock
|
||||||
import os
|
import os
|
||||||
|
|
@ -104,7 +105,9 @@ def test_clone(store, tmpdir_factory, log_info_mock):
|
||||||
assert get_head_sha(ret) == sha
|
assert get_head_sha(ret) == sha
|
||||||
|
|
||||||
# Assert that we made a symlink from the sha to the repo
|
# 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.exists(sha_path)
|
||||||
assert os.path.islink(sha_path)
|
assert os.path.islink(sha_path)
|
||||||
assert os.readlink(sha_path) == ret
|
assert os.readlink(sha_path) == ret
|
||||||
|
|
@ -136,7 +139,12 @@ def test_clone_when_repo_already_exists(store):
|
||||||
store.require_created()
|
store.require_created()
|
||||||
repo_dir_path = os.path.join(store.directory, 'repo_dir')
|
repo_dir_path = os.path.join(store.directory, 'repo_dir')
|
||||||
os.mkdir(repo_dir_path)
|
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')
|
ret = store.clone('url', 'fake_sha')
|
||||||
assert ret == repo_dir_path
|
assert ret == repo_dir_path
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue