Created
December 22, 2022 16:39
-
-
Save natenho/dd33741d6dcb046f7c2e7f0a60d9cefc to your computer and use it in GitHub Desktop.
Git - Get the list of modified directories from the last tag (ou last commit)
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 -x | |
# Get the last tag | |
last_tag=$(git describe --tags 2> /dev/null) | |
# If the last tag does not exist, get the commit hash of the last commit | |
if [ $? -ne 0 ]; then | |
last_tag="HEAD~1" | |
fi | |
# Get the list of modified directories | |
modified_dirs=$(git diff --dirstat=files,0 $last_tag HEAD | awk '{print $2}') | |
# Print the modified directories | |
echo " modified directories: $modified_dirs" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment