git: cpr
This commit is contained in:
parent
dec957203d
commit
ef05831e57
|
@ -1,4 +1,5 @@
|
|||
/gcloud
|
||||
/git/.git-credentials
|
||||
/git/github_token
|
||||
/node/.npmrc
|
||||
/ssh
|
||||
|
|
|
@ -6,6 +6,7 @@ Things that are not checked in but which should live in this directory:
|
|||
|
||||
- `gcloud/`
|
||||
- `git/.git-credentials`
|
||||
- `git/github_token`
|
||||
- `ssh/`
|
||||
|
||||
## WSL setup
|
||||
|
@ -22,6 +23,7 @@ Use `squashfs2tar.sh` to convert squashfs files from e.g. https://cloud-images.u
|
|||
- `git clean-modes` - reset all file modes to to those in the repository
|
||||
- `git clean-original` - delete all `refs/original/` refs left by `git filter-branch`
|
||||
- `get clean-user` - set author and committer of all commits in the given range to the currently configured identity
|
||||
- `git cpr` - checkout a PR from GitHub by id, and set up the local branch to track the appropriate branch on the appropriate fork
|
||||
- `git index-list-skip` - list all files that have had `--skip-worktree` set on them
|
||||
- `git index-skip` - set `--skip-worktree` on a given file
|
||||
- `git index-unskip` - set `--no-skip-worktree` on a given file
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
clean-modes = !git -c core.filemode diff -R | grep -E '^(diff|(old|new) mode)' | git apply
|
||||
clean-original = !git show-ref | grep ' refs/original/' | cut -d ' ' -f 2 | xargs -r -n 1 git update-ref -d
|
||||
clean-user = !git filter-branch --env-filter 'GIT_AUTHOR_EMAIL="$(git config --get user.email)" GIT_AUTHOR_NAME="$(git config --get user.name)" GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL" GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"' --
|
||||
cpr = "!f() { \"$(dirname \"$(realpath ~/.gitconfig)\")\"/cpr \"$@\"; }; f"
|
||||
index-list-skip = !git ls-files -v | grep ^S | cut -c3-
|
||||
index-skip = update-index --skip-worktree
|
||||
index-unskip = update-index --no-skip-worktree
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
[ $# = 1 ]
|
||||
[[ "$(git remote get-url origin)" =~ [/@]github\.com[/:]([^/:]+)\/([^/]+)\.git$ ]]
|
||||
read REMOTE BRANCH < <(curl -s -H "Authorization: bearer $(cat "$(dirname "$0")"/github_token)" -X POST -d "{\"query\":\"{ repository(owner: \\\"${BASH_REMATCH[1]}\\\", name: \\\"${BASH_REMATCH[2]}\\\") { pullRequest(number: $1) { headRef { name } headRepository { nameWithOwner } } } }\"}" https://api.github.com/graphql | jq -r '.data.repository.pullRequest | "https://github.com/\(.headRepository.nameWithOwner).git \(.headRef.name)"')
|
||||
git fetch $REMOTE $BRANCH:pr/$1
|
||||
git config branch.pr/$1.remote $REMOTE
|
||||
git config branch.pr/$1.merge refs/heads/$BRANCH
|
||||
git checkout pr/$1
|
Loading…
Reference in New Issue