aboutsummaryrefslogtreecommitdiff
path: root/tmuxrdr/scripts/sync-upstream
diff options
context:
space:
mode:
authorIgor Soarez <igor@soarez.org>2026-10-05 11:27:00 +0300
committerIgor Soarez <igor@soarez.org>2026-10-05 11:27:00 +0300
commita58874ca96a87fbf6a86e8df7821f29749985b58 (patch)
tree655b3f52bf768a2757a07dd52944dce1e4518453 /tmuxrdr/scripts/sync-upstream
parent48cd6744f077a3d59e61bbdcdb1e0bff8da7a540 (diff)
tmuxrdr: install, end-to-end test and upstream sync scripts
install links ~/.config/herdr/config.toml and the plugin to this checkout and registers the plugin. test-e2e presses each binding in a herdr client running in a throwaway tmux and session, and checks the result through the herdr CLI. sync-upstream rebases the tmuxrdr commits onto a newer herdr release, keeping the old branch as a backup.
Diffstat (limited to 'tmuxrdr/scripts/sync-upstream')
-rwxr-xr-xtmuxrdr/scripts/sync-upstream72
1 files changed, 72 insertions, 0 deletions
diff --git a/tmuxrdr/scripts/sync-upstream b/tmuxrdr/scripts/sync-upstream
new file mode 100755
index 00000000..44c1b010
--- /dev/null
+++ b/tmuxrdr/scripts/sync-upstream
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+# Move tmuxrdr onto a newer herdr release: rebase the tmuxrdr commits from the
+# release they sit on onto the new one.
+#
+# tmuxrdr/scripts/sync-upstream newest stable release (vX.Y.Z)
+# tmuxrdr/scripts/sync-upstream v0.9.4 that release
+#
+# Releases, not upstream's master: a release is what Homebrew ships, so a
+# tmuxrdr build speaks the same protocol as any stock herdr server around it.
+# The base is the newest release tag behind HEAD; the tmuxrdr commits are
+# everything after it. The branch as it was is kept as tmuxrdr-on-<old tag>,
+# so a bad rebase costs nothing: `git switch -C tmuxrdr tmuxrdr-on-<old tag>`.
+# rerere is on in this checkout, so a conflict resolved once is resolved again
+# by itself on the next release.
+
+set -euo pipefail
+
+cd "$(dirname "$0")/../.."
+branch="tmuxrdr"
+target="${1:-}"
+
+die() { >&2 echo "ERROR: $*"; exit 1; }
+
+[[ "$(git symbolic-ref --short -q HEAD)" == "$branch" ]] || die "check out $branch first"
+[[ -z "$(git status --porcelain)" ]] || die "uncommitted changes; commit or stash them first"
+
+git fetch --quiet --tags --prune upstream
+
+old="$(git describe --tags --abbrev=0 --match 'v[0-9]*' HEAD)"
+if [[ -z "$target" ]]; then
+ target="$(git tag -l 'v[0-9]*' --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)"
+fi
+git rev-parse -q --verify "refs/tags/$target^{commit}" >/dev/null || die "no release tag $target"
+
+if [[ "$target" == "$old" ]]; then
+ echo "up to date: $branch is on $old"
+ exit 0
+fi
+[[ "$(printf '%s\n' "$old" "$target" | sort -V | tail -n 1)" == "$target" ]] \
+ || die "$target is older than $old, the release $branch is on"
+
+echo "$branch: $(git rev-list --count "$old..HEAD") commits on $old"
+git log --oneline --reverse "$old..HEAD" | sed 's/^/ /'
+echo "rebasing onto $target ($(git rev-list --count "$old..$target") upstream commits)"
+
+backup="$branch-on-$old"
+git branch -f "$backup" HEAD
+
+if ! git rebase --onto "$target" "$old" "$branch"; then
+ cat <<EOF
+
+The rebase stopped on a conflict -- in a code patch, since everything else
+lives in tmuxrdr/, which upstream never touches.
+ git status what conflicts
+ ... resolve, git add, then: git rebase --continue
+ git rebase --abort give up: $branch goes back as it was
+The branch before the rebase is also kept as $backup.
+EOF
+ exit 1
+fi
+
+echo
+echo "$branch is on $target; the old one is kept as $backup."
+installed="$("${HERDR:-herdr}" --version 2>/dev/null | awk '{print "v" $2}')"
+if [[ "$installed" != "$target" ]]; then
+ echo "herdr on PATH is ${installed:-missing}, not $target: test against $target"
+ echo "(upgrade it, or build this checkout -- README.md) before trusting test-e2e."
+fi
+HERDR_CONFIG_PATH="$PWD/tmuxrdr/config/config.toml" "${HERDR:-herdr}" config check \
+ || echo "config check found issues against the herdr on PATH; see above"
+echo "Next: tmuxrdr/scripts/test-e2e"