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 concurrent.futures import ThreadPoolExecutor
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
from subprocess import check_output
|
from subprocess import check_output, CalledProcessError
|
||||||
from typing import TYPE_CHECKING, Iterable, Literal, Optional
|
from typing import TYPE_CHECKING, Iterable, Literal, Optional
|
||||||
|
|
||||||
import gitlab
|
import gitlab
|
||||||
@@ -426,27 +426,32 @@ if __name__ == "__main__":
|
|||||||
REV = check_output(['git', 'rev-parse', REV]).decode('ascii').strip()
|
REV = check_output(['git', 'rev-parse', REV]).decode('ascii').strip()
|
||||||
|
|
||||||
if args.rev == 'HEAD':
|
if args.rev == 'HEAD':
|
||||||
branch_name = check_output([
|
try:
|
||||||
'git', 'symbolic-ref', '-q', 'HEAD',
|
branch_name = check_output([
|
||||||
]).decode('ascii').strip()
|
'git', 'symbolic-ref', '-q', 'HEAD',
|
||||||
|
]).decode('ascii').strip()
|
||||||
|
except CalledProcessError:
|
||||||
|
branch_name = ""
|
||||||
|
|
||||||
tracked_remote = check_output([
|
# Ignore detached heads
|
||||||
'git', 'for-each-ref', '--format=%(upstream)',
|
if branch_name:
|
||||||
branch_name,
|
tracked_remote = check_output([
|
||||||
]).decode('ascii').strip()
|
'git', 'for-each-ref', '--format=%(upstream)',
|
||||||
|
branch_name,
|
||||||
# Ignore local branches that do not track any remote
|
|
||||||
if tracked_remote:
|
|
||||||
remote_rev = check_output([
|
|
||||||
'git', 'rev-parse', tracked_remote,
|
|
||||||
]).decode('ascii').strip()
|
]).decode('ascii').strip()
|
||||||
|
|
||||||
if REV != remote_rev:
|
# Ignore local branches that do not track any remote
|
||||||
print(
|
if tracked_remote:
|
||||||
f"Local HEAD commit {REV[:10]} is different than "
|
remote_rev = check_output([
|
||||||
f"tracked remote HEAD commit {remote_rev[:10]}"
|
'git', 'rev-parse', tracked_remote,
|
||||||
)
|
]).decode('ascii').strip()
|
||||||
print("Did you forget to `git push` ?")
|
|
||||||
|
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))
|
projects.append(get_gitlab_project(gl, args.project))
|
||||||
(pipe, cur_project) = wait_for_pipeline(projects, REV)
|
(pipe, cur_project) = wait_for_pipeline(projects, REV)
|
||||||
|
Reference in New Issue
Block a user