diff mbox series

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

Message ID 20260129163632.1660116-1-ross.burton@arm.com
State New
Headers show
Series [yocto-autobuilder-helper,kirkstone] scripts: rebase before pushing patch and CVE metrics | expand

Commit Message

Ross Burton Jan. 29, 2026, 4:36 p.m. UTC
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.

Backport of 60e2011 from master.

[ YOCTO #15686 ]

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 scripts/run-cvecheck     | 4 ++++
 scripts/run-patchmetrics | 5 +++++
 2 files changed, 9 insertions(+)

Comments

Yoann Congal Jan. 29, 2026, 5:07 p.m. UTC | #1
Le jeu. 29 janv. 2026 à 17:37, Ross Burton via lists.yoctoproject.org
<ross.burton=arm.com@lists.yoctoproject.org> a écrit :

> 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.
>
> Backport of 60e2011 from master.
>
> [ YOCTO #15686 ]
>
> Signed-off-by: Ross Burton <ross.burton@arm.com>
>

Thanks Ross,

I missed that when fixing
https://bugzilla.yoctoproject.org/show_bug.cgi?id=16111 (on Dunfell)

There is a now obsolete comment to remove/rephrase:

# Do another pull to make sure we're as up to date as possible.  This
is# preferable to committing and rebasing before pushing as it would
be better to# waste some time repeating work than commit potentially
corrupted files from a# git merge gone wrong.


But, this is also the case on master. I plan to send a patch someday.

---
>  scripts/run-cvecheck     | 4 ++++
>  scripts/run-patchmetrics | 5 +++++
>  2 files changed, 9 insertions(+)
>
> diff --git a/scripts/run-cvecheck b/scripts/run-cvecheck
> index d22dc825..c6b00660 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 391ac45a..5fe3d8f3 100755
> --- a/scripts/run-patchmetrics
> +++ b/scripts/run-patchmetrics
> @@ -24,6 +24,11 @@ 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
> --
> 2.43.0
>
>
>
> ------------
> Links: You receive all messages sent to this group.
> View/Reply Online (#3143):
> https://lists.yoctoproject.org/g/yocto-patches/message/3143
> Mute This Topic: https://lists.yoctoproject.org/mt/117528934/4316185
> Group Owner: yocto-patches+owner@lists.yoctoproject.org
> Unsubscribe:
> https://lists.yoctoproject.org/g/yocto-patches/leave/13179410/4316185/929767106/xyzzy
> [yoann.congal@smile.fr]
> ------------
>
>
>
diff mbox series

Patch

diff --git a/scripts/run-cvecheck b/scripts/run-cvecheck
index d22dc825..c6b00660 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 391ac45a..5fe3d8f3 100755
--- a/scripts/run-patchmetrics
+++ b/scripts/run-patchmetrics
@@ -24,6 +24,11 @@  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