chore: add stale branch cleanup tool and test suite - #36561
Draft
torreypayne wants to merge 1 commit into
Draft
torreypayne wants to merge 1 commit into
torreypayne wants to merge 1 commit into
Conversation
Add script/delete-stale-branches.rb to identify and safely delete stale remote branches across googleapis/google-cloud-ruby. Key features and safety protections: - Unconditionally protects base branches (main, master, gh-pages) - Dynamically discovers and protects all active open PR heads - Protects branches with commits within the grace period (default: 30 days) - Dry-run mode by default to prevent accidental deletions - Supports batched deletion via git push origin --delete or GitHub API - Includes automated unit test suite in script/test_delete_stale_branches.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses Buganizer issue b/558882844: "Clean up stale branches in google-cloud-ruby".
The
google-cloud-rubyrepository currently has 2,402 remote branches. Below is the audit summary of the identified stale branches proposed for deletion, along with the safety criteria used to preserve all active and in-flight work.cc @aandreassa for visibility and confirmation before we execute the branch deletions.
Branch Evaluation & Count Summary
main,gh-pagesowl-bot-*andautosynth-*branches from 2020–2022main1. Protected / Preserved Branches (16 Total — Zero Risk to Active Work)
These branches will NOT be touched:
Base & Docsite (2)
main(Default branch)gh-pages(Documentation site)Active Open PR Heads (7)
enable-recursive-delete-folder-tests(PR feat(storagecontrol): re-enable recursive delete folder integration tests #36282: feat(storagecontrol): re-enable recursive delete folder integration tests)fix-storage-order-test(PR chore(storage): fix order dependency in get_object_contexts test #34844: chore(storage): fix order dependency in get_object_contexts test)pubsub-shutdown-docs(PR docs(pubsub): Add subscriber shutdown documentation and examples #36482: docs(pubsub): Add subscriber shutdown documentation and examples)pubsub-shutdown-options(PR feat(pubsub): Support subscriber shutdown options #36480: feat(pubsub): Support subscriber shutdown options)pubsub-shutdown-stream-inventory(PR chore(pubsub): Add inventory wait and stream shutdown nack #36479: chore(pubsub): Add inventory wait and stream shutdown nack)release-please--branches--main--components--google-cloud-compute(PR chore(main): release google-cloud-compute 1.20.1 #36540: chore(main): release google-cloud-compute 1.20.1)release-please--branches--main--components--google-cloud-compute-v1(PR chore(main): release google-cloud-compute-v1 3.11.0 #36541: chore(main): release google-cloud-compute-v1 3.10.1)Recent Activity within 30-Day Grace Period (6)
chore/zizmor-fixes(Last commit: 2026-08-21)ci/demo-doctests-execution(Last commit: 2026-08-24)owl-bot-copy-google-cloud-compute-v1(Last commit: 2026-09-02)owl-bot-copy-google-cloud-storage-control-v2(Last commit: 2026-08-20)release-please--branches--main--components--google-apps-chat-v1(Last commit: 2026-08-18)tombstone-apigee-registry-v1(Last commit: 2026-08-12)2. Identified Branches to Delete (2,386 Total)
A. Legacy Bot Branches (2,259 Branches)
Ephemeral branches generated by automated bots between 2020 and 2022 that were left behind:
owl-bot-*: 2,249 branchesautosynth-*: 10 branches (autosynth-asset-v1beta1,autosynth-datastore,autosynth-debugger,autosynth-error_reporting,autosynth-firestore,autosynth-irm,autosynth-logging,autosynth-pubsub,autosynth-trace,autosynth-webrisk)B. Merged PR Branches (13 Branches)
Branches whose work was already merged into
main:context-aware-commitsczahedi-patch-1docpubrelease-google-cloud-asset-v1-v0.6.0release-google-cloud-dialogflow-v2-v0.6.5release-google-cloud-memcache-v1beta2-v0.1.3release-please--branches--main--components--google-cloud-schedulerrelease-please--branches--main--components--grafeassamples-presubmit-mastershivng-storage-samplessrssystem-tests-against-emulatorzizmor-cleanupC. Abandoned No-PR Branches (26 Branches)
Stale ad-hoc branches with no associated pull requests (last updated 2016–2026):
automl-samplesbcb-to-fbbuildozer-gameschore/automate-gemfile-locks-phase-2chore/owlbot-lockfile-automationchore/renovate-daily-pilot-expansionchore/seed-lockfiles-1785437666compose-delete-sourcedemo-generate-asset-v1dev/virost/chore/github_credsdf-sampleser-fix-projectgcloud-jsondocgcloud-rdocgoogle-cloud-asset-synth.metadata-testgoogle-cloud-pubsub-v1-stablelifecycle-action-multipart-upload-extendpubsub-docspubsub-exactly-once-delivery-supportradruby-2.3-compatiblestatelesstest-btest-run-gapic-gitignore-lockfile-blockchainnodeenginetest-run-gapic-gitignore-lockfile-modelarmoryard-gcloudD. Closed / Unmerged PR Branches (88 Branches)
Click to expand full list of 88 closed PR branches
add-delete-folder-recursive-sampleadmin-latestads-manager-pathsbigquery-ci-testbq-5mb-json-testchat-library-genchore/add-lockfile-seederchore/phase2-expansion-round-2chore/renovate-schedule-groupingchore/renovate-wildcard-enrolled-lockfilescompose-delete-source-objects-rubycompute-accept-fixdataplex-v1-fixdemo-gen-fix-07-2026demo-generatorfeat-ruby-delete-folder-recursivefirestore-headers-issuefirestore-replace-legacy-headerfix_chrome_sessionfix_storage_labelsg-husam-patch-1google-cloud-dataplex-v1-fixmb.synthtool_importobsolete-resource-settingspin-conformance-testspolling-harness-bigtablepubsub_devrelease-gcloud-v0.25.0release-google-analytics-admin-v1alpha-v0.5.1release-google-cloud-access_approval-v0.4.0release-google-cloud-asset-v0.7.1release-google-cloud-asset-v1beta1-v0.3.0release-google-cloud-asset-v2.0.0release-google-cloud-automl-v0.4.1release-google-cloud-bigquery-v1.23.1release-google-cloud-bigtable-v0.8.1release-google-cloud-bigtable-v2.3.1release-google-cloud-bigtable-v3.0.0release-google-cloud-container-v2.0.0release-google-cloud-container_analysis-v2.0.0release-google-cloud-dataproc-v2.0.0release-google-cloud-debugger-v0.37.0release-google-cloud-dialogflow-v2.0.0release-google-cloud-env-v1.5.0release-google-cloud-error_reporting-v0.36.0release-google-cloud-language-v2.0.0release-google-cloud-memcache-v0.2.0release-google-cloud-monitoring-v0.37.3release-google-cloud-monitoring-v0.39.0release-google-cloud-os_login-v2.0.0release-google-cloud-pubsub-v1.3.2release-google-cloud-redis-v2.0.0release-google-cloud-secret_manager-v0.1.1release-google-cloud-security_center-v2.0.0release-google-cloud-service_directory-v0.4.0release-google-cloud-spanner-v2.1.1release-google-cloud-spanner-v3.0.0release-google-cloud-speech-v0.42.0release-google-cloud-speech-v2.0.0release-google-cloud-storage-v1.23.1release-google-cloud-storage-v1.24.1release-google-cloud-storage-v1.26.3release-google-cloud-storage-v1.28.1release-google-cloud-storage-v1.29.3release-google-cloud-storage-v2.0.0release-google-cloud-talent-v0.21.0release-google-cloud-talent-v2.0.0release-google-cloud-trace-v0.36.2release-google-cloud-translate-v4.0.0release-google-cloud-video_intelligence-v2.0.4release-google-cloud-video_intelligence-v4.0.0release-google-cloud-vision-v0.39.0release-google-cloud-vision-v2.0.0release-google-cloud-webrisk-v0.7.0release-please--branches--main--components--google-cloud-merchant-issue_resolution-v1betarelease-stackdriver-v0.17.0remove-dupe-samplesrenovate/core-handwritten-gems-lockfilesrenovate/major-core-handwritten-gems-lockfilessg-google-chat-v1test-citest-generator-updatestest-protobuf-36test-pubsub-alltest-run-gapic-gitignore-lockfiletest-run-gapic-minitest-reporters-language-v2test-run-speech-v1viacheslav-rostovtsev-patch-1Confirmation & Next Steps