Cleans up after Copado.
There are two criterial for removal, one of which can be removed all together
- The branch has not been committed to in 4 months
- A log of a branche's commit history can be found with
git log $branch --since "4 months ago" - The count of a branche's commit history can be found with
git log $branch --since "4 months ago" | wc -l
- The branches that have already been merged into the master branch (and may be stale)
- These can be found with
git branch -r --merged - This criteria can be disabled with the
softargument, and enabled with thehardargument
- Clone the repository that you would like to clean
// ssh
git clone git@github.com:your_repo.git
// https
https://github.com/your_repo.git
- Navigate to your repo
cd your_repo
- Fetch all the remote branches
git fetch -a
- Ensure you are on the
masterbranch
git checkout master
- Run your command either as a dry run for testing or as a wet run
A soft run means that we do not remove branches that have been merged into master (or branches that could be stale)
From within your repository, run the clean.sh script using the testme and soft arguments for a soft dry run and the testme and hard arguments for a hard dry run.
// soft dry run
path/to/the/script testme soft
// hard dry run
path/to/the/script testme hard
From within your repository, run the clean.sh script using the dome and soft arguments for a soft dry run and the dome and hard arguments for a hard dry run.
// soft wet run
path/to/the/script dome soft
// hard wet run
path/to/the/script dome hard
> ../clean testme soft
π© promotion/P0xxxx-DeployP0xxxxBranchName
git branch -d promotion/P0xxxx-DeployP0xxxxBranchName
git push origin --delete promotion/P0xxxx-DeployP0xxxxBranchName
π promotion/P0yyyy-DeployP0yyyyBranchName
git branch -d promotion/P0yyyy-DeployP0yyyyBranchName
git push origin --delete promotion/P0yyyy-DeployP0yyyyBranchName
Promotion branches deleted: 2
π« feature/US-000xxxx
git branch -d feature/US-000xxxx
git push origin --delete feature/US-000xxxx
π£ feature/US-000yyyy
git branch -d feature/US-000yyyy
git push origin --delete feature/US-000yyyy
Feature branches deleted: 2
Total branches deleted: 4
> ../clean testme hard
π
promotion/P0xxxx-DeployP0xxxxBranchName
git branch -d promotion/P0xxxx-DeployP0xxxxBranchName
git push origin --delete promotion/P0xxxx-DeployP0xxxxBranchName
π promotion/P0yyyy-DeployP0yyyyBranchName
git branch -d promotion/P0yyyy-DeployP0yyyyBranchName
git push origin --delete promotion/P0yyyy-DeployP0yyyyBranchName
Promotion branches deleted: 2
β° feature/US-000xxxx
git branch -d feature/US-000xxxx
git push origin --delete feature/US-000xxxx
π₯ feature/US-000yyyy
git branch -d feature/US-000yyyy
git push origin --delete feature/US-000yyyy
Feature branches deleted: 2
Total branches deleted: 4
Stale branches deleted: 38