Skip to content

Commit

Permalink
Merge pull request #19 from virtuoushub/pull-request-fix
Browse files Browse the repository at this point in the history
fix: allow curl of PR metadata
  • Loading branch information
William Lauzé authored Jun 8, 2020
2 parents cabb284 + 76cb01c commit 939b2de
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions commitlint_range.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ if [ -n "${CIRCLE_PULL_REQUEST}" ]
then
echo "This is a pull request"
PULL_REQUEST_NUMBER=$(echo "${CIRCLE_PULL_REQUEST}" | cut -d/ -f7)
PULL_REQUEST_DETAILS=$(curl https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/pulls/${PULL_REQUEST_NUMBER})
UPSTREAM_PROJECT_USERNAME=$(echo "${CIRCLE_PULL_REQUEST}" | cut -d/ -f4)
CURL_URL="https://api.github.com/repos/${UPSTREAM_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/pulls/${PULL_REQUEST_NUMBER}"
PULL_REQUEST_DETAILS=$(curl ${CURL_URL})
REPO_IS_PUBLIC=$(echo "${PULL_REQUEST_DETAILS}" | jq -r .url)
if [ -n "${REPO_IS_PUBLIC}" ]
then
echo "Public repo"
else
echo "Private repo"
PULL_REQUEST_DETAILS=$(curl -H "Authorization: token ${GITHUB_TOKEN_COMMITLINT}" https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/pulls/${PULL_REQUEST_NUMBER})
PULL_REQUEST_DETAILS=$(curl -H "Authorization: token ${GITHUB_TOKEN_COMMITLINT}" ${CURL_URL})
fi

BASE_SHA1=$(echo "${PULL_REQUEST_DETAILS}" | jq -r .base.sha)
Expand Down

0 comments on commit 939b2de

Please sign in to comment.