Skip to content

Commit

Permalink
Test for git repo
Browse files Browse the repository at this point in the history
Suggestion by @skullydazed
  • Loading branch information
yanfali committed Nov 6, 2018
1 parent f89cada commit ac491e1
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions util/new_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,19 @@ find "keyboards/${KEYBOARD}" -type f -exec sed -i '' -e "s;%KEYBOARD_UPPERCASE%;

GIT=$(whereis git)
if [ "$GIT" != "" ]; then
USER=$($GIT config --get user.name)
ID="'$USER'"
echo "Using $ID as user name"

KBD=keyboards/${KEYBOARD}
for i in "$KBD/config.h" "$KBD/$KEYBOARD_NAME.c" "$KBD/$KEYBOARD_NAME.h" "$KBD/keymaps/default/config.h" "$KBD/keymaps/default/keymap.c"
do
awk -v id="$ID" '{sub(/REPLACE_WITH_YOUR_NAME/,id); print}' < "$i" > "$i.$$"
mv "$i.$$" "$i"
done
IS_GIT_REPO=$($GIT log >>/dev/null 2>&1; echo $?)
if [ $IS_GIT_REPO -eq 0 ]; then
USER=$($GIT config --get user.name)
ID="'$USER'"
echo "Using $ID as user name"

KBD=keyboards/${KEYBOARD}
for i in "$KBD/config.h" "$KBD/$KEYBOARD_NAME.c" "$KBD/$KEYBOARD_NAME.h" "$KBD/keymaps/default/config.h" "$KBD/keymaps/default/keymap.c"
do
awk -v id="$ID" '{sub(/REPLACE_WITH_YOUR_NAME/,id); print}' < "$i" > "$i.$$"
mv "$i.$$" "$i"
done
fi
fi

echo "######################################################"
Expand Down

0 comments on commit ac491e1

Please sign in to comment.