Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

Automatically set delete_branch_on_merge for repositories#72

Draft
Kobzol wants to merge 1 commit into
rust-lang:masterfrom
Kobzol:delete-branch-on-merge
Draft

Automatically set delete_branch_on_merge for repositories#72
Kobzol wants to merge 1 commit into
rust-lang:masterfrom
Kobzol:delete-branch-on-merge

Conversation

@Kobzol

@Kobzol Kobzol commented Mar 1, 2024

Copy link
Copy Markdown
Member

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

ehuss commented Mar 1, 2024

Copy link
Copy Markdown
Contributor

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

Kobzol commented Mar 1, 2024

Copy link
Copy Markdown
Member Author

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

@ehuss

ehuss commented Mar 1, 2024

Copy link
Copy Markdown
Contributor

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

Kobzol commented Mar 1, 2024

Copy link
Copy Markdown
Member Author

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

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

@Kobzol

Kobzol commented Mar 1, 2024

Copy link
Copy Markdown
Member Author

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

rylev commented Mar 5, 2024

Copy link
Copy Markdown
Member

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

Kobzol commented Mar 5, 2024

Copy link
Copy Markdown
Member Author

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants