Skip to content

Want to always have local branch deleted on auto #8801

@xenoterracide

Description

@xenoterracide

Describe the feature or problem you’d like to solve

I want a single uninteractive command to delete the local branch when the PR is merged

This, almost works, but has a couple of race conditions

gh pr create --fill-first; sleep 3 && gh run watch --exit-status && gh pr merge --squash --delete-branch --auto
  1. The runs might not be available, so we're sleeping first
  2. If we watch the wrong run the local branch won't be deleted if there are still runs

Proposed solution

Let's start with I think there are multiple solutions to this, so I'm doing my best to describe the problem more than just the solution

  1. I think that there needs to be a gh pr watch --exit-status so that we can watch all the runs related to this pr at once.
  2. When running gh pr merge --squash --delete-branch --auto if the merge hasn't been done yet, record some kind of local file queue check, so that the next time gh is run, it'll check and delete the branch if that pr is closed.
  3. We also need a gh pr watch <job name> and maybe a gh run watch --latest --job-name <job name>
❯ gh --version
gh version 2.44.1 (2024-02-29)
https://github.com/cli/cli/releases/tag/v2.44.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions