mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Merge pull request #680 from pre-commit/local_golang_repos
Fix broken local golang repos
This commit is contained in:
commit
4d6efe1943
2 changed files with 33 additions and 0 deletions
|
|
@ -156,6 +156,21 @@ class Store(object):
|
||||||
def make_local(self, deps):
|
def make_local(self, deps):
|
||||||
def make_local_strategy(directory):
|
def make_local_strategy(directory):
|
||||||
copy_tree_to_path(resource_filename('empty_template'), directory)
|
copy_tree_to_path(resource_filename('empty_template'), directory)
|
||||||
|
|
||||||
|
env = no_git_env()
|
||||||
|
name, email = 'pre-commit', 'asottile+pre-commit@umich.edu'
|
||||||
|
env['GIT_AUTHOR_NAME'] = env['GIT_COMMITTER_NAME'] = name
|
||||||
|
env['GIT_AUTHOR_EMAIL'] = env['GIT_COMMITTER_EMAIL'] = email
|
||||||
|
|
||||||
|
# initialize the git repository so it looks more like cloned repos
|
||||||
|
def _git_cmd(*args):
|
||||||
|
cmd_output('git', '-C', directory, *args, env=env)
|
||||||
|
|
||||||
|
_git_cmd('init', '.')
|
||||||
|
_git_cmd('config', 'remote.origin.url', '<<unknown>>')
|
||||||
|
_git_cmd('add', '.')
|
||||||
|
_git_cmd('commit', '--no-edit', '--no-gpg-sign', '-n', '-minit')
|
||||||
|
|
||||||
return self._new_repo(
|
return self._new_repo(
|
||||||
'local:{}'.format(','.join(sorted(deps))), C.LOCAL_REPO_VERSION,
|
'local:{}'.format(','.join(sorted(deps))), C.LOCAL_REPO_VERSION,
|
||||||
make_local_strategy,
|
make_local_strategy,
|
||||||
|
|
|
||||||
|
|
@ -541,6 +541,24 @@ def test_additional_golang_dependencies_installed(
|
||||||
assert 'hello' in binaries
|
assert 'hello' in binaries
|
||||||
|
|
||||||
|
|
||||||
|
def test_local_golang_additional_dependencies(store):
|
||||||
|
config = {
|
||||||
|
'repo': 'local',
|
||||||
|
'hooks': [{
|
||||||
|
'id': 'hello',
|
||||||
|
'name': 'hello',
|
||||||
|
'entry': 'hello',
|
||||||
|
'language': 'golang',
|
||||||
|
'additional_dependencies': ['github.com/golang/example/hello'],
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
repo = Repository.create(config, store)
|
||||||
|
(_, hook), = repo.hooks
|
||||||
|
ret = repo.run_hook(hook, ('filename',))
|
||||||
|
assert ret[0] == 0
|
||||||
|
assert _norm_out(ret[1]) == b"Hello, Go examples!\n"
|
||||||
|
|
||||||
|
|
||||||
def test_reinstall(tempdir_factory, store, log_info_mock):
|
def test_reinstall(tempdir_factory, store, log_info_mock):
|
||||||
path = make_repo(tempdir_factory, 'python_hooks_repo')
|
path = make_repo(tempdir_factory, 'python_hooks_repo')
|
||||||
config = make_config_from_repo(path)
|
config = make_config_from_repo(path)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue