jj-fork 0.2.7

Maintain a fork as jj series and glues on top of upstream, and keep them current
#!/usr/bin/env bash
# Installs the jj release that tests and CI use. Usage: scripts/install-jj [DEST_DIR]
# Skips the download when DEST_DIR/jj is already this version.
set -euo pipefail

version=0.43.0
asset="jj-v${version}-x86_64-unknown-linux-musl.tar.gz"
sha256=59e5588583ac82b623239929368c65b90735931c0f26b5a16c1f04d5bb97643d
dest="${1:-$HOME/.local/bin}"

if [[ "$("$dest/jj" --version 2>/dev/null)" == "jj $version"* ]]; then
  echo "jj $version already installed in $dest"
  exit 0
fi

tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
curl -fsSL --retry 3 -o "$tmp/$asset" "https://github.com/jj-vcs/jj/releases/download/v${version}/${asset}"
echo "$sha256  $tmp/$asset" | sha256sum -c --quiet -
tar -xzf "$tmp/$asset" -C "$tmp" ./jj
mkdir -p "$dest"
install -m 0755 "$tmp/jj" "$dest/jj"
echo "installed $("$dest/jj" --version) in $dest"