File tree 2 files changed +17
-13
lines changed 2 files changed +17
-13
lines changed Original file line number Diff line number Diff line change 10
10
import subprocess
11
11
import os
12
12
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' )
14
18
15
19
16
20
def get_repository_version (repository ):
17
21
'Returns the Git HEAD for the supplied repository path as a string.'
18
22
if not os .path .exists (repository ):
19
23
raise IOError ('path does not exist' )
20
24
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'
27
28
version = subprocess .check_output ([
28
29
git ,
29
30
'-C' ,
Original file line number Diff line number Diff line change 10
10
import os
11
11
import subprocess
12
12
import sys
13
- from shutil import which # Natively supported since python 3.3
14
13
15
14
SRC_ROOT = os .path .dirname (
16
15
os .path .dirname (
20
19
FLUTTER_DIR = os .path .join (SRC_ROOT , 'flutter' )
21
20
22
21
22
+ def IsWindows ():
23
+ os_id = sys .platform
24
+ return os_id .startswith ('win32' ) or os_id .startswith ('cygwin' )
25
+
26
+
23
27
def Main (argv ):
28
+ git = 'git'
24
29
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' )
30
33
result = subprocess .run ([
31
34
git ,
32
35
'config' ,
You can’t perform that action at this time.
0 commit comments