Commit 961f7ef8 authored by Clive Makamara's avatar Clive Makamara Committed by GitHub

Merge pull request #9 from dreidev/feature/review

cmosh submitted feature/review branch for review
parents 970f4647 e0ab6427
...@@ -495,43 +495,60 @@ cmd_review() { ...@@ -495,43 +495,60 @@ cmd_review() {
REPO="$(basename "${GIT_URL_WITHOUT_SUFFIX}")" REPO="$(basename "${GIT_URL_WITHOUT_SUFFIX}")"
URL_WITH_OWNER="$(dirname "${GIT_URL_WITHOUT_SUFFIX})")" URL_WITH_OWNER="$(dirname "${GIT_URL_WITHOUT_SUFFIX})")"
OWNER=$(basename $(echo $URL_WITH_OWNER | tr ":" /)) OWNER=$(basename $(echo $URL_WITH_OWNER | tr ":" /))
DEVELOPMENT_BRANCH=$(git config --get gitflow.branch.develop)
echo $REPO $OWNER
echo $BRANCH
if [ -f ./.git/.gitflow/.github_token ]; if [ -f ./.git/.gitflow/.github_token ];
then then
GITHUB_USERNAME=$(tail -1 ./.git/.gitflow/.github_username | head -1) GITHUB_USERNAME=$(tail -1 ./.git/.gitflow/.github_username | head -1)
GITHUB_TOKEN=$(tail -1 ./.git/.gitflow/.github_token | head -1) GITHUB_TOKEN=$(tail -1 ./.git/.gitflow/.github_token | head -1)
curl -X POST -H "Content-Type: application/json" \ GITHUB_REQUEST=$(curl -X POST --write-out %{http_code} --silent --output /dev/null -H "Content-Type: application/json" \
-H "Cache-Control: no-cache" \ -H "Cache-Control: no-cache" \
--user $GITHUB_USERNAME:$GITHUB_TOKEN \ --user $GITHUB_USERNAME:$GITHUB_TOKEN \
-d '{ -d '{
"title":"'"$GITHUB_USERNAME"' submitted '"$BRANCH"' branch for review", "title":"'"$GITHUB_USERNAME"' submitted '"$BRANCH"' branch for review",
"head":"'"$BRANCH"'", "head":"'"$BRANCH"'",
"base":"develop", "base":"'"$DEVELOPMENT_BRANCH"'",
"body":"'"$GITHUB_USERNAME"' is asking for code review. Total time taken:'"$FINALTIME"' expected time was '"$TIME_EXPECTED"' hour(s), Time spent on breaks was '"$TOTAL_TIME_OFF"' -- message by gitflow", "body":"'"$GITHUB_USERNAME"' is asking for code review. Total time taken:'"$FINALTIME"' expected time was '"$TIME_EXPECTED"' hour(s), Time spent on breaks was '"$TOTAL_TIME_OFF"' -- message by gitflow",
"maintainer_can_modify": true "maintainer_can_modify": true
}' \ }' \
"https://api.github.com/repos/$OWNER/$REPO/pulls" "https://api.github.com/repos/$OWNER/$REPO/pulls")
echo "Pull request created on github please inform the code reviewer by mentioning them in the comments"
# else # if [ "$GITHUB_REQUEST" -gt 300 ]
# INTERRUPT_REASON="No reason :)" # then
# echo "Failed to create pull request"
# else
# fi
fi fi
# if [ -f ./.git/.gitflow/.gitlab_token ]; if [ -f ./.git/.gitflow/.gitlab_token ];
# then then
# echo "Why were you interrupted?"
# read INTERRUPT_REASON
# rm ./.git/.gitflow/.interrupt-feature-$NAME
# # else
# # INTERRUPT_REASON="No reason :)"
# fi
GITLAB_TOKEN=$(tail -1 ./.git/.gitflow/.gitlab_token | head -1)
USER_NAME=$(git config --get --global user.name)
GITLAB_REQUEST=$(curl -X POST --write-out %{http_code} --silent --output /dev/null -H "PRIVATE-TOKEN: $GITLAB_TOKEN" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -H "Postman-Token: 209ed2f2-a7bd-ab33-a432-1d884669976b" -d '{
"target_branch": "'"$DEVELOPMENT_BRANCH"'",
"source_branch": "'"$BRANCH"'",
"title": "'"$BRANCH Merge Request by $USER_NAME"'",
"body":"'"$USER_NAME"' is asking for code review. Total time taken:'"$FINALTIME"' expected time was '"$TIME_EXPECTED"' hour(s), Time spent on breaks was '"$TOTAL_TIME_OFF"' -- message by gitflow"
}' "https://gitlab.com/api/v3/projects/$OWNER%2F$REPO/merge_requests")
echo "Pull request created on gitlab please inform the code reviewer by mentioning them in the comments"
# if [ "$GITLAB_REQUEST" -gt 300 ]
# then
# echo "Failed to create merge request"
# else
# echo "Merge request created succesfully"
# fi
# fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment