@@ -97,14 +97,14 @@ def run_git(cmd, cwd):
97
97
app .logger .info ("Running git: %s" % ' ' .join (cmd ))
98
98
return subprocess .run (cmd , cwd = cwd , shell = False )
99
99
100
- def get_git_hash (branch ):
101
- app .logger .info ("Running git rev-parse %s in %s" % (branch , sourcedir ))
102
- return subprocess .check_output (['git' , 'rev-parse' , branch ], cwd = sourcedir , encoding = 'utf-8' , shell = False ).rstrip ()
100
+ def get_git_hash (branch , cwd ):
101
+ app .logger .info ("Running git rev-parse %s in %s" % (branch , cwd ))
102
+ return subprocess .check_output (['git' , 'rev-parse' , branch ], cwd = cwd , encoding = 'utf-8' , shell = False ).rstrip ()
103
103
104
- def on_branch (branch ):
105
- git_hash_target = get_git_hash (branch )
104
+ def on_branch (branch , cwd ):
105
+ git_hash_target = get_git_hash (branch , cwd )
106
106
app .logger .info ("Expected branch git-hash '%s'" % git_hash_target )
107
- git_hash_current = get_git_hash ('HEAD' )
107
+ git_hash_current = get_git_hash ('HEAD' , cwd )
108
108
app .logger .info ("Current branch git-hash '%s'" % git_hash_current )
109
109
return git_hash_target == git_hash_current
110
110
@@ -119,7 +119,7 @@ def checkout_branch(targetBranch, s_dir, fetch_and_reset=False, temp_branch_name
119
119
app .logger .error ("Checkout requested for an invalid branch" )
120
120
return None
121
121
remote = targetBranch .split ('/' , 1 )[0 ]
122
- if not on_branch (targetBranch ):
122
+ if not on_branch (targetBranch , cwd = s_dir ):
123
123
app .logger .info ("Checking out to %s branch" % targetBranch )
124
124
run_git (['git' , 'checkout' , targetBranch ], cwd = s_dir )
125
125
if fetch_and_reset :
@@ -128,7 +128,7 @@ def checkout_branch(targetBranch, s_dir, fetch_and_reset=False, temp_branch_name
128
128
if temp_branch_name is not None :
129
129
delete_branch (temp_branch_name , s_dir = s_dir ) # delete temp branch if it already exists
130
130
run_git (['git' , 'checkout' , '-b' , temp_branch_name , targetBranch ], cwd = s_dir ) # creates new temp branch
131
- git_hash = get_git_hash ('HEAD' )
131
+ git_hash = get_git_hash ('HEAD' , cwd = s_dir )
132
132
return git_hash
133
133
134
134
def clone_branch (targetBranch , sourcedir , out_dir , temp_branch_name ):
@@ -584,7 +584,7 @@ def generate():
584
584
os .path .join (outdir_parent , 'extra_hwdef.dat' ))
585
585
os .remove (os .path .join (outdir_parent , 'extra_hwdef.dat' ))
586
586
587
- new_git_hash = get_git_hash (chosen_branch )
587
+ new_git_hash = get_git_hash (chosen_branch , sourcedir )
588
588
git_hash_short = new_git_hash [:10 ]
589
589
app .logger .info ('Git hash = ' + new_git_hash )
590
590
selected_features_dict ['git_hash_short' ] = git_hash_short
0 commit comments