Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit d0b9bd7
Merge: e0b037f 90c0d60
Author: colbynh <colby@recurforever.com>
Date:   Thu Feb 10 15:21:16 2022 -0500

    Merge branch 'add-exclude-open-prs' of github.com:recurforever/delete-old-branches-action into add-exclude-open-prs

commit e0b037f
Author: Siavash Safi <siavash.safi@gmail.com>
Date:   Fri Feb 4 11:14:49 2022 +0100

    parent 5ca4d86
    author Siavash Safi <siavash.safi@gmail.com> 1643969689 +0100
    committer colbynh <colby@recurforever.com> 1644524340 -0500
    gpgsig -----BEGIN PGP SIGNATURE-----

     iQIzBAABCAAdFiEEUZBe8tgy7Ask2IhkIqPSM0dKGa8FAmIFczUACgkQIqPSM0dK
     Ga9Ltw/+NagoL6pRjUq2J/H/1YnsIEUzm8Hs7m7t4cMhOi8EoeRqhJ7i8xf5Cx4m
     Bdj4+5E7/x6oPXp+tZlZI0jp5Q6ZKlAcYxK4t41QpIe9sEiTy/3OFvY+22GQHjzL
     Ec9Agvj8psmlmGrCJdLNzdMD83+s+NJiPAyt3djZkQHKtIn4ssRDZKrS2aXJtDtz
     SlkdeeG4buaQv+/eV0gEIihKnsV/lqL7BedF7TcxFsxG6TcLMKrVYQ1f7qYGQu+U
     rDuyoc86IZR+ikrSVGFsNYZrbyFnwyGR7fTw8T3UqvUzmMgfA6Ba9vmxsB8JTRw3
     oFXT3QK7dcPYS8wdYDtLd0ooIJO4sj8gJ9gPt/2UEU02ESFQ5Kr/fLKfJ2m2rlyl
     K4x+1eTSg4IADZ9woR3OJK1RHupxLJUEEwShn29dv8DWCp0LrG64FnPbmnb64rAT
     /AUTzbdwpVvs6UdlwDRIDWIa9vZqTn3pq9bN9QXAo3j585birKybNpPDnlvzFXls
     0hhenZ04gt2V+qoRAAqEPg7wKFki89evmMjjsBG2Nzsw4HvS49Hou4pkiifCTlQC
     B0uUTE19a+sGjvA72gCozQO8EgOy34e36JBgSsfxd4ClrGX329cfJxfbezOwDAcp
     po0UfnQqGAJsjKcIS1K6P3Hw6DyroX0ZbT9oBnMjleBcoMh0xkE=
     =3gCj
     -----END PGP SIGNATURE-----

    parent 5ca4d86
    author Siavash Safi <siavash.safi@gmail.com> 1643969689 +0100
    committer colbynh <colby@recurforever.com> 1644524337 -0500
    gpgsig -----BEGIN PGP SIGNATURE-----

     iQIzBAABCAAdFiEEUZBe8tgy7Ask2IhkIqPSM0dKGa8FAmIFczEACgkQIqPSM0dK
     Ga/QPQ//UIL+chY1ZJ8Pj4eSionib0n8Cx6lR81jH9No5ldilFxJQyWYFamPSnQc
     KU3YRyxPUIoq5vNp7+HgaNhLTRMfkjtEBrpu5M+0FVjQnCFaYjR0YW4zX3u/F4ct
     d9mzrzWjIWPZuFgQu/VAcB1NwEgB0l8nfVKJkSNAbuei8rddu4LFGp/fupWpW8tQ
     JIdigISNf2XrpOXZwfR09FVPAhU6+73VWlu0nqfuF69MA62BvxLaJKMaGAKzTKhv
     V4OzC0gq30bQi176nsUlgiJnhK9JDO9G/54/pbytWsOE/ZoZlW9rgZo8DzFnwJ7Y
     ZWLLDtor8KSx1Q844VtmrBuIESnWPCQwYxeNiumJpYDTe/ErSqG0bNxJep+GNF7y
     XxT77diZNWqI9cCgwj0EauAfbj7ssfYZyy/o35lAWQXlTy88E2SW2LEqjEv+PGrA
     xUcYbXunr/FeXaZsWzdVh0//hn3qKr6x//OVKMd+8sYv4yfweVVZGCKNlqAfNfi9
     bquDtVhY8UOMb2jYwvW9zXaGBg7JNA2z9zyicRRdq7ssehrSjvFTZlP2U+bRC5Hz
     46bGTMqeJNuikXD3N5vhSFBG2wPlMoDm9KFXkrP9DhRg0KBBQMPBYYvspsEtKoxY
     3YMEibCaC/JGBjpPu4fgwfNQxJBxOhewY5aIL5VMan9kDsQGRlk=
     =8dYu
     -----END PGP SIGNATURE-----

    parent 5ca4d86
    author Siavash Safi <siavash.safi@gmail.com> 1643969689 +0100
    committer colbynh <colby@recurforever.com> 1644524332 -0500
    gpgsig -----BEGIN PGP SIGNATURE-----

     iQIzBAABCAAdFiEEUZBe8tgy7Ask2IhkIqPSM0dKGa8FAmIFcy0ACgkQIqPSM0dK
     Ga+PChAAq3IhiKxPmxgY6i7ilvv25W0hndHI7pvCBXo8ckmxboDs0o85QEyRL0vm
     bNxHxVHeIC2qN6dOG5n4g6N4uxRCjRDpN1nu/FgYuHZ46EkNaPBe5B6GTW7i8nFV
     KVnj18mMNzfRrB3mVKxr4Af8S5GLVZ5qlxPATkZ9DJRIsrJxcT/IkCOXqXYNl1kY
     2dlYR3NLKmCCKJSfLP88SiYxY3jIGOE1nkTuP3w+hZrNBkqPnRCbbFOoQmYnovDe
     JJRAzXtIwZL9qgIN7E0v9O8TLM5UI9FFk0gvNvTS2AWk4I4ZjSR/I2QQQhpBP9Ce
     EgBpE8oW/0Qll0jSKVDCseYycTVL9g+56N7jR52mT14Ju6uRqkrrQmtuPjPATp7O
     i6HG7ws/QTNPr74ophVxfIsZy4N4XPPU9KTyag9cxOlJCZEpioEctJ0W3fVQfp3N
     oLJWyjiDGmrRCaanW8UatTBTAv//imLOmEOGkDotg39MAdO2mch+ATGVdWaPNEqc
     rXh6rkGBui0xSOtT1h3IjpVBy/vKBCyEZZdO+q9lBn1iVPvTMr53pKDxtCoBznzl
     35k1WWKY1W4mL7urhxM0pOqZq5ubY0kHRc5g9SP2CKAq3rtg8P+DFBvS8ab6Y/eC
     dPvftwTBb6YHR6uWF2CbklHhxhDBDTpXzI4lo0h6g9hXQVB17dQ=
     =YC59
     -----END PGP SIGNATURE-----

    Update CODEOWNERS

    Use github api to get source branches

    Debug pr output

    debug

    .

    Fix api url

    Trim quotes on branch names

    Update for consistency

    Co-authored-by: Polykarpos Kossyfas <44210251+pkossyfas@users.noreply.github.com>

    Fix variable

    Co-authored-by: Polykarpos Kossyfas <44210251+pkossyfas@users.noreply.github.com>

    Update readme with exlude pr branches

    Update readme

    Update for consistency

    Co-authored-by: Polykarpos Kossyfas <44210251+pkossyfas@users.noreply.github.com>

    Fix variable

    Co-authored-by: Polykarpos Kossyfas <44210251+pkossyfas@users.noreply.github.com>

commit 90c0d60
Merge: e3a2c01 0704ae2
Author: colbynh <colby@recurforever.com>
Date:   Thu Feb 10 15:12:02 2022 -0500

    Merge branch 'add-exclude-open-prs' of github.com:recurforever/delete-old-branches-action into add-exclude-open-prs

commit e3a2c01
Author: colbynh <colby@recurforever.com>
Date:   Thu Feb 10 15:11:44 2022 -0500

    Add exclude pr

commit 0704ae2
Merge: 173fad9 c94dd47
Author: colbynh <colby@recurforever.com>
Date:   Thu Feb 10 15:06:42 2022 -0500

    Merge branch 'add-exclude-open-prs' of github.com:recurforever/delete-old-branches-action into add-exclude-open-prs

commit 173fad9
Author: Colby Chenard <guitaristcolby@gmail.com>
Date:   Thu Feb 10 14:48:32 2022 -0500

    Fix variable

    Co-authored-by: Polykarpos Kossyfas <44210251+pkossyfas@users.noreply.github.com>

commit 2153840
Author: Colby Chenard <guitaristcolby@gmail.com>
Date:   Thu Feb 10 14:48:21 2022 -0500

    Update for consistency

    Co-authored-by: Polykarpos Kossyfas <44210251+pkossyfas@users.noreply.github.com>

commit c876f88
Author: colbynh <colby@recurforever.com>
Date:   Wed Jan 26 15:37:16 2022 -0500

    Update readme

commit c86b44a
Author: colbynh <colby@recurforever.com>
Date:   Wed Jan 26 15:33:05 2022 -0500

    Trim quotes on branch names

commit 0251ed9
Author: colbynh <colby@recurforever.com>
Date:   Wed Jan 26 13:18:59 2022 -0500

    Fix api url

commit dc20feb
Author: colbynh <colby@recurforever.com>
Date:   Wed Jan 26 13:17:02 2022 -0500

    .

commit ef515cd
Author: colbynh <colby@recurforever.com>
Date:   Wed Jan 26 13:13:19 2022 -0500

    debug

commit c6e5632
Author: colbynh <colby@recurforever.com>
Date:   Wed Jan 26 12:58:27 2022 -0500

    Debug pr output

commit 5c69752
Author: colbynh <colby@recurforever.com>
Date:   Wed Jan 26 12:44:42 2022 -0500

    Update readme with exlude pr branches

commit bfed459
Author: colbynh <colby@recurforever.com>
Date:   Wed Jan 26 12:44:24 2022 -0500

    Use github api to get source branches

commit f58a23d
Author: colbynh <colby@recurforever.com>
Date:   Wed Jan 26 12:04:43 2022 -0500

    Add exclude pr branch option

commit c94dd47
Author: Colby Chenard <guitaristcolby@gmail.com>
Date:   Thu Feb 10 14:48:32 2022 -0500

    Fix variable

    Co-authored-by: Polykarpos Kossyfas <44210251+pkossyfas@users.noreply.github.com>

commit 2bb3f87
Author: Colby Chenard <guitaristcolby@gmail.com>
Date:   Thu Feb 10 14:48:21 2022 -0500

    Update for consistency

    Co-authored-by: Polykarpos Kossyfas <44210251+pkossyfas@users.noreply.github.com>

commit 90dde14
Merge: e2fc70d ee268fd
Author: Polykarpos Kossyfas <44210251+pkossyfas@users.noreply.github.com>
Date:   Tue Feb 8 12:56:13 2022 +0200

    Merge pull request beatlabs#15 from pkossyfas/protect-default-branch

    delete-old-branches: Protect main and master branch

commit ee268fd
Author: Polykarpos Kossyfas <p.kossyfas@thebeat.co>
Date:   Wed Feb 2 20:06:36 2022 +0200

    delete-old-branches: Protect main and master branch

    Add main and master branches as default branches so as to be
    excluded from deletion. Also, add an option for user to override the
    default behavior.

commit e2fc70d
Merge: 5cec5e4 9104e84
Author: Alexios Polyzos <dragotic.saen@gmail.com>
Date:   Tue Feb 8 12:32:11 2022 +0200

    Merge pull request beatlabs#16 from hwoarang/markos/add-ability-to-exclude-tags

    delete-action-branches: Add ability to exclude certain tags pattern

commit 9104e84
Author: Markos Chandras <markos@chandras.me>
Date:   Mon Feb 7 17:22:30 2022 +0200

    delete-action-branches: Add ability to exclude certain tags pattern

    There might be cases where certain tags need to be excluded from
    deletion. As such, lets add the ability to do that similarly to how
    excluded branches are handled.

commit 5cec5e4
Author: Siavash Safi <siavash.safi@gmail.com>
Date:   Fri Feb 4 11:14:49 2022 +0100

    Update CODEOWNERS

commit 7e81c4d
Author: colbynh <colby@recurforever.com>
Date:   Wed Jan 26 15:37:16 2022 -0500

    Update readme

commit 6925fe2
Author: colbynh <colby@recurforever.com>
Date:   Wed Jan 26 15:33:05 2022 -0500

    Trim quotes on branch names

commit 5e942cd
Author: colbynh <colby@recurforever.com>
Date:   Wed Jan 26 13:18:59 2022 -0500

    Fix api url

commit 5498e08
Author: colbynh <colby@recurforever.com>
Date:   Wed Jan 26 13:17:02 2022 -0500

    .

commit d19ff4a
Author: colbynh <colby@recurforever.com>
Date:   Wed Jan 26 13:13:19 2022 -0500

    debug

commit 7c4e5a6
Author: colbynh <colby@recurforever.com>
Date:   Wed Jan 26 12:58:27 2022 -0500

    Debug pr output

commit 3c95920
Author: colbynh <colby@recurforever.com>
Date:   Wed Jan 26 12:44:42 2022 -0500

    Update readme with exlude pr branches

commit 5ca4d86
Author: colbynh <colby@recurforever.com>
Date:   Wed Jan 26 12:44:24 2022 -0500

    Use github api to get source branches

commit e3f0650
Author: colbynh <colby@recurforever.com>
Date:   Wed Jan 26 12:04:43 2022 -0500

    Add exclude pr branch option

commit 2f90191
Merge: 6a6405f 6178899
Author: Markos Chandras <hwoarang@users.noreply.github.com>
Date:   Mon Mar 15 07:34:01 2021 +0000

    Merge pull request beatlabs#12 from mdelapenya/patch-1

    docs: update example usage to latest version

commit 6178899
Author: Manuel de la Peña <mdelapenya@gmail.com>
Date:   Mon Mar 15 07:34:40 2021 +0100

    docs: update example usage to latest version

commit 6a6405f
Author: Markos Chandras <markos@chandras.me>
Date:   Tue Dec 1 11:50:54 2020 +0000

    [github] Update release action

    Update action to use the beatlabs/release-changelog-action
    to generate the changelog for the release.

commit b0c1038
Merge: ea9b1ff 32c8b35
Author: Markos Chandras <hwoarang@users.noreply.github.com>
Date:   Tue Dec 1 11:46:34 2020 +0000

    Merge pull request beatlabs#9 from beatlabs/fix-excluded-branches-regex

    delete-old-branches: Fix default regex for excluded branches

commit 32c8b35
Author: Markos Chandras <markos@chandras.me>
Date:   Tue Dec 1 10:18:45 2020 +0000

    delete-old-branches: Fix default regex for excluded branches

    The default regex is meant to not ignore any extra branch. As such,
    we need fix the regex in order to not match anything.

commit ea9b1ff
Author: Markos Chandras <markos@chandras.me>
Date:   Tue Nov 24 15:57:47 2020 +0000

    [github] Bump to latest release action

commit e78d126
Merge: ab4c664 eab41eb
Author: Markos Chandras <hwoarang@users.noreply.github.com>
Date:   Tue Nov 24 15:43:20 2020 +0000

    Merge pull request beatlabs#8 from beatlabs/minimum_tags

    [delete-old-branches] Add option to keep minimum number of tags

commit eab41eb
Author: Markos Chandras <markos@chandras.me>
Date:   Tue Nov 10 22:44:55 2020 +0000

    [delete-old-branches] Add option to keep minimum number of tags

    Tags often correspond to actual releases so its might be desirable to
    keep a minimum number of them around especially for repositories which
    do not release so often otheriwse we may end up with a situation where
    all the tags will be eventually deleted if nothing was committed to the
    repo for X amount of time.

commit ab4c664
Merge: 68dfdde fb75cf4
Author: Markos Chandras <hwoarang@users.noreply.github.com>
Date:   Tue Nov 10 22:33:32 2020 +0000

    Merge pull request beatlabs#6 from beatlabs/fix-logic-around-branch-prefix

    Fix logic around prefixed branches

commit fb75cf4
Author: Markos Chandras <markos@chandras.me>
Date:   Fri Jul 24 13:12:20 2020 +0300

    Fix logic around prefixed branches

    The action deletes all branches by default except the protected ones.
    As such, there is no reason to have a specific filter to include more
    branches into this logic. What we want is a mechanism to *exclude*
    branches from this logic in order to artifically protect branches which
    are not marked as protected in the github API.

commit 68dfdde
Author: Markos Chandras <markos@chandras.me>
Date:   Mon Sep 14 16:38:33 2020 +0300

    [github] Update SHA for release action

    Update SHA for the release action which fixes the following problem:

    marvinpinto/action-automatic-releases/7787f7d200d647f2e8739c9df73a1cf7a23b9f30/action.yml (Line: 27, Col: 5): Unexpected value 'decription'

commit ae01784
Merge: 801baf5 37542d5
Author: Markos Chandras <hwoarang@users.noreply.github.com>
Date:   Mon Sep 14 14:36:20 2020 +0100

    Merge pull request beatlabs#7 from beatlabs/hide-pseudorefs-and-peeled-tags

    Pass --refs to git-ls-remote

commit 37542d5
Author: Markos Chandras <markos@chandras.me>
Date:   Mon Sep 14 13:35:35 2020 +0300

    Pass --refs to git-ls-remote

    We need to pass --refs to the git ls-remote command in order to hide
    peeled tags and pseudorefs like HEAD from output. Otherwise the action
    fails when trying to delete annotated tags as they appear in the form of
    vX.X.X^{}

commit 801baf5
Merge: df0035d be5626b
Author: Siavash Safi <siavash.safi@gmail.com>
Date:   Wed Jul 22 09:53:02 2020 +0200

    Merge pull request beatlabs#5 from teivah/master

    Adding a mechanism to filter per prefix

commit be5626b
Author: teivah <t.harsanyi@thebeat.co>
Date:   Wed Jul 22 09:44:24 2020 +0200

    Adding a mechanism to filter per prefix

commit df0035d
Merge: d7a53d7 56f53d0
Author: Markos Chandras <hwoarang@users.noreply.github.com>
Date:   Tue Jun 16 08:23:51 2020 +0100

    Merge pull request beatlabs#4 from beatlabs/fix-tag-deletion

    Fix bug when deleting branches with delete_tags=true

commit 56f53d0
Author: Markos Chandras <markos@chandras.me>
Date:   Mon Jun 15 14:28:57 2020 +0100

    Fix bug when deleting branches with delete_tags=true

    Fix a bug where a branch deletion will fail with 422 whene delete_tags
    is true. This is because the logic was broken and the wrong endpoint
    was used to delete the object.

commit d7a53d7
Merge: dbfa3f3 0698a3a
Author: Markos Chandras <hwoarang@users.noreply.github.com>
Date:   Mon Jun 15 08:38:42 2020 +0100

    Merge pull request beatlabs#3 from beatlabs/enhance-debug-log

    delete-old-brances: Add option to dump the curl output on failures

commit 0698a3a
Author: Markos Chandras <markos@chandras.me>
Date:   Fri Jun 12 10:36:47 2020 +0100

    delete-old-brances: Add option to dump the curl output on failures

    Redirect output to a debug file which can then dump when the delete
    request fails

commit dbfa3f3
Merge: 375cfc4 c0cb74b
Author: Markos Chandras <hwoarang@users.noreply.github.com>
Date:   Thu Jun 4 09:43:10 2020 +0100

    Merge pull request beatlabs#2 from beatlabs/fix-for-tags

    delete-old-branches: Also fetch tags during initial git fetch

commit c0cb74b
Author: Markos Chandras <markos@chandras.me>
Date:   Thu Jun 4 09:07:12 2020 +0100

    Also fetch tags during initial git fetch

    We need to have the tags present on the repo to be able to examine
    their history

    This also updates the release action to the latest commit to fix an
    issue with commit filtering.

commit 375cfc4
Merge: 75a26c7 3fe627f
Author: Markos Chandras <hwoarang@users.noreply.github.com>
Date:   Thu Jun 4 09:01:31 2020 +0100

    Merge pull request beatlabs#1 from beatlabs/add-tag-support

    Add support for deleting old tags as well

commit 3fe627f
Author: Markos Chandras <markos@chandras.me>
Date:   Wed Jun 3 10:58:39 2020 +0100

    Add support for deleting old tags as well

    It might also be beneficial to get rid of old tags so add a new
    `delete_tags` option for that which defaults to `false` to preserve
    the existing behavior.

commit 75a26c7
Author: Markos Chandras <markos@chandras.me>
Date:   Fri May 22 14:36:18 2020 +0100

    README: Delete Release badge

    The badge only makes sense for tags so no point in having it in the
    README file.
  • Loading branch information
colbynh committed Feb 10, 2022
1 parent 90dde14 commit f5d0e59
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 13 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The default behaviour is to exclude the default branch (main or master) and the

Additional branches can be excluded using the `extra_protected_branch_regex` variable (see example below).
Similarly, certain tags can be excluded using the `extra_protected_tag_regex` variable.
The default behaviour is to exclude Github protected branches as well as branches with open pull requests. Additional branches can be excluded using the `extra_protected_branch_regex` variable. Branches with open pull requests can be ignored as well (see example below).

## Disclaimer

Expand Down Expand Up @@ -41,6 +42,7 @@ jobs:
minimum_tags: 5
extra_protected_branch_regex: ^(foo|bar)$
extra_protected_tag_regex: '^v.*'
exclude_open_pr_branches: true
```
Once you are happy switch, `dry_run` to `false` so the action actually does the job
Expand Down
30 changes: 17 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
# action.yml
name: 'Delete old branches'
description: 'Delete branches which are older than certain period of time'
author: 'Markos Chandras'
name: "Delete old branches"
description: "Delete branches which are older than certain period of time"
author: "Markos Chandras"
inputs:
repo_token:
description: 'The GITHUB_TOKEN secret'
description: "The GITHUB_TOKEN secret"
required: true
date:
description: 'A git-log compatible date format'
description: "A git-log compatible date format"
required: true
dry_run:
description: 'Run in dry-run mode so no branches are deleted'
description: "Run in dry-run mode so no branches are deleted"
required: false
default: true
delete_tags:
description: 'Also look for tags to delete'
description: "Also look for tags to delete"
required: false
default: false
minimum_tags:
descritpion: 'Minimum number of tags to keep'
descritpion: "Minimum number of tags to keep"
required: false
default: false
default_branches:
description: 'Default branch(es) to exclude'
description: "Default branch(es) to exclude"
required: false
default: main,master
extra_protected_branch_regex:
description: 'grep extended (ERE) compatible regex for additional branches to exclude'
description: "grep extended (ERE) compatible regex for additional branches to exclude"
required: false
extra_protected_tag_regex:
description: 'grep extended (ERE) compatible regex for additional tags to exclude'
description: "grep extended (ERE) compatible regex for additional tags to exclude"
required: false
exclude_open_pr_branches:
description: "Exclude branches that have an open pull request"
required: false
default: true

runs:
using: 'docker'
image: 'Dockerfile'
using: "docker"
image: "Dockerfile"
21 changes: 21 additions & 0 deletions delete-old-branches
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ MINIMUM_TAGS=${INPUT_MINIMUM_TAGS:-0}
DEFAULT_BRANCHES=${INPUT_DEFAULT_BRANCHES:-main,master}
EXCLUDE_BRANCH_REGEX=${INPUT_EXTRA_PROTECTED_BRANCH_REGEX:-^$}
EXCLUDE_TAG_REGEX=${INPUT_EXTRA_PROTECTED_TAG_REGEX:-^$}
EXCLUDE_OPEN_PR_BRANCHES=${INPUT_EXCLUDE_OPEN_PR_BRANCHES:-true}

default_branch_protected() {
local br=${1}
Expand Down Expand Up @@ -58,6 +59,24 @@ extra_branch_or_tag_protected() {
return $?
}

is_pr_open_on_branch() {
if [[ "${EXCLUDE_OPEN_PR_BRANCHES}" == false ]]; then
return 1
fi

local br=${1}
open_prs_branches=$(curl -X GET -s -H "Authorization: token ${GITHUB_TOKEN}" \
"${BASE_URI}/repos/${REPO}/pulls" | jq '.[].head.ref' | tr -d '"')

for pr_br in ${open_prs_branches}; do
if [[ "${pr_br}" == "${br}" ]]; then
return 0
fi
done

return 1
}

delete_branch_or_tag() {
local br=${1} ref="${2}"

Expand Down Expand Up @@ -86,6 +105,8 @@ main() {
default_branch_protected "${br}" && echo "branch: ${br} is a default branch. Won't delete it" && continue
branch_protected "${br}" && echo "branch: ${br} is likely protected. Won't delete it" && continue
extra_branch_or_tag_protected "${br}" "branch" && echo "branch: ${br} is explicitly protected and won't be deleted" && continue
extra_branch_protected "${br}" && echo "branch: ${br} is explicitly protected and won't be deleted" && continue
is_pr_open_on_branch "${br}" && echo "branch: ${br} has an open pull request and won't be deleted" && continue
delete_branch_or_tag "${br}" "heads"
fi
done
Expand Down

0 comments on commit f5d0e59

Please sign in to comment.