Skip to content

allow for stale branch cleanup (& dry run)#772

Open
mcncl wants to merge 3 commits intomainfrom
TE-5434/branch_cleanup
Open

allow for stale branch cleanup (& dry run)#772
mcncl wants to merge 3 commits intomainfrom
TE-5434/branch_cleanup

Conversation

@mcncl
Copy link
Copy Markdown
Contributor

@mcncl mcncl commented Apr 9, 2026

Description

Enables the user to run a cleanup subcommand to delete branches which are left stale after a build has run to completion. Allows for --dry-run to be used.

Changes

  • adds a cleanup command which will delete any branches with the pattern bk/preflight/*
    • works via using the [new] build branch resolver to get a list of branches with completed builds
  • minor housekeeping with Kong structs (PreflightCmd -> RunCmd)

Testing

  • Tests have run locally (with go test ./...)
  • Code is formatted (with go fmt ./...)

@mcncl mcncl requested review from a team as code owners April 9, 2026 05:33
allow for stale branch cleanup (& dry run)
@mcncl mcncl force-pushed the TE-5434/branch_cleanup branch from 0880562 to de14026 Compare April 13, 2026 05:39
@mcncl mcncl requested a review from matthewborden April 13, 2026 06:18
// CleanupCmd deletes remote bk/preflight/* branches whose builds have completed.
type CleanupCmd struct {
Pipeline string `help:"The pipeline to check builds against. This can be a {pipeline slug} or in the format {org slug}/{pipeline slug}." short:"p"`
PreflightUUID string `help:"Target a single preflight branch by its UUID (bk/preflight/<uuid>)." name:"preflight-uuid"`
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allows the use of --preflight-uuid to target a specific run

Comment on lines +32 to +36
if c.PreflightUUID != "" {
if _, err := uuid.Parse(c.PreflightUUID); err != nil {
return bkErrors.NewValidationError(err, fmt.Sprintf("invalid preflight UUID %q", c.PreflightUUID))
}
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where we try to resolve the preflight UUID

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.

2 participants