79 lines
No EOL
1.6 KiB
Bash
79 lines
No EOL
1.6 KiB
Bash
source './.env'
|
|
|
|
PASSED_ISSUE=''
|
|
|
|
while test $# -gt 0; do
|
|
case "$1" in
|
|
-i|--issue)
|
|
shift
|
|
if test $# -gt 0
|
|
then
|
|
export PASSED_ISSUE=$1
|
|
fi
|
|
shift
|
|
;;
|
|
-h|--help) print_usage ;;
|
|
*) print_usage
|
|
break
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ -z $PASSED_ISSUE ]]
|
|
then
|
|
echo -e "missing issue; use -i \e[3missue\e[0m"
|
|
exit 1
|
|
fi
|
|
|
|
printf "\n"
|
|
|
|
ISSUES=$(curl -X 'GET' \
|
|
'https://git.n39.eu/api/v1/repos/'$OWNER'/'$REPO'/issues' \
|
|
-H 'accept: application/json' | tr ' ' -)
|
|
|
|
printf "\n"
|
|
echo $ISSUES
|
|
|
|
ISSUE=$(jq '.[] | select(.title|test("'$PASSED_ISSUE'"))' <<< $ISSUES)
|
|
|
|
printf "\n"
|
|
echo $ISSUE
|
|
|
|
NAME=$(jq '.title' <<< $ISSUE)
|
|
|
|
printf "\n"
|
|
echo $NAME
|
|
|
|
BRANCH=$(curl -X 'POST' 'https://git.n39.eu/api/v1/repos/'$OWNER'/'$REPO'/branches' \
|
|
-H "accept: application/json" \
|
|
-H 'Authorization: token '${FORJEGO_ACCESS_TOKEN} \
|
|
-H "Content-Type: application/json" -d '{"new_branch_name": '$NAME', "old_branch_name": "main"}' -i)
|
|
|
|
echo $BRANCH
|
|
|
|
USER=$(git config --global user.name)
|
|
|
|
MR=$(curl -X 'POST' 'https://git.n39.eu/api/v1/repos/'$OWNER'/'$REPO'/pulls' \
|
|
-H "accept: application/json" \
|
|
-H 'Authorization: token '${FORJEGO_ACCESS_TOKEN} \
|
|
-H "Content-Type: application/json" -d '{
|
|
"assignee": "'$USER'",
|
|
"assignees": [
|
|
"string"
|
|
],
|
|
"base": "string",
|
|
"body": "string",
|
|
"head": "string",
|
|
"labels": [
|
|
0
|
|
],
|
|
"milestone": 0,
|
|
"title": "string"
|
|
}' -i)
|
|
|
|
USER=$(git checkout $BRANCH)
|
|
|
|
|
|
#git browse -- issues
|
|
#git checkout -b ''
|
|
#git push -o merge_request.create origin my-branch |