Skip to content

Instantly share code, notes, and snippets.

@crsven
Last active June 23, 2021 07:29
Show Gist options
  • Select an option

  • Save crsven/c23214992e535836d8244877612f3243 to your computer and use it in GitHub Desktop.

Select an option

Save crsven/c23214992e535836d8244877612f3243 to your computer and use it in GitHub Desktop.
Sorting XCode project file
#!/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!"
#!/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"
@crsven
Copy link
Copy Markdown
Author

crsven commented Aug 31, 2017

Replacement for sock-sort.sh file found here: https://github.com/Polidea/SOCK, plus a helper script to install the git hoook:

  • will work for multiple project.pbxproj files in a single repo/workspace
  • still requires the same pysock directory with contents from the above repo
  • hardcoded to live within a top-level scripts directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment