@@ -186,6 +186,7 @@ def _is_entirely_submodule_updates(repo, commit):
186
186
return GOOD , "skipped (submodules updates)"
187
187
188
188
non_existent = dict ()
189
+ unmerged = dict ()
189
190
found_cherry_pick_line = False
190
191
for match in prog_cp .findall (commit .message ):
191
192
found_cherry_pick_line = True
@@ -195,9 +196,11 @@ def _is_entirely_submodule_updates(repo, commit):
195
196
# These errors mean that the git library recognized the
196
197
# hash as a valid commit, but the GitHub Action didn't
197
198
# fetch the entire repo, so we don't have all the meta
198
- # data about this commit. Bottom line: it's a good hash.
199
- # So -- no error here.
200
- pass
199
+ # data about this commit. This occurs because the commit
200
+ # only exists in an as-yet unmerged pull request on github. Therefore, we
201
+ # want to fail this commit until the corresponding pull request
202
+ # is merged.
203
+ unmerged [match ] = True
201
204
except git .BadName as e :
202
205
# Use a dictionary to track the non-existent hashes, just
203
206
# on the off chance that the same non-existent hash exists
@@ -208,15 +211,27 @@ def _is_entirely_submodule_updates(repo, commit):
208
211
209
212
# Process the results for this commit
210
213
if found_cherry_pick_line :
211
- if len (non_existent ) == 0 :
214
+ if len (non_existent ) == 0 and len ( unmerged ) == 0 :
212
215
return GOOD , None
213
- else :
216
+ elif len ( non_existent ) > 0 and len ( unmerged ) == 0 :
214
217
str = f"contains a cherry pick message that refers to non-existent commit"
215
218
if len (non_existent ) > 1 :
216
219
str += "s"
217
220
str += ": "
218
221
str += ", " .join (non_existent )
219
222
return BAD , str
223
+ elif len (non_existent ) == 0 and len (unmerged ) > 0 :
224
+ str = f"contains a cherry pick message that refers to a commit that exists, but is in an as-yet unmerged pull request"
225
+ if len (non_existent ) > 1 :
226
+ str += "s"
227
+ str += ": "
228
+ str += ", " .join (unmerged )
229
+ return BAD , str
230
+ else :
231
+ str = f"contains a cherry pick message that refers to both non-existent commits and commits that exist but are in as-yet unmerged pull requests"
232
+ str += ": "
233
+ str += ", " .join (non_existent + unmerged )
234
+ return BAD , str
220
235
221
236
else :
222
237
if config ['cherry pick required' ]:
0 commit comments