-
Notifications
You must be signed in to change notification settings - Fork 20
Look up all branches on repo by prefix. Days threshold for deleting stale branches #17
base: master
Are you sure you want to change the base?
Conversation
Ideally, I think the suffix functionality can operate the same way as this rendition of the prefix functionality. |
Days input
I know I'm throwing a lot into this and I apologize. This is fun project for me and suits a use case I have in a mono-repo that I work in. Please let me know any feedback you have. I'm willing to change anything to get this out there in the marketplace. I'd love to be able to use this. |
@@ -21,6 +21,12 @@ inputs: | |||
suffix: | |||
description: Additional suffix to append to every branch name | |||
required: false | |||
dry_run: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is any need for this input. Why it was added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows users of the action to see what branches it will delete without deleting it. This is meant to operate like most dry-run command line flags.
@@ -1,7 +1,7 @@ | |||
# Delete multiple branches GitHub Action | |||
|
|||
An action that deletes multiple branches from repository. | |||
Optionally one can provide a `prefix` or `suffix` strings that would be appended or prepended to every branch name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why removing prefix here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous prefix was replaced with lookups against all the repo branches. The previous implementation users of the action had to explicitly know the branch name.
@@ -22,18 +32,57 @@ async function main() { | |||
branchesToDelete.push(pull.data.head.ref) | |||
} | |||
} | |||
|
|||
|
|||
if (prefix) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why you did it like this. Why if prefix
here and not later, how it was done before? Why prefix is handled different than suffix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make suffix be in parity with the prefix. Honestly, I have not experienced repos that name git branches with suffixes, so I left it be
|
||
|
||
if (prefix) { | ||
const branchFunc = await client.paginate("GET /repos/{owner}/{repo}/branches", { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does octokit not have any standard function for getting branches? Do we need to insert the endpoint here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not identify a function on octokit that operates like this. That was my first attempt but no luck
This action suits my need well. The one addition I wanted to make is to be able to delete branches by prefix for all branches on the repo. This pull request has the capabilities to look up the branches by prefix, stage them for deletion, and then subsequently delete them.