Merge pull request #2047 from pre-commit/windows-as-usual · berquist/pre-commit@530dbe6 · GitHub
Skip to content

Commit 530dbe6

Browse files
authored
Merge pull request pre-commit#2047 from pre-commit/windows-as-usual
fix pre-commit autoupdate for core.useBuiltinFSMonitor=true on windows
2 parents 2ef29b7 + ab94dd6 commit 530dbe6

3 files changed

Lines changed: 32 additions & 8 deletions

File tree

pre_commit/commands/autoupdate.py

Lines changed: 17 additions & 5 deletions

pre_commit/git.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
from pre_commit.util import cmd_output
1313
from pre_commit.util import cmd_output_b
1414

15-
1615
logger = logging.getLogger(__name__)
1716

17+
# see #2046
18+
NO_FS_MONITOR = ('-c', 'core.useBuiltinFSMonitor=false')
19+
1820

1921
def zsplit(s: str) -> List[str]:
2022
s = s.strip('\0')
@@ -185,10 +187,11 @@ def init_repo(path: str, remote: str) -> None:
185187
if os.path.isdir(remote):
186188
remote = os.path.abspath(remote)
187189

190+
git = ('git', *NO_FS_MONITOR)
188191
env = no_git_env()
189192
# avoid the user's template so that hooks do not recurse
190-
cmd_output_b('git', 'init', '--template=', path, env=env)
191-
cmd_output_b('git', 'remote', 'add', 'origin', remote, cwd=path, env=env)
193+
cmd_output_b(*git, 'init', '--template=', path, env=env)
194+
cmd_output_b(*git, 'remote', 'add', 'origin', remote, cwd=path, env=env)
192195

193196

194197
def commit(repo: str = '.') -> None:

tests/commands/autoupdate_test.py

Lines changed: 9 additions & 0 deletions

0 commit comments

Comments
 (0)