git cpr: work without .git in remote
This commit is contained in:
parent
220a38f1ac
commit
3b53702f4f
4
git/cpr
4
git/cpr
|
@ -1,8 +1,8 @@
|
|||
#!/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 remote get-url origin)" =~ [/@]github\.com[/:]([^/:]+)\/([^/]+)$ ]]
|
||||
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]%.git}\\\") { pullRequest(number: $1) { headRef { name } headRepository { nameWithOwner } } } }\"}" https://api.github.com/graphql | jq -r '.data.repository.pullRequest | "https://github.com/\(.headRepository.nameWithOwner) \(.headRef.name)"')
|
||||
git fetch $REMOTE $BRANCH:pr/$1
|
||||
git config branch.pr/$1.remote $REMOTE
|
||||
git config branch.pr/$1.merge refs/heads/$BRANCH
|
||||
|
|
Loading…
Reference in New Issue