diff options
Diffstat (limited to 'lib/python/qmk/cli/doctor/main.py')
-rwxr-xr-x | lib/python/qmk/cli/doctor/main.py | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/lib/python/qmk/cli/doctor/main.py b/lib/python/qmk/cli/doctor/main.py index 5e93fad36..6a31ccdfd 100755 --- a/lib/python/qmk/cli/doctor/main.py +++ b/lib/python/qmk/cli/doctor/main.py | |||
@@ -9,8 +9,9 @@ from milc import cli | |||
9 | from milc.questions import yesno | 9 | from milc.questions import yesno |
10 | 10 | ||
11 | from qmk import submodules | 11 | from qmk import submodules |
12 | from qmk.constants import QMK_FIRMWARE | 12 | from qmk.constants import QMK_FIRMWARE, QMK_FIRMWARE_UPSTREAM |
13 | from .check import CheckStatus, check_binaries, check_binary_versions, check_submodules, check_git_repo | 13 | from .check import CheckStatus, check_binaries, check_binary_versions, check_submodules |
14 | from qmk.commands import git_check_repo, git_get_branch, git_is_dirty, git_get_remotes, git_check_deviation, in_virtualenv | ||
14 | 15 | ||
15 | 16 | ||
16 | def os_tests(): | 17 | def os_tests(): |
@@ -32,6 +33,37 @@ def os_tests(): | |||
32 | return CheckStatus.WARNING | 33 | return CheckStatus.WARNING |
33 | 34 | ||
34 | 35 | ||
36 | def git_tests(): | ||
37 | """Run Git-related checks | ||
38 | """ | ||
39 | status = CheckStatus.OK | ||
40 | |||
41 | # Make sure our QMK home is a Git repo | ||
42 | git_ok = git_check_repo() | ||
43 | if not git_ok: | ||
44 | cli.log.warning("{fg_yellow}QMK home does not appear to be a Git repository! (no .git folder)") | ||
45 | status = CheckStatus.WARNING | ||
46 | else: | ||
47 | git_branch = git_get_branch() | ||
48 | if git_branch: | ||
49 | cli.log.info('Git branch: %s', git_branch) | ||
50 | git_dirty = git_is_dirty() | ||
51 | if git_dirty: | ||
52 | cli.log.warning('{fg_yellow}Git has unstashed/uncommitted changes.') | ||
53 | status = CheckStatus.WARNING | ||
54 | git_remotes = git_get_remotes() | ||
55 | if 'upstream' not in git_remotes.keys() or QMK_FIRMWARE_UPSTREAM not in git_remotes['upstream'].get('url', ''): | ||
56 | cli.log.warning('{fg_yellow}The official repository does not seem to be configured as git remote "upstream".') | ||
57 | status = CheckStatus.WARNING | ||
58 | else: | ||
59 | git_deviation = git_check_deviation(git_branch) | ||
60 | if git_branch in ['master', 'develop'] and git_deviation: | ||
61 | cli.log.warning('{fg_yellow}The local "%s" branch contains commits not found in the upstream branch.', git_branch) | ||
62 | status = CheckStatus.WARNING | ||
63 | |||
64 | return status | ||
65 | |||
66 | |||
35 | @cli.argument('-y', '--yes', action='store_true', arg_only=True, help='Answer yes to all questions.') | 67 | @cli.argument('-y', '--yes', action='store_true', arg_only=True, help='Answer yes to all questions.') |
36 | @cli.argument('-n', '--no', action='store_true', arg_only=True, help='Answer no to all questions.') | 68 | @cli.argument('-n', '--no', action='store_true', arg_only=True, help='Answer no to all questions.') |
37 | @cli.subcommand('Basic QMK environment checks') | 69 | @cli.subcommand('Basic QMK environment checks') |
@@ -49,12 +81,11 @@ def doctor(cli): | |||
49 | 81 | ||
50 | status = os_tests() | 82 | status = os_tests() |
51 | 83 | ||
52 | # Make sure our QMK home is a Git repo | 84 | status = git_tests() |
53 | git_ok = check_git_repo() | ||
54 | 85 | ||
55 | if git_ok == CheckStatus.WARNING: | 86 | venv = in_virtualenv() |
56 | cli.log.warning("QMK home does not appear to be a Git repository! (no .git folder)") | 87 | if venv: |
57 | status = CheckStatus.WARNING | 88 | cli.log.info('CLI installed in virtualenv.') |
58 | 89 | ||
59 | # Make sure the basic CLI tools we need are available and can be executed. | 90 | # Make sure the basic CLI tools we need are available and can be executed. |
60 | bin_ok = check_binaries() | 91 | bin_ok = check_binaries() |