Skip to content

Commit

Permalink
Fix crash when using a none github repo
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoHood committed Mar 23, 2020
1 parent 3b9e95b commit 914a6d1
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions gpgit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ GPG_USER="${GPG_USER:-"${USER}"}"
GPG_EMAIL="$(git config user.email || true)"
GITHUBREPO="${GITHUBREPO:-"$(git config gpgit.githubrepo || true)"}"
GITHUBREPO="${GITHUBREPO:-"$(git config --local remote.origin.url | sed -e 's/.*github.com[:/]//' | sed -e 's/.git$//')"}"
GITHUB="${GITHUB:-"$(git config --local remote.origin.url | grep -i 'github.com')"}"
GITHUB="${GITHUB:-"$(git config --local remote.origin.url | grep -i 'github.com' || true)"}"
PRERELEASE="${PRERELEASE:-"false"}"
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
GPG_BIN="$(git config gpg.program || true)"
Expand Down Expand Up @@ -437,24 +437,27 @@ fi
# Check if tag exists
msg2 "3.3 Create signed Git tag"
if [[ -n "${FORCE}" ]]; then
# Delete existing Github release when using --force option
# It needs to get deleted before the tag, otherwise a release draft is kept as ghost online.
if check_dependency jq curl; then
# Parse existing Github release
if ! GITHUB_RELEASE="$(curl --proto-redir =https -s \
"https://github.com/gitapi/repos/${GITHUBREPO}/releases/tags/${TAG}")"; then
die "Accessing Github failed."
fi

GITHUB_RELEASE_ID="$(echo "${GITHUB_RELEASE}" | jq -r .id)"
if [[ "${GITHUB_RELEASE_ID}" != "null" ]]; then
plain "Deleting existing Github release."
interactive
get_token
curl --proto-redir =https -s -X DELETE \
"https://github.com/gitapi/repos/${GITHUBREPO}/releases/${GITHUB_RELEASE_ID}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${TOKEN}"
if [[ -n "${GITHUB}" ]]; then
# Delete existing Github release when using --force option
# It needs to get deleted before the tag, otherwise a release draft is kept as ghost online.
if check_dependency jq curl; then
# Parse existing Github release
if ! GITHUB_RELEASE="$(curl --proto-redir =https -s \
"https://github.com/gitapi/repos/${GITHUBREPO}/releases/tags/${TAG}")"; then
die "Accessing Github failed."
fi

GITHUB_RELEASE_ID="$(echo "${GITHUB_RELEASE}" | jq -r .id)"
if [[ "${GITHUB_RELEASE_ID}" != "null" ]]; then
plain "Deleting existing Github release."
interactive
get_token
curl --proto-redir =https -s -X DELETE \
"https://github.com/gitapi/repos/${GITHUBREPO}/releases/${GITHUB_RELEASE_ID}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${TOKEN}"
fi
fi
fi

Expand Down

0 comments on commit 914a6d1

Please sign in to comment.