diff options
author | Joel Challis <git@zvecr.com> | 2023-01-06 04:16:52 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-06 04:16:52 +0000 |
commit | 5c730d971ec78344e1304f746436ac0e1d61aea5 (patch) | |
tree | 839a165c8fb4c9bb2d7645e3f8c6e4ee68e35623 /lib | |
parent | b2384f18096d42fb4ed036a2fc0135e6d32ece5d (diff) |
Migrate submodule dirty check to CLI (#19488)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/python/qmk/cli/git/submodule.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/python/qmk/cli/git/submodule.py b/lib/python/qmk/cli/git/submodule.py index bcc3868a52..9f354c021e 100644 --- a/lib/python/qmk/cli/git/submodule.py +++ b/lib/python/qmk/cli/git/submodule.py @@ -1,8 +1,10 @@ import shutil -from qmk.path import normpath from milc import cli +from qmk.path import normpath +from qmk import submodules + REMOVE_DIRS = [ 'lib/ugfx', '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.') 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: if normpath(folder).is_dir(): print(f"Removing '{folder}'") |