Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Auto-delete branch on pull request merge #1121

Closed
stuartpb opened this issue Nov 13, 2017 · 40 comments
Closed

Auto-delete branch on pull request merge #1121

stuartpb opened this issue Nov 13, 2017 · 40 comments

Comments

@stuartpb
Copy link

It would be nice if we could have a checkbox / button or something for pull requests to make it so, when the pull request is merged, rather than having to revisit the PR and manually click the "Delete branch" button, the branch for the pull request would be deleted automatically. This is one of the features @jessfraz was just tweeting about running out of GitHub API calls to implement for herself: https://twitter.com/jessfraz/status/930154061869002752

Just sent this suggestion to GitHub Support.

@stuartpb
Copy link
Author

Wow, that was fast, looks like they've got a template response email for feature requests:

Hi there,

Thanks for reaching out! I'd be happy to pass this along to the team to consider as a feature request. I can't promise if or when it will be implemented, but your suggestion is definitely in the right hands!

Regards,
Laura
@lecoursen
GitHub Support

@pedro93
Copy link

pedro93 commented Nov 13, 2017

Amazing!

@davyengone
Copy link

Is this feature request still pending? That would be great to have it

@martinbonnin
Copy link

For what it's worth, I worked around this issue by writing a small script that auto-deletes merged branches every night. Not ideal but works.

@jimbol
Copy link

jimbol commented Feb 27, 2018

Would you be willing to share that with us @martinbonnin? I'd star that repo

@ericanderson
Copy link

This just annoyed me recently enough that I wrote a script. I intend to produce other useful things for working against git/gh inside it and PRs are welcome. Just ran it on internal instance to success: https://github.com/ericanderson/ghouls

@treps
Copy link

treps commented May 9, 2018

Have there been any updates on whether this is going to be a thing anytime soon?

@tonypiazza
Copy link

@lecoursen This would be very helpful. Can you give us an update on this?

@monperrus
Copy link

I guess that this can be implemented as a webhook. Has anybody ever done so?

@sparky005
Copy link

+1 for this feature.

@tansaku
Copy link

tansaku commented Jun 8, 2018

we'd love it too!

@renoirtech
Copy link

Hey guys, what about the following announcements and help articles? It seems that this feature already existed and someday and simply being vanished?

Confused.

@wareczek
Copy link

@renoirfaria read carefully ;) This issue is about automatically delete branch after merge. Not click on button action.

@AraHaan
Copy link

AraHaan commented Jun 14, 2018

Not to mention it would be nice to be able to physically delete issues and pull requests. I know it is a simple curl delete request away but I do not get the actual params I need to delete invalid issues/pull requests manually nor do I always have the ability as I have to use my iPhone most of the time on github unfortunately.

Althought it would be nice if there was a button to export issues and pull requests to files though (with the file names being the name of the pull request/issue number).

@renoirtech
Copy link

@wareczek right, but both alternatives (automatic and button deletion) seems to be are no longer available.

@wareczek
Copy link

No. Button is still there after merge. You can delete or restore branch.

@thomas-scrace

This comment has been minimized.

1 similar comment
@cgirard-mir
Copy link

+1

@AraHaan
Copy link

AraHaan commented Jul 20, 2018

I just got the idea. One could make a CI bot for their org that can detect pr merge and then check if the base branch is in the same repository, if so then delete it but then the CI would have to have means of editing the repository itself for that though. But at least it would be something. However like github pages it would be nice if only could setup a folder or whatever under branch master that then would run the ci itself automatically using Github as the host. For those who cannot run it on their devices and do not have money for a VPS or something to run it elsewhere. No programming language preference on this comment though so any language that can be used to make a Github CI is ok.

on the Api though it has pr’s like this right?

{
    "base": "my-base-branch",
    "target": "master",
    // other things.
}

@tiberiomoliveira
Copy link

Maybe this will do the job: https://developer.github.com/v3/git/refs/#delete-a-reference

@SvanBoxel
Copy link

Or this https://probot.github.io/apps/delete-merged-branch/

@Jumhyn

This comment has been minimized.

2 similar comments
@Oyelaking
Copy link

+1

@anton-kotik
Copy link

+1

@AraHaan
Copy link

AraHaan commented Sep 25, 2018

@SvanBoxel it works, but sadly that seems more of a hack than anything. It would be nice if that bot was automatically installed on any newly made repository from now on and does not require a per-user installation unless it is for enabling it on a older or old repository.

@jd
Copy link

jd commented Oct 22, 2018

@mspiegel
Copy link

mspiegel commented Dec 9, 2018

I've implemented this feature as a GitHub App. Looking for beta-testers. Check out https://github.com/apps/always-be-closing if you're interested. Any feedback would be appreciated at https://github.com/thoughtdealership/abc-users.

@teeberg
Copy link

teeberg commented Dec 11, 2018

You can automate this through GitHub actions now, e.g. using https://github.com/jessfraz/branch-cleanup-action

@sindresorhus
Copy link

PR welcome for this on Refined GitHub: refined-github/refined-github#1024

@amueller
Copy link

there is a button right after the merge button. That seems like enough, right?

@clarkbw
Copy link
Collaborator

clarkbw commented Jul 31, 2019

Auto-delete branches 🎉

Check it out! https://github.blog/changelog/2019-07-31-automatically-delete-head-branches-of-pull-requests/

@mgoddard27
Copy link

Will the 'auto-delete branches' feature be available on GitHub Enterprise as well, anytime soon?

@SvanBoxel
Copy link

SvanBoxel commented Aug 5, 2019

@mgoddard27 Assuming you mean GitHub Enterprise Server; yes. Normally GitHub ships features to Enterprise Server after they are battle-tested on GitHub.com. This could take a couple of months because of the quarterly release cadence for GitHub Enterprise Server.

@clarkbw clarkbw closed this as completed Aug 6, 2019
@testworksau
Copy link

testworksau commented Sep 3, 2019

@clarkbw any idea when an API to turn this setting on / off might arrive? It's not listed here:
https://developer.github.com/v3/repos/#edit

On another note - a repository maintainer has access to enable / disable the merge button to allow merge commits / squash merging / rebase merging in the GitHub UI, but does not have the ability to see the new Automatically delete head branches setting. Was this intentional?

@clarkbw
Copy link
Collaborator

clarkbw commented Sep 3, 2019

I don't have a timeline for the API yet, looking into it.

On another note - a repository maintainer has access to enable / disable the merge button to allow merge commits / squash merging / rebase merging in the GitHub UI, but does not have the ability to see the new Automatically delete head branches setting. Was this intentional?

re: the Maintainer role? I'll look into it.

@testworksau
Copy link

@clarkbw I've found that this setting is unexpectedly being turned off on us when using the Edit repos endpoint.

We use the https://developer.github.com/v3/repos/#edit API to configure merge strategies on our repositories. We typically send the following information (and only the following information) in the patch request:

{
  "allow_merge_commit": false,
  "allow_squash_merge": true,
  "allow_rebase_merge": true
}

After calling the API, the Automatically delete head branches setting turns off.

@clarkbw
Copy link
Collaborator

clarkbw commented Nov 6, 2019

That’s not good... can you send this through support so it gets to the right people? Thx!

@meabed
Copy link

meabed commented Nov 10, 2019

@clarkbw I've found that this setting is unexpectedly being turned off on us when using the Edit repos endpoint.

We use the https://developer.github.com/v3/repos/#edit API to configure merge strategies on our repositories. We typically send the following information (and only the following information) in the patch request:

{
  "allow_merge_commit": false,
  "allow_squash_merge": true,
  "allow_rebase_merge": true
}

After calling the API, the Automatically delete head branches setting turns off.

I have exactly the same issue, @clarkbw there is no option to toggle this through the API as well.
image

image

It would be great if this could be addressed :)

@terowz
Copy link

terowz commented Dec 16, 2019

do you have any idea when this will be available in the API as well?
or am I just missing the docs on it?

@testworksau
Copy link

The bug has finally been fixed, and this parameter is now available through the API, as delete_branch_on_merge.

https://developer.github.com/v3/repos/#edit

As a bonus for those using PyGitHub, I've also raised a PR to enable this parameter to be configured, which has been merged and is available in PyGitHub 1.46

https://github.com/PyGithub/PyGithub/releases/tag/v1.46

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests