1
0
Files
configuration
flake
hosts
lib
modules
pkgs
chromium-incognito
clerie-backup
clerie-keys
clerie-sops
clerie-system-remote-install
clerie-system-upgrade
clerie-update-nixfiles
factorio-launcher
feeds-dir
git-checkout-github-pr
default.nix
git-checkout-github-pr.sh
git-diff-word
git-pp
iot-data
nix-remove-result-links
nixfiles
overrides
print-afra
run-with-docker-group
ssh-gpg
update-from-hydra
uptimestatus
overlay.nix
users
.gitignore
README.md
flake.lock
flake.nix
nixfiles/pkgs/git-checkout-github-pr/git-checkout-github-pr.sh

45 lines
577 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ID=""
REMOTE="origin"
LOCAL_BRANCH=""
while [[ $# -gt 0 ]]; do
case $1 in
--remote)
REMOTE="$2"
shift
shift
;;
--local-branch)
LOCAL_BRANCH="$2"
shift
shift
;;
*)
if [[ -z "${ID}" ]]; then
ID="$1"
shift
else
echo "Unknown option $1"
exit 1
fi
;;
esac
done
if [[ -z "${ID}" ]]; then
echo "Specify GitHub PR number"
exit 1
fi
if [[ -z "${LOCAL_BRANCH}" ]]; then
LOCAL_BRANCH="pr/${ID}"
fi
git fetch "${REMOTE}" "pull/${ID}/head:${LOCAL_BRANCH}"
git switch "${LOCAL_BRANCH}"