From 3ec1698830aec9eca84ab4d2f331e3a2b520bd8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=98=E6=B8=8A?= Date: Wed, 12 Jan 2022 19:44:46 +0800 Subject: [PATCH] update --- pr.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 pr.sh diff --git a/pr.sh b/pr.sh new file mode 100644 index 0000000..d7d04c2 --- /dev/null +++ b/pr.sh @@ -0,0 +1,53 @@ +#!/bin/bash + + +git config --global alias.visual '!gitk' + +# check dirty +if [ -n "$(git status --porcelain)" ]; then + git status + echo "there are untracked changes"; + exit 1 +fi + +# TODO: check up-to-date +local_head_commit=`git rev-parse --short HEAD` +remote_head_commit=`git rev-parse --short origin/HEAD` + +local_branch=`git rev-parse --abbrev-ref HEAD` +remote_branch=${local_head_commit} + +echo ${local_head_commit} +echo ${remote_head_commit} +echo ${local_branch} +echo ${remote_branch} + +# TODO: keep first branch +git push origin master ${local_branch}:${remote_branch} + + +git config --get remote.origin.url + +access_token=`git config user.accessToken` +# TODO: check empty + +# TODO: create or update +curl -X 'POST' \ + 'https://code.newnius.com/api/v1/repos/snippets/Tampermonkey/pulls?access_token='${access_token} \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d '{ + "assignee": "newnius", + "assignees": [ + "newnius" + ], + "base": "master", + "body": "diff", + "due_date": "2022-01-15T08:31:16.272Z", + "head": "${remote_branch}", + "labels": [ + 0 + ], + "milestone": 0, + "title": "string" +}'