Last active
January 5, 2025 17:58
-
-
Save mohtada-h/6f93e9199b3d361c304c25bd25ac68bd to your computer and use it in GitHub Desktop.
To calculate the change failure rate, you need to determine the percentage of changes that resulted in a failure, typically indicated by revert commits. Here's how you can calculate it using Git
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
# Count all commits in the last month | |
total_commits=$(git log --since='1 month ago' --oneline | wc -l) | |
# Count revert commits in the last month | |
revert_commits=$(git log --since='1 month ago' --grep='^Revert' -i --oneline | wc -l) | |
# Calculate the percentage of revert commits | |
percentage=$(echo "scale=2; ($revert_commits / $total_commits) * 100" | bc) | |
echo "Change Failure Rate: $percentage%" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment