forked from PX4/PX4-Bootloader
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tools:Added Git submodule checking that obeys GIT_SUBMODULES_ARE_EVIL
- Loading branch information
David Sidrane
committed
Jul 5, 2018
1 parent
f6b273d
commit 1492677
Showing
3 changed files
with
49 additions
and
18 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,63 @@ | ||
#!/bin/sh | ||
#!/usr/bin/env bash | ||
|
||
if [ -d libopencm3 ]; | ||
[ -n "$GIT_SUBMODULES_ARE_EVIL" ] && { | ||
# GIT_SUBMODULES_ARE_EVIL is set, meaning user doesn't want submodules | ||
echo "Skipping submodules." | ||
exit 0 | ||
} | ||
|
||
GITSTATUS=$(git status) | ||
|
||
function check_git_submodule { | ||
|
||
if [ -d $1 ]; | ||
then | ||
STATUSRETVAL=$(git submodule summary | grep -A20 -i "libopencm3" | grep "<") | ||
SUBMODULE_STATUS=$(git submodule summary "$1") | ||
STATUSRETVAL=$(echo $SUBMODULE_STATUS | grep -A20 -i "$1" | grep "<") | ||
if [ -z "$STATUSRETVAL" ]; then | ||
echo "Checked libopencm3 submodule, correct version found" | ||
echo "Checked $1 submodule, correct version found" | ||
else | ||
echo -e "\033[31mChecked $1 submodule, ACTION REQUIRED:\033[0m" | ||
echo "" | ||
echo -e "New commits required:" | ||
echo -e "$SUBMODULE_STATUS" | ||
echo "" | ||
echo " libopencm3 sub repo not at correct version. Try 'git submodule update'" | ||
echo " or follow instructions on http://px4.io/dev/git/submodules" | ||
echo "" | ||
echo " DO NOT FORGET TO RUN 'make clean' AFTER EACH libopencm3 UPDATE!" | ||
echo -e " *******************************************************************************" | ||
echo -e " * \033[31mIF YOU DID NOT CHANGE THIS FILE (OR YOU DON'T KNOW WHAT A SUBMODULE IS):\033[0m *" | ||
echo -e " * \033[31mHit 'u' and <ENTER> to update ALL submodules and resolve this.\033[0m *" | ||
echo -e " * (performs \033[94mgit submodule update --init --recursive\033[0m) *" | ||
echo -e " *******************************************************************************" | ||
echo "" | ||
echo "" | ||
echo "New commits required:" | ||
echo "$(git submodule summary)" | ||
echo -e " Only for EXPERTS:" | ||
echo -e " $1 submodule is not in the recommended version." | ||
echo -e " Hit 'y' and <ENTER> to continue the build with this version. Hit <ENTER> to resolve manually." | ||
echo -e " Use \033[94mgit add $1 && git commit -m 'Updated $1'\033[0m to choose this version (careful!)" | ||
echo "" | ||
exit 1 | ||
read user_cmd | ||
if [ "$user_cmd" == "y" ] | ||
then | ||
echo "Continuing build with manually overridden submodule.." | ||
else | ||
if [ "$user_cmd" == "u" ] | ||
then | ||
git submodule update --init --recursive | ||
echo "Submodule fixed, continuing build.." | ||
else | ||
echo "Build aborted." | ||
exit 1 | ||
fi | ||
fi | ||
fi | ||
else | ||
git submodule init; | ||
git submodule update --init --recursive; | ||
git submodule update; | ||
fi | ||
|
||
} | ||
|
||
check_git_submodule libopencm3 | ||
check_git_submodule lib/kinetis/NXP_Kinetis_Bootloader_2_0_0 | ||
|
||
exit 0 |
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