Created
December 8, 2017 02:49
-
-
Save realyze/5c118df24ee418eae9523fd4b7009792 to your computer and use it in GitHub Desktop.
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
FILES=$(git diff --name-only `git merge-base HEAD green`) | |
FORMAT_BIN=${HOME}/.ideaformatter/Contents/bin/format.sh | |
if [[ ! -f ${FORMAT_BIN} ]]; then | |
echo 'Please symlink idea into $HOME/.ideaformatter'; | |
exit 1; | |
fi | |
FILES_ARR=($FILES) | |
ABS_FILES=( "${FILES_ARR[@]/#/`cd .. && pwd`/}" ) | |
echo "Formatting ${ABS_FILES[@]}" | |
SETTINGS_FILE=`pwd`/.idea/codeStyleSettings.xml | |
cd ~/.ideaformatter/Contents/bin && ./format.sh -s ${SETTINGS_FILE} ${ABS_FILES[@]} |
The following works better for me -- it only formats changed files (checked out + staged). I was finding the branch-based approach touch to use.
I have IJ installed standalone and not as part of the toolbox.
Assumes $CANVA
points to your canva dir (which can be set up in your ~/.bashrc, sourced from ~/.bash_profile):
SETTINGS_FILE=$CANVA/.idea/codeStyleSettings.xml
FILES=$(git diff --name-only HEAD')
FILES_ARR=($FILES)
ABS_FILES=( "${FILES_ARR[@]/#/`cd .. && pwd`/}" )
(cd /Applications/IntelliJ\ IDEA.app/Contents/bin && ./format.sh -s $SETTINGS_FILE ${ABS_FILES[@]})
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tweaked it a little, WDYT?