mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-15 18:11:48 +04:00
fix get_root() for the case of called from the git dir
This commit is contained in:
parent
cc9f8f66c8
commit
c43698e942
1 changed files with 4 additions and 2 deletions
|
|
@ -55,13 +55,15 @@ def get_root() -> str:
|
||||||
root = os.path.abspath(
|
root = os.path.abspath(
|
||||||
cmd_output('git', 'rev-parse', '--show-cdup')[1].strip(),
|
cmd_output('git', 'rev-parse', '--show-cdup')[1].strip(),
|
||||||
)
|
)
|
||||||
git_dir = os.path.abspath(get_git_common_dir())
|
inside_git_dir = cmd_output(
|
||||||
|
'git', 'rev-parse', '--is-inside-git-dir',
|
||||||
|
)[1].strip()
|
||||||
except CalledProcessError:
|
except CalledProcessError:
|
||||||
raise FatalError(
|
raise FatalError(
|
||||||
'git failed. Is it installed, and are you in a Git repository '
|
'git failed. Is it installed, and are you in a Git repository '
|
||||||
'directory?',
|
'directory?',
|
||||||
)
|
)
|
||||||
if os.path.samefile(root, git_dir):
|
if inside_git_dir != 'false':
|
||||||
raise FatalError(
|
raise FatalError(
|
||||||
'git toplevel unexpectedly empty! make sure you are not '
|
'git toplevel unexpectedly empty! make sure you are not '
|
||||||
'inside the `.git` directory of your repository.',
|
'inside the `.git` directory of your repository.',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue