Created
October 30, 2023 14:09
-
-
Save jameswilson/4ad00ed27cd57539cbb930864f1d95af to your computer and use it in GitHub Desktop.
Cohesion Git History explorer
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 | |
# For an unknown reason, the Acquia Site Studio repositories package their | |
# releases in a way that prevents comparing code changes between releases. | |
# Maybe this is intentional as a kind of security through obscurity. Maybe it | |
# is unintentional and just a part of a flawed release practice. Either way, | |
# the source code is GPL'ed on Github which lends itself to being able to track | |
# the changes between versions. That is exactly what this script does. | |
## | |
## Usage: | |
## ./cohesion_git_history.sh https://github.com/acquia/cohesion | |
## ./cohesion_git_history.sh https://github.com/acquia/cohesion-theme | |
## | |
## After executing these commands you'll end up with two folders in the current | |
## directory, one for cohesion and one for cohesion-theme that contain a proper | |
## git history constructed between releases that can be used to understand and | |
## inspect code changes incurred for each release. | |
## | |
## You can then leverage git history exploration tooling such as Sublime Merge | |
## or `git` commands to see and compare differences between versions: | |
## | |
## cd cohesion | |
## git diff 7.3.1..7.3.2 | |
## cd ../cohesion-theme | |
## git diff 7.3.1..7.3.2 | |
# | |
# Uncomment to show commands output. | |
# set -x | |
set -e | |
# Silence output from pushd. | |
pushd () { | |
command pushd "$@" > /dev/null | |
} | |
# Silence output from popd. | |
popd () { | |
command popd "$@" > /dev/null | |
} | |
# Show usage text if no argument is specified. | |
if [ -z "$1" ]; then | |
sed -n 's/^##//p' $(basename "$0") | |
exit 1; | |
fi | |
repo=$1 | |
project_name=$(echo $repo | cut -d"/" -f5) | |
rm -rf $project_name | |
mkdir -p $project_name | |
mkdir -p .cache/ | |
pushd $project_name | |
git init . --quiet | |
popd | |
refs=$(git ls-remote --refs --tags $repo '*.*.*' | sed -E 's/^[[:xdigit:]]+[[:space:]]+refs\/tags\/(.+)/\1/g') | |
for ref in $refs; do | |
if [[ ! -f ".cache/$project_name-$ref.tar.gz" ]]; then | |
echo "downloading $repo/archive/$ref.tar.gz" | |
curl --silent -L $repo/archive/$ref.tar.gz --output ".cache/$project_name-$ref.tar.gz" | |
else | |
echo "skipping $repo/archive/$ref.tar.gz - .cache/$project_name-$ref.tar.gz file exists" | |
fi | |
pushd $project_name | |
find . -not -path "./.git/*" -not -name ".git" -delete | |
popd | |
tar zxf .cache/$project_name-$ref.tar.gz --strip-components 1 -C $project_name | |
pushd $project_name | |
git add . | |
git commit -m "$ref" | |
popd | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment