Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding git candidate search to githooks setup.py
  • Loading branch information
mtolmacs committed Jun 28, 2022
commit da946edec1b252f6a64641ba8aa905fb5e7203cb
16 changes: 6 additions & 10 deletions tools/githooks/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import os
import subprocess
import sys
from shutil import which # Natively supported since python 3.3

SRC_ROOT = os.path.dirname(
os.path.dirname(
Expand All @@ -18,18 +19,13 @@
)
FLUTTER_DIR = os.path.join(SRC_ROOT, 'flutter')


def IsWindows():
os_id = sys.platform
return os_id.startswith('win32') or os_id.startswith('cygwin')


def Main(argv):
git = 'git'
githooks = os.path.join(FLUTTER_DIR, 'tools', 'githooks')
if IsWindows():
git = 'git.bat'
githooks = os.path.join(githooks, 'windows')
git_candidates = ['git', 'git.sh', 'git.bat']
git = next(filter(which, git_candidates), None)
if git is None:
candidates = "', '".join(git_candidates)
raise IOError(f"Looks like GIT is not on the path. Tried '{candidates}'")
result = subprocess.run([
git,
'config',
Expand Down