Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Revert "Use git exec candidate list on all platforms for build" #34844

Merged
merged 1 commit into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
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: 8 additions & 7 deletions build/git_revision.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@
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):
'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_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',
Expand Down
15 changes: 9 additions & 6 deletions tools/githooks/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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')
Copy link
Member Author

@loic-sharma loic-sharma Jul 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the line that causes the issue: it shouldn't be updated before the non-Windows pre-push githook is fixed to work on Windows.

Copy link
Contributor

@mtolmacs mtolmacs Jul 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The non-Windows pre-push works perfectly on Windows since forever, the issue is with python executable discovery / requirement as the main pre-push is a python script.

Edit: Leaving this comment for my reference and for whoever comes around looking back.

result = subprocess.run([
git,
'config',
Expand Down