Delete remaining stale branches (Step 4) [SKIP REVIEW APP]
What does this MR do?
Step 4 of #5525 (closed)
At this point, all stale branches should have commits. But they may still not be deletable, if they are associated with an open MR. So, we need to identify only stale branches which are 1) associated with closed or merged MRs, OR 2) not associated with any MR.
Process (Step 4)
Part 1
- Run a script to identify all branches which are:
- Older than 90 days, AND
- Associated with a closed or merged MR OR not associated with any MR
- For each of these branches, obtain the:
- branch name
- last commit author name
- last commit author email
- last commit author date
- last commit committer name
- last commit committer email
- last commit committer date
- last commit message
- URL to branch
- URL to MR (if branch is associated with an MR) - NOTE: this could contain incorrect links if a deleted MR branch was subsequently created with the same name. There's at least one instance of this
- Create a spreadsheet with all of the branch information, and a column for ACTION containing "DELETE", sorted by descending commit date
- Send a mass email~~/slack~~ telling people to look at the spreadsheet, search for their name or email, and change the ACTION to "KEEP" for any branches they want to keep.
(Optional) email all authors and committers with a*@gitlab.com
email address.- Run the script again with the flag to do the actual deletion, and the exclude-list of any branches people wanted to keep.
trial run numbers:
Starting Cleanup::DeleteStaleBranches at 2020-05-01 06:10:27 UTC...
Finding stale branches for project gitlab-com/www-gitlab-com...
Found 5843 total branches.
Found 4420 stale branches.
...
...
Found 48283 total MRs.
Found 47664 closed or merged MRs.
Found 3573 stale branches with closed or merged MRs to be deleted.
Found 847 stale branches with no MR to be deleted.
Wrote stale branches to be deleted to CSV file /tmp/stale_branches_for_gitlab-com-www-gitlab-com_to_be_deleted_before_2020-01-30T00.00.00+00.00.csv.
...
Finished Cleanup::DeleteStaleBranches at 2020-05-01 06:30:40 UTC...
Part 2
- Wait 7 days
(provide a final reminder 3 days before) - Export a list of all branch names which have
ACTION=KEEP
- Run the script to delete the branches excluding the ones with
ACTION=KEEP
Script run commands
First run (identify and report only)
CLEANUP_DRY_RUN=true CLEANUP_STALE_CUTOFF_TIMESTAMP='2020-01-30T00:00:00+00:00' scripts/cleanup-delete-stale-branches.rb
Second run (do deletion)
Make a file branches_to_keep.csv
with following contents (if there are none, just have the header and no rows):
Branch
branch_to_keep_1
branch_to_keep_2
CLEANUP_DRY_RUN=false CLEANUP_STALE_CUTOFF_TIMESTAMP='2020-01-30T00:00:00+00:00' CLEANUP_DELETE_IDENTIFIED_STALE_BRANCHES=true BRANCHES_TO_KEEP_CSV=/Users/cwoolley/branches_to_keep.csv scripts/cleanup-delete-stale-branches.rb
Slack Notification Text
TODO: add link: [Slack message in
#handbook](https://gitlab.slack.com/archives/C81PT2ALD/p1586595681037900)
Hi team!
On 2020-05-11 we are doing the final step of the *cleanup of the https://gitlab.com/gitlab-com/www-gitlab-com repo to delete stale branches* which are:
1) older than 90 days (no activity since Jan 30), *AND*
2) not associated with any MR, or associated with a closed or merged MR.
*If there is any branch meeting this criteria which you do NOT want deleted, you can find it in this spreadsheet and change the `ACTION` to `KEEP`*: https://docs.google.com/spreadsheets/d/1YVupdJW1KOqd6GLhhY3HMsSvd98Rt84PqLjli2ToctA/edit#gid=0
If you need to restore one of these deleted branches for any reason in the future, you can find it in this archive repo (as of Apr 10, 2020): https://gitlab.com/gitlab-com/www-gitlab-com-archive-20200410-pre-cleanup
If you have any questions or concerns please reach out on this issue: https://gitlab.com/gitlab-com/www-gitlab-com/-/issues/5525#step-4-delete-remaining-stale-branches
Related issues
Relates #5525 (closed)
Edited by Ryan Wells