diff mbox series

[yocto-autobuilder-helper,dunfell] scripts: rebase before pushing patch and CVE metrics

Message ID 20260108193643.317392-2-yoann.congal@smile.fr
State New
Headers show
Series [yocto-autobuilder-helper,dunfell] scripts: rebase before pushing patch and CVE metrics | expand

Commit Message

Yoann Congal Jan. 8, 2026, 7:36 p.m. UTC
From: Ross Burton <ross.burton@arm.com>

There's a chance that run-cvecheck and run-patchmetrics fail to push
because the remote repository has changed. Try to resolve this by pulling
and rebasing immediately before the push, and failing if we can't rebase.

[ YOCTO #15529 ]

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

(cherry-picked from commit 60e2011f34793fb638c223e520cef823025c8c26)
This backport should fix [YOCTO #16111]
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
@Richard, do you want me to test it on AB first?
---
 scripts/run-cvecheck     | 4 ++++
 scripts/run-patchmetrics | 4 ++++
 2 files changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/scripts/run-cvecheck b/scripts/run-cvecheck
index d22dc82..c6b0066 100755
--- a/scripts/run-cvecheck
+++ b/scripts/run-cvecheck
@@ -90,6 +90,10 @@  if [ -e tmp/log/cve/cve-summary.json ]; then
     git -C $METRICSDIR add cve-check/$BRANCH/$TIMESTAMP.json
     git -C $METRICSDIR commit -asm "Autobuilder adding new CVE data for branch $BRANCH" || true
     if [ "$PUSH" = "1" ]; then
+        if ! git -C $METRICSDIR pull --rebase; then
+            echo "Aborting push, metrics repo has updated and cannot rebase cleanly"
+            exit 1
+        fi
         git -C $METRICSDIR push
     fi
     $OURDIR/cve-report.py tmp/log/cve/cve-summary.json > $RESULTSDIR/cve-status-$BRANCH.txt
diff --git a/scripts/run-patchmetrics b/scripts/run-patchmetrics
index 391ac45..8e52371 100755
--- a/scripts/run-patchmetrics
+++ b/scripts/run-patchmetrics
@@ -24,6 +24,10 @@  if [ ! -e $PARENTDIR/yocto-metrics ]; then
 fi
 $OURDIR/patchmetrics-update --repo $PARENTDIR --patchscript $PARENTDIR/scripts/contrib/patchreview.py --metadata $TARGETDIR --json $PARENTDIR/yocto-metrics/patch-status.json
 git -C $PARENTDIR/yocto-metrics commit -asm "Autobuilder adding new patch stats"
+if ! git -C $PARENTDIR/yocto-metrics pull --rebase; then
+	echo "Aborting push, metrics repo has updated and cannot rebase cleanly"
+	exit 1
+fi
 git -C $PARENTDIR/yocto-metrics push
 
 if [ ! -d $RESULTSDIR ]; then