ci_run_n_monitor: allow detached heads as well
When running on a detached head (eg. checkout of a tag or a specific commit), there is no active branch, so we can't perform this check; just skip it and assume the user knows what they're doing. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27578>
This commit is contained in:
@@ -20,7 +20,7 @@ from collections import defaultdict
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from functools import partial
|
||||
from itertools import chain
|
||||
from subprocess import check_output
|
||||
from subprocess import check_output, CalledProcessError
|
||||
from typing import TYPE_CHECKING, Iterable, Literal, Optional
|
||||
|
||||
import gitlab
|
||||
@@ -426,27 +426,32 @@ if __name__ == "__main__":
|
||||
REV = check_output(['git', 'rev-parse', REV]).decode('ascii').strip()
|
||||
|
||||
if args.rev == 'HEAD':
|
||||
branch_name = check_output([
|
||||
'git', 'symbolic-ref', '-q', 'HEAD',
|
||||
]).decode('ascii').strip()
|
||||
try:
|
||||
branch_name = check_output([
|
||||
'git', 'symbolic-ref', '-q', 'HEAD',
|
||||
]).decode('ascii').strip()
|
||||
except CalledProcessError:
|
||||
branch_name = ""
|
||||
|
||||
tracked_remote = check_output([
|
||||
'git', 'for-each-ref', '--format=%(upstream)',
|
||||
branch_name,
|
||||
]).decode('ascii').strip()
|
||||
|
||||
# Ignore local branches that do not track any remote
|
||||
if tracked_remote:
|
||||
remote_rev = check_output([
|
||||
'git', 'rev-parse', tracked_remote,
|
||||
# Ignore detached heads
|
||||
if branch_name:
|
||||
tracked_remote = check_output([
|
||||
'git', 'for-each-ref', '--format=%(upstream)',
|
||||
branch_name,
|
||||
]).decode('ascii').strip()
|
||||
|
||||
if REV != remote_rev:
|
||||
print(
|
||||
f"Local HEAD commit {REV[:10]} is different than "
|
||||
f"tracked remote HEAD commit {remote_rev[:10]}"
|
||||
)
|
||||
print("Did you forget to `git push` ?")
|
||||
# Ignore local branches that do not track any remote
|
||||
if tracked_remote:
|
||||
remote_rev = check_output([
|
||||
'git', 'rev-parse', tracked_remote,
|
||||
]).decode('ascii').strip()
|
||||
|
||||
if REV != remote_rev:
|
||||
print(
|
||||
f"Local HEAD commit {REV[:10]} is different than "
|
||||
f"tracked remote HEAD commit {remote_rev[:10]}"
|
||||
)
|
||||
print("Did you forget to `git push` ?")
|
||||
|
||||
projects.append(get_gitlab_project(gl, args.project))
|
||||
(pipe, cur_project) = wait_for_pipeline(projects, REV)
|
||||
|
Reference in New Issue
Block a user