Migrate submodule dirty check to CLI (#19488)
This commit is contained in:
parent
b2384f1809
commit
5c730d971e
16
Makefile
16
Makefile
|
@ -394,21 +394,9 @@ ifdef NOT_REPO
|
||||||
printf "$(MSG_NOT_REPO)"
|
printf "$(MSG_NOT_REPO)"
|
||||||
endif
|
endif
|
||||||
ifndef SKIP_GIT
|
ifndef SKIP_GIT
|
||||||
|
$(QMK_BIN) git-submodule --sync
|
||||||
# Check if the submodules are dirty, and display a warning if they are
|
# Check if the submodules are dirty, and display a warning if they are
|
||||||
if [ ! -e lib/chibios ]; then git submodule sync lib/chibios && git submodule update --depth 50 --init lib/chibios; fi
|
if ! $(QMK_BIN) git-submodule --check 1> /dev/null 2>&1; then printf "$(MSG_SUBMODULE_DIRTY)"; fi
|
||||||
if [ ! -e lib/chibios-contrib ]; then git submodule sync lib/chibios-contrib && git submodule update --depth 50 --init lib/chibios-contrib; fi
|
|
||||||
if [ ! -e lib/lufa ]; then git submodule sync lib/lufa && git submodule update --depth 50 --init lib/lufa; fi
|
|
||||||
if [ ! -e lib/vusb ]; then git submodule sync lib/vusb && git submodule update --depth 50 --init lib/vusb; fi
|
|
||||||
if [ ! -e lib/printf ]; then git submodule sync lib/printf && git submodule update --depth 50 --init lib/printf; fi
|
|
||||||
if [ ! -e lib/pico-sdk ]; then git submodule sync lib/pico-sdk && git submodule update --depth 50 --init lib/pico-sdk; fi
|
|
||||||
if [ ! -e lib/lvgl ]; then git submodule sync lib/lvgl && git submodule update --depth 50 --init lib/lvgl; fi
|
|
||||||
git submodule status --recursive 2>/dev/null | \
|
|
||||||
while IFS= read -r x; do \
|
|
||||||
case "$$x" in \
|
|
||||||
\ *) ;; \
|
|
||||||
*) printf "$(MSG_SUBMODULE_DIRTY)";break;; \
|
|
||||||
esac \
|
|
||||||
done
|
|
||||||
endif
|
endif
|
||||||
rm -f $(ERROR_FILE) > /dev/null 2>&1
|
rm -f $(ERROR_FILE) > /dev/null 2>&1
|
||||||
$(eval $(call PARSE_RULE,$@))
|
$(eval $(call PARSE_RULE,$@))
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import shutil
|
import shutil
|
||||||
from qmk.path import normpath
|
|
||||||
|
|
||||||
from milc import cli
|
from milc import cli
|
||||||
|
|
||||||
|
from qmk.path import normpath
|
||||||
|
from qmk import submodules
|
||||||
|
|
||||||
REMOVE_DIRS = [
|
REMOVE_DIRS = [
|
||||||
'lib/ugfx',
|
'lib/ugfx',
|
||||||
'lib/pico-sdk',
|
'lib/pico-sdk',
|
||||||
|
@ -11,8 +13,22 @@ REMOVE_DIRS = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@cli.argument('--check', arg_only=True, action='store_true', help='Check if the submodules are dirty, and display a warning if they are.')
|
||||||
|
@cli.argument('--sync', arg_only=True, action='store_true', help='Shallow clone any missing submodules.')
|
||||||
@cli.subcommand('Git Submodule actions.')
|
@cli.subcommand('Git Submodule actions.')
|
||||||
def git_submodule(cli):
|
def git_submodule(cli):
|
||||||
|
"""Git Submodule actions
|
||||||
|
"""
|
||||||
|
if cli.args.check:
|
||||||
|
return all(item['status'] for item in submodules.status().values())
|
||||||
|
|
||||||
|
if cli.args.sync:
|
||||||
|
cli.run(['git', 'submodule', 'sync', '--recursive'])
|
||||||
|
for name, item in submodules.status().items():
|
||||||
|
if item['status'] is None:
|
||||||
|
cli.run(['git', 'submodule', 'update', '--depth=50', '--init', name], capture_output=False)
|
||||||
|
return True
|
||||||
|
|
||||||
for folder in REMOVE_DIRS:
|
for folder in REMOVE_DIRS:
|
||||||
if normpath(folder).is_dir():
|
if normpath(folder).is_dir():
|
||||||
print(f"Removing '{folder}'")
|
print(f"Removing '{folder}'")
|
||||||
|
|
Loading…
Reference in New Issue