Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
fix: handle curl error on delete branch
Browse files Browse the repository at this point in the history
  • Loading branch information
zregvart committed Dec 22, 2020
1 parent 9f64637 commit 545fbc0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion backport.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,12 @@ delete_branch() {

local status
status=$(curl -XDELETE -fsSL \
--fail \
--output /dev/null \
-w '%{http_code}' \
-H 'Accept: application/vnd.github.v3+json' \
-H "Authorization: Bearer ${INPUT_TOKEN}" \
"$refs_url/heads/$branch")
"$refs_url/heads/$branch" || true)

if [[ "${status}" == 204 || "${status}" == 422 ]]; then
return 0
Expand Down
4 changes: 2 additions & 2 deletions spec/backport_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ EOF
It 'Deletes branches'
When call delete_branch backport/123-to-branch
The value "$(cat "${curl_args}")" should equal "-XDELETE -fsSL --output /dev/null -w %{http_code} -H Accept: application/vnd.github.v3+json -H Authorization: Bearer ${INPUT_TOKEN} git-refs-url/heads/backport/123-to-branch"
The value "$(cat "${curl_args}")" should equal "-XDELETE -fsSL --fail --output /dev/null -w %{http_code} -H Accept: application/vnd.github.v3+json -H Authorization: Bearer ${INPUT_TOKEN} git-refs-url/heads/backport/123-to-branch"
End
End
Expand All @@ -246,7 +246,7 @@ EOF
It 'Doesn''t fail on deleted branches'
When call delete_branch backport/123-to-branch
The value "$(cat "${curl_args}")" should equal "-XDELETE -fsSL --output /dev/null -w %{http_code} -H Accept: application/vnd.github.v3+json -H Authorization: Bearer ${INPUT_TOKEN} git-refs-url/heads/backport/123-to-branch"
The value "$(cat "${curl_args}")" should equal "-XDELETE -fsSL --fail --output /dev/null -w %{http_code} -H Accept: application/vnd.github.v3+json -H Authorization: Bearer ${INPUT_TOKEN} git-refs-url/heads/backport/123-to-branch"
End
End
Expand Down

0 comments on commit 545fbc0

Please sign in to comment.