Last active
March 3, 2024 15:27
-
-
Save caveda/013014ebbb4f11f36755a40971455c2e to your computer and use it in GitHub Desktop.
Script Function to Detect the Modules Modified Between Two Branches
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 | |
source_branch=$1 | |
target_branch=$2 | |
detectchanges() { | |
changed_modules="" | |
git diff $source_branch..$target_branch --name-only | { while read line | |
do | |
module_name=${line%%/*} | |
if [[( -d "$module_name" ) && ( $changed_modules != *"$module_name,"* )]]; | |
then | |
changed_modules="${changed_modules}${module_name}," | |
fi | |
done | |
echo $changed_modules | |
} | |
} | |
detectchanges |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're right @emilewakim96!I've corrected a couple of misplaced curly braces. Additionally, I've filled in the arguments, so you can simply run it like this:
Thanks for pointing it out!