Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use git exec candidate list on all platforms for build #34294

Merged
merged 7 commits into from
Jun 28, 2022
Merged
Changes from all commits
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
15 changes: 7 additions & 8 deletions build/git_revision.py
Original file line number Diff line number Diff line change
@@ -10,21 +10,20 @@
import subprocess
import os
import argparse


def is_windows():
os_id = sys.platform
return os_id.startswith('win32') or os_id.startswith('cygwin')
from shutil import which # Natively supported since python 3.3


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

git = 'git'
if is_windows():
git = 'git.bat'
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}'")

version = subprocess.check_output([
git,
'-C',
15 changes: 6 additions & 9 deletions tools/githooks/setup.py
Original file line number Diff line number Diff line change
@@ -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(
@@ -19,17 +20,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',