Created
February 22, 2021 16:48
-
-
Save stronk7/98cfef88785cf969ac95cc60f119cb37 to your computer and use it in GitHub Desktop.
Compare 2 development branches (before they diverge with new features)
This file contains 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
#!/bin/bash | |
# Note this is useful when comparing 2 development branches that other than versions and upgrade lines shoudl be 99% | |
# the same. Of course before they really begin to diverge, then the utility is not useful any more. | |
# Setup the desired branches | |
branch1=MOODLE_311_STABLE | |
branch2=master | |
# Prepare branches | |
for branch in ${branch1} ${branch2}; do | |
# Base branch and reset. | |
git co ${branch} | |
git co -B ${branch}_normalised | |
git reset --hard origin/${branch} | |
# Normalise all versions. | |
ag '[0-9\.]{8,}' -l | xargs -I{} sed -i -r 's/[0-9\.]{8,}/x/g' {} # All versions to x | |
# Normalise upgrade lines. | |
ag '// Automatically generated Moodle' -l | xargs -I{} sed -i -r 's/^.*Automatically generated Moodle .*$//g' {} # Upgrade lines out | |
ag '// Put any upgrade step following this.' -l | xargs -I{} sed -i -r 's/^.*Put any upgrade step following this.*$//g' {} | |
# Save all changes. | |
git add . | |
git commit -m "normalised ${branch}" --no-verify | |
done; | |
# Perform a comparison | |
comparison=" diff ${branch1}_normalised ${branch2}_normalised --ignore-all-space --ignore-blank-lines" | |
echo "git ${comparison}" | |
git ${comparison} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment