Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rev master not found #7

Open
nhendy opened this issue Jan 30, 2020 · 1 comment
Open

Rev master not found #7

nhendy opened this issue Jan 30, 2020 · 1 comment

Comments

@nhendy
Copy link

nhendy commented Jan 30, 2020

Hi I'm having trouble running this hook, the following is the error log.

[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /home/shay/a/nhendy/.cache/pre-commit/patch1580363237.
[INFO] Initializing environment for git://github.com/doublify/pre-commit-clang-format.
[INFO] Restored changes from /home/shay/a/nhendy/.cache/pre-commit/patch1580363237.
An unexpected error has occurred: CalledProcessError: command: ('/usr/libexec/git-core/git', 'checkout', 'master')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    error: pathspec 'master' did not match any file(s) known to git.

Check the log at /home/shay/a/nhendy/.cache/pre-commit/pre-commit.log

Log file:

### version information

pre-commit version: 2.0.0
sys.version:
    3.6.8 (default, Aug  7 2019, 17:28:10)
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
sys.executable: /usr/bin/python3
os.name: posix
sys.platform: linux

### error information

An unexpected error has occurred: CalledProcessError: command: ('/usr/libexec/git-core/git', 'checkout', 'master')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    error: pathspec 'master' did not match any file(s) known to git.

Traceback (most recent call last):
  File "/home/shay/a/nhendy/.local/lib/python3.6/site-packages/pre_commit/store.py", line 178, in clone_strategy
    self._shallow_clone(ref, _git_cmd)
  File "/home/shay/a/nhendy/.local/lib/python3.6/site-packages/pre_commit/store.py", line 164, in _shallow_clone
    '--depth=1',
  File "/home/shay/a/nhendy/.local/lib/python3.6/site-packages/pre_commit/store.py", line 175, in _git_cmd
    cmd_output_b('git', *args, cwd=directory, env=env)
  File "/home/shay/a/nhendy/.local/lib/python3.6/site-packages/pre_commit/util.py", line 126, in cmd_output_b
    raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/usr/libexec/git-core/git', '-c', 'protocol.version=2', 'submodule', 'update', '--init', '--recursive', '--depth=1')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    usage: git submodule [--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
       or: git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...]
       or: git submodule [--quiet] init [--] [<path>...]
       or: git submodule [--quiet] deinit [-f|--force] [--] <path>...
       or: git submodule [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
       or: git submodule [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
       or: git submodule [--quiet] foreach [--recursive] <command>
       or: git submodule [--quiet] sync [--recursive] [--] [<path>...]


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/shay/a/nhendy/.local/lib/python3.6/site-packages/pre_commit/error_handler.py", line 54, in error_handler
    yield
  File "/home/shay/a/nhendy/.local/lib/python3.6/site-packages/pre_commit/main.py", line 351, in main
    args=args.rest[1:],
  File "/home/shay/a/nhendy/.local/lib/python3.6/site-packages/pre_commit/commands/hook_impl.py", line 180, in hook_impl
    return retv | run(config, store, ns)
  File "/home/shay/a/nhendy/.local/lib/python3.6/site-packages/pre_commit/commands/run.py", line 326, in run
    for hook in all_hooks(config, store)
  File "/home/shay/a/nhendy/.local/lib/python3.6/site-packages/pre_commit/repository.py", line 206, in all_hooks
    for repo in root_config['repos']
  File "/home/shay/a/nhendy/.local/lib/python3.6/site-packages/pre_commit/repository.py", line 207, in <genexpr>
    for hook in _repository_hooks(repo, store, root_config)
  File "/home/shay/a/nhendy/.local/lib/python3.6/site-packages/pre_commit/repository.py", line 182, in _repository_hooks
    return _cloned_repository_hooks(repo_config, store, root_config)
  File "/home/shay/a/nhendy/.local/lib/python3.6/site-packages/pre_commit/repository.py", line 148, in _cloned_repository_hooks
    manifest_path = os.path.join(store.clone(repo, rev), C.MANIFEST_FILE)
  File "/home/shay/a/nhendy/.local/lib/python3.6/site-packages/pre_commit/store.py", line 182, in clone
    return self._new_repo(repo, ref, deps, clone_strategy)
  File "/home/shay/a/nhendy/.local/lib/python3.6/site-packages/pre_commit/store.py", line 139, in _new_repo
    make_strategy(directory)
  File "/home/shay/a/nhendy/.local/lib/python3.6/site-packages/pre_commit/store.py", line 180, in clone_strategy
    self._complete_clone(ref, _git_cmd)
  File "/home/shay/a/nhendy/.local/lib/python3.6/site-packages/pre_commit/store.py", line 153, in _complete_clone
    git_cmd('checkout', ref)
  File "/home/shay/a/nhendy/.local/lib/python3.6/site-packages/pre_commit/store.py", line 175, in _git_cmd
    cmd_output_b('git', *args, cwd=directory, env=env)
  File "/home/shay/a/nhendy/.local/lib/python3.6/site-packages/pre_commit/util.py", line 126, in cmd_output_b
    raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/usr/libexec/git-core/git', 'checkout', 'master')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    error: pathspec 'master' did not match any file(s) known to git.

@nhendy nhendy closed this as completed Jan 30, 2020
@nhendy nhendy reopened this Jan 30, 2020
@nhendy
Copy link
Author

nhendy commented Jan 30, 2020

I believe it's because of my git version git version 1.8.3.1. I fixed it by patching pre-commit:

--- a/pre_commit/store.py	2020-01-30 00:58:13.986034490 -0500
+++ b/pre_commit/store_patched.py	2020-01-30 00:59:21.648956059 -0500
@@ -161,7 +161,7 @@
         git_cmd('checkout', 'FETCH_HEAD')
         git_cmd(
             '-c', git_config, 'submodule', 'update', '--init', '--recursive',
-            'depth=1',
+            '',
         )

     def clone(self, repo: str, ref: str, deps: Sequence[str] = ()) -> str:

Wondering if there's a fix on this repo's side since I didn't run into this issue with
https://github.com/pre-commit/pre-commit-hooks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant