Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically set delete_branch_on_merge for repositories #72

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kobzol
Copy link
Contributor

@Kobzol Kobzol commented Mar 1, 2024

This was requested for the miri-test-libstd repository, but I think that it's generally useful to set this everywhere, which this PR does.

@Kobzol Kobzol requested a review from jdno March 1, 2024 15:34
@ehuss
Copy link
Contributor

ehuss commented Mar 1, 2024

Will this delete things like auto branches? It seems somewhat dangerous to turn this on for everyone, since we don't know if there are repos with long-lived branches. I'm not really clear when this does and does not delete branches. Does it only delete if merged directly from a PR?

@Kobzol
Copy link
Contributor Author

Kobzol commented Mar 1, 2024

My understanding is that this only deletes the source branch after a PR is merged.

@ehuss
Copy link
Contributor

ehuss commented Mar 1, 2024

But what if the source branch is auto? Won't that delete it? How does it determine what a "source branch" is? Does it have to be the branch that is on a PR itself? Does deleting happen for merges not done through the GitHub UI? What about merges done through the GitHub API?

@Kobzol
Copy link
Contributor Author

Kobzol commented Mar 1, 2024

Do we ever create PRs out of the auto branch? 🤔

Anyway, good questions, I will try to find out.

@Kobzol
Copy link
Contributor Author

Kobzol commented Mar 1, 2024

GitHub claims that the head (source) branch of a PR will be removed after a merge.

I did a few experiments:

  • Merge a PR through GH API: the head branch is deleted.
  • Merge a branch directly into main: the merged branch is not deleted.
  • Merge a branch directly into main, when a PR is opened from that branch: the head branch is deleted.
  • Merge a branch directly into main, where a PR is opened from a branch auto that has the same commit SHA: the head branch is deleted, auto is not deleted.

So it seems that the logic looks like this: if a PR is opened from branch b, and that PR is marked as merged (by any means, be it UI, GH API, or the head commit of b appearing in main/master), then b will be deleted.

@rylev
Copy link
Member

rylev commented Mar 5, 2024

This makes me nervous since there are situations where this is a destructive action (e.g., when squashing on merge).

Does this work the same way for forks of a repo or is this only happening when the branch is in the same repo as the branch being merged into?

@Kobzol
Copy link
Contributor Author

Kobzol commented Mar 5, 2024

Does this work the same way for forks of a repo or is this only happening when the branch is in the same repo as the branch being merged into?

It doesn't delete the branches from forks.

@Kobzol Kobzol marked this pull request as draft March 16, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants