From d1434b6d75865d91b6b6626a06b67e24bd81e145 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Wed, 27 Jul 2022 02:37:28 +1000 Subject: Make `qmk doctor` print out the last log entry for upstream/{master,develop}, including dates (#17713) --- lib/python/qmk/cli/doctor/main.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'lib/python/qmk/cli/doctor') diff --git a/lib/python/qmk/cli/doctor/main.py b/lib/python/qmk/cli/doctor/main.py index 2898a9894c..1600ab8dd4 100755 --- a/lib/python/qmk/cli/doctor/main.py +++ b/lib/python/qmk/cli/doctor/main.py @@ -11,7 +11,7 @@ from milc.questions import yesno from qmk import submodules from qmk.constants import QMK_FIRMWARE, QMK_FIRMWARE_UPSTREAM from .check import CheckStatus, check_binaries, check_binary_versions, check_submodules -from qmk.git import git_check_repo, git_get_branch, git_get_tag, git_is_dirty, git_get_remotes, git_check_deviation +from qmk.git import git_check_repo, git_get_branch, git_get_tag, git_get_last_log_entry, git_get_common_ancestor, git_is_dirty, git_get_remotes, git_check_deviation from qmk.commands import in_virtualenv @@ -66,10 +66,32 @@ def git_tests(): if git_branch in ['master', 'develop'] and git_deviation: cli.log.warning('{fg_yellow}The local "%s" branch contains commits not found in the upstream branch.', git_branch) status = CheckStatus.WARNING + for branch in [git_branch, 'upstream/master', 'upstream/develop']: + cli.log.info('- Latest %s: %s', branch, git_get_last_log_entry(branch)) + for branch in ['upstream/master', 'upstream/develop']: + cli.log.info('- Common ancestor with %s: %s', branch, git_get_common_ancestor(branch, 'HEAD')) return status +def output_submodule_status(): + """Prints out information related to the submodule status. + """ + cli.log.info('Submodule status:') + sub_status = submodules.status() + for s in sub_status.keys(): + sub_info = sub_status[s] + if 'name' in sub_info: + sub_name = sub_info['name'] + sub_shorthash = sub_info['shorthash'] if 'shorthash' in sub_info else '' + sub_describe = sub_info['describe'] if 'describe' in sub_info else '' + sub_last_log_timestamp = sub_info['last_log_timestamp'] if 'last_log_timestamp' in sub_info else '' + if sub_last_log_timestamp != '': + cli.log.info(f'- {sub_name}: {sub_last_log_timestamp} -- {sub_describe} ({sub_shorthash})') + else: + cli.log.error(f'- {sub_name}: <<< missing or unknown >>>') + + @cli.argument('-y', '--yes', action='store_true', arg_only=True, help='Answer yes to all questions.') @cli.argument('-n', '--no', action='store_true', arg_only=True, help='Answer no to all questions.') @cli.subcommand('Basic QMK environment checks') @@ -129,6 +151,8 @@ def doctor(cli): elif sub_ok == CheckStatus.WARNING and status == CheckStatus.OK: status = CheckStatus.WARNING + output_submodule_status() + # Report a summary of our findings to the user if status == CheckStatus.OK: cli.log.info('{fg_green}QMK is ready to go') -- cgit v1.2.3