Created
February 20, 2020 05:19
-
-
Save george-lim/fbbb73722df2545e70edfc7002a25392 to your computer and use it in GitHub Desktop.
Dynamically identify updated Xcode workspace projects with git diff
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 | |
# Parameters | |
workspace_path=$1 # Path to .xcworkspace to identify projects | |
# Parameter check | |
if [[ $# != 1 ]]; then | |
echo "usage: $0 <.xcworkspace path>" | |
exit 1 | |
fi | |
# Parse project paths from workspace | |
project_paths=`cat ${workspace_path}/contents.xcworkspacedata | egrep .xcodeproj | sed -e 's| location = \"group:||' -e 's|/[^/]*$|/|' | tr '\n' '|' | sed 's/.$//'` | |
branch=`git rev-parse --abbrev-ref HEAD` # Current branch | |
ancestor=`git merge-base $branch origin/master` # Least common ancestor from origin/master | |
diff_paths=`git diff --name-only $ancestor # Get all file changes from ancestor | |
# Iterate through project paths with changes | |
while read project_path; do | |
project_name=`basename $project_path` # Project name | |
echo "Changes found in project '$project_name'" | |
done< <(echo $diff_paths | egrep -o $project_paths | uniq) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment