From 74787fca7b290de10eebd24a0f5e2cfdda346cbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Sharma?= <737941+loic-sharma@users.noreply.github.com> Date: Fri, 22 Jul 2022 09:53:42 -0700 Subject: [PATCH] Revert "Use git exec candidate list on all platforms for build (#34294)" This reverts commit bc87d306dff38ae8a97e0a026c9f9f4ead6fd191. --- build/git_revision.py | 15 ++++++++------- tools/githooks/setup.py | 15 +++++++++------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/build/git_revision.py b/build/git_revision.py index 0b0653f3ad3f9..d84886d8b8427 100755 --- a/build/git_revision.py +++ b/build/git_revision.py @@ -10,7 +10,11 @@ import subprocess import os import argparse -from shutil import which # Natively supported since python 3.3 + + +def is_windows(): + os_id = sys.platform + return os_id.startswith('win32') or os_id.startswith('cygwin') def get_repository_version(repository): @@ -18,12 +22,9 @@ def get_repository_version(repository): if not os.path.exists(repository): raise IOError('path does not exist') - 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}'") - + git = 'git' + if is_windows(): + git = 'git.bat' version = subprocess.check_output([ git, '-C', diff --git a/tools/githooks/setup.py b/tools/githooks/setup.py index 9e677e96b91d5..ea8edf467a838 100755 --- a/tools/githooks/setup.py +++ b/tools/githooks/setup.py @@ -10,7 +10,6 @@ import os import subprocess import sys -from shutil import which # Natively supported since python 3.3 SRC_ROOT = os.path.dirname( os.path.dirname( @@ -20,13 +19,17 @@ 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') - 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}'") + if IsWindows(): + git = 'git.bat' + githooks = os.path.join(githooks, 'windows') result = subprocess.run([ git, 'config',