Last active
June 23, 2021 07:29
-
-
Save crsven/c23214992e535836d8244877612f3243 to your computer and use it in GitHub Desktop.
Sorting XCode project file
This file contains hidden or 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 | |
| GIT_ROOT=$(git rev-parse --show-toplevel) | |
| HOOKS_PATH=$(git rev-parse --git-dir)/hooks | |
| if [ ! -d "$HOOKS_PATH" ]; then | |
| mkdir $HOOKS_PATH | |
| fi | |
| ln -s -f $GIT_ROOT/scripts/sort-project-file.sh $HOOKS_PATH/pre-commit | |
| chmod 555 $HOOKS_PATH/pre-commit | |
| echo "pre-commit hook installed!" |
This file contains hidden or 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 | |
| echo "sorting project files" | |
| script_name="./scripts/pysock/sock.py" | |
| ######## Find changed project files | |
| modifiedProjectFiles=( $(git diff --name-only --cached | grep "project.pbxproj") ) | |
| ######## Sort changed project files and re-add to git | |
| for filePath in ${modifiedProjectFiles[@]}; do | |
| python $script_name $filePath | |
| git add $filePath | |
| done | |
| echo "done sorting project files" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Replacement for
sock-sort.shfile found here: https://github.com/Polidea/SOCK, plus a helper script to install the git hoook:project.pbxprojfiles in a single repo/workspacepysockdirectory with contents from the above reposcriptsdirectory.