Created
August 6, 2023 23:50
-
-
Save jcdcdev/c8c6e0701781198cd89e519dfaeaa72e to your computer and use it in GitHub Desktop.
Umbraco Version Git
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 | |
# Clone the repo to a temporary directory | |
git clone https://github.com/umbraco/Umbraco-CMS.git /tmp/umbraco | |
# Change to the repo directory | |
cd /tmp/umbraco | |
# Ask the user for the start tag | |
echo "Enter the start tag (semver part only):" | |
read start | |
# Prepend release- to the start tag | |
start="release-$start" | |
# Ask the user for the end tag | |
echo "Enter the end tag (semver part only):" | |
read end | |
# Prepend release- to the end tag | |
end="release-$end" | |
# Count the commits between the two tags | |
count=$(git rev-list --count $start..$end) | |
# Print the result | |
echo "There are $count commits between $start and $end" | |
# Get the dates of the two tags | |
start_date=$(git log -1 --format=%ai $start) | |
end_date=$(git log -1 --format=%ai $end) | |
# Convert the dates to seconds since epoch | |
start_seconds=$(date -d "$start_date" +%s) | |
end_seconds=$(date -d "$end_date" +%s) | |
# Calculate the difference in seconds | |
diff_seconds=$((end_seconds - start_seconds)) | |
# Convert the difference to a human readable format using dateutils | |
diff_human=$(dateutils.ddiff -f "%Y years, %m months, %d days, %H hours, %M minutes and %S seconds" "$start_date" "$end_date") | |
# Print the result | |
echo "It has been $diff_human between $start and $end" | |
# Get the list of tags between and including the two tags that match release-0.0.0 where 0 is a number | |
tags=$(git tag --list --sort=version:refname "release-*" | awk "/$start/{flag=1}/$end/{flag=0;print}flag" | grep -E "^release-[0-9]+\.[0-9]+\.[0-9]+$") | |
# Count how many tags are in the list | |
tag_count=$(echo "$tags" | wc -l) | |
# Print the result | |
echo "There are $tag_count release tags between and including $start and $end" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment