From 044c51b6bf450c215a9c83c203f520d30f9cab2c Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Wed, 10 Jan 2024 11:49:19 +0000 Subject: [PATCH] ci_run_n_monitor: warn user if they forgot to push the branch Only perform this check if they set `--rev HEAD` (or don't specify it); let's assume if they select another commit, they know what they're doing. Part-of: --- bin/ci/ci_run_n_monitor.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/bin/ci/ci_run_n_monitor.py b/bin/ci/ci_run_n_monitor.py index 6d5a2153435..43d4b6fe308 100755 --- a/bin/ci/ci_run_n_monitor.py +++ b/bin/ci/ci_run_n_monitor.py @@ -407,6 +407,28 @@ if __name__ == "__main__": REV = mesa_project.mergerequests.get(args.mr).sha else: 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() + + tracked_remote = check_output([ + 'git', 'for-each-ref', '--format=%(upstream)', + branch_name, + ]).decode('ascii').strip() + + 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)