Skip to content

Commit 07924c5

Browse files
authored
Revert "Use git exec candidate list on all platforms for build" (flutter#34844)
1 parent 8d686a3 commit 07924c5

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

build/git_revision.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@
1010
import subprocess
1111
import os
1212
import argparse
13-
from shutil import which # Natively supported since python 3.3
13+
14+
15+
def is_windows():
16+
os_id = sys.platform
17+
return os_id.startswith('win32') or os_id.startswith('cygwin')
1418

1519

1620
def get_repository_version(repository):
1721
'Returns the Git HEAD for the supplied repository path as a string.'
1822
if not os.path.exists(repository):
1923
raise IOError('path does not exist')
2024

21-
git_candidates = ['git', 'git.sh', 'git.bat']
22-
git = next(filter(which, git_candidates), None)
23-
if git is None:
24-
candidates = "', '".join(git_candidates)
25-
raise IOError(f"Looks like GIT is not on the path. Tried '{candidates}'")
26-
25+
git = 'git'
26+
if is_windows():
27+
git = 'git.bat'
2728
version = subprocess.check_output([
2829
git,
2930
'-C',

tools/githooks/setup.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import os
1111
import subprocess
1212
import sys
13-
from shutil import which # Natively supported since python 3.3
1413

1514
SRC_ROOT = os.path.dirname(
1615
os.path.dirname(
@@ -20,13 +19,17 @@
2019
FLUTTER_DIR = os.path.join(SRC_ROOT, 'flutter')
2120

2221

22+
def IsWindows():
23+
os_id = sys.platform
24+
return os_id.startswith('win32') or os_id.startswith('cygwin')
25+
26+
2327
def Main(argv):
28+
git = 'git'
2429
githooks = os.path.join(FLUTTER_DIR, 'tools', 'githooks')
25-
git_candidates = ['git', 'git.sh', 'git.bat']
26-
git = next(filter(which, git_candidates), None)
27-
if git is None:
28-
candidates = "', '".join(git_candidates)
29-
raise IOError(f"Looks like GIT is not on the path. Tried '{candidates}'")
30+
if IsWindows():
31+
git = 'git.bat'
32+
githooks = os.path.join(githooks, 'windows')
3033
result = subprocess.run([
3134
git,
3235
'config',

0 commit comments

Comments
 (0)