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

fix: handle curl error on delete branch #17

Merged
merged 1 commit into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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