Move rosdistro updating to a separate script

... and fix bugs
This commit is contained in:
Michal Sojka 2024-09-18 09:17:09 +02:00
parent ee76acc9c9
commit 527b8460e5
2 changed files with 28 additions and 23 deletions

26
maint/rosdistro-update.sh Executable file
View file

@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -euo pipefail
pr_body=${1:-/tmp/.body}
nix build .#rosdistro --out-link /tmp/rosdistro-old
nix flake update rosdistro
nix build .#rosdistro --out-link /tmp/rosdistro-new
grep -Rh nixos: /tmp/rosdistro-old > /tmp/rosdistro-old.txt
grep -Rh nixos: /tmp/rosdistro-new > /tmp/rosdistro-new.txt
git reset --hard
if ! git diff -U0 /tmp/rosdistro-old.txt /tmp/rosdistro-new.txt > /tmp/rosdistro-diff; then
# redo update with nice commit message
nix flake update rosdistro --commit-lock-file
GIT_EDITOR='sed -i -e "1crosdistro update"' git commit --amend
GIT_EDITOR='sed -i -e "\$r/tmp/rosdistro-diff"' git commit --amend
cat <<EOF > "$pr_body"
Diff:
\`\`\`diff
$(cat /tmp/rosdistro-diff)
\`\`\`
EOF
else
echo "No relevant changes"
fi