Skip to content

Commit

Permalink
qmk doctor: display qmk_firmware version tag (qmk#16155)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored Feb 2, 2022
1 parent 16ad8c0 commit c9f88d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/python/qmk/cli/doctor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
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.commands import git_check_repo, git_get_branch, git_is_dirty, git_get_remotes, git_check_deviation, in_virtualenv
from qmk.commands import git_check_repo, git_get_branch, git_get_tag, git_is_dirty, git_get_remotes, git_check_deviation, in_virtualenv


def os_tests():
Expand Down Expand Up @@ -47,6 +47,11 @@ def git_tests():
git_branch = git_get_branch()
if git_branch:
cli.log.info('Git branch: %s', git_branch)

repo_version = git_get_tag()
if repo_version:
cli.log.info('Repo version: %s', repo_version)

git_dirty = git_is_dirty()
if git_dirty:
cli.log.warning('{fg_yellow}Git has unstashed/uncommitted changes.')
Expand Down
8 changes: 8 additions & 0 deletions lib/python/qmk/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,14 @@ def git_get_branch():
return git_branch.stdout.strip()


def git_get_tag():
"""Returns the current tag for a repo, or None.
"""
git_tag = cli.run(['git', 'describe', '--abbrev=0', '--tags'])
if git_tag.returncode == 0:
return git_tag.stdout.strip()


def git_is_dirty():
"""Returns 1 if repo is dirty, or 0 if clean
"""
Expand Down

0 comments on commit c9f88d7

Please sign in to comment.