Tampermonkey/pr.sh
2022-01-12 19:44:46 +08:00

54 lines
1.1 KiB
Bash

#!/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"
}'