summaryrefslogtreecommitdiff
path: root/lib/python/qmk/git.py
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2022-07-27 02:37:28 +1000
committerGitHub <noreply@github.com>2022-07-26 17:37:28 +0100
commitd1434b6d75865d91b6b6626a06b67e24bd81e145 (patch)
treeb8ef6831fab3353de9e460c23592c4c1ecfab430 /lib/python/qmk/git.py
parent501276a8fd4139e56cb256d110ee2c6d250ce669 (diff)
Make `qmk doctor` print out the last log entry for upstream/{master,develop}, including dates (#17713)
Diffstat (limited to 'lib/python/qmk/git.py')
-rw-r--r--lib/python/qmk/git.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/python/qmk/git.py b/lib/python/qmk/git.py
index f493628492..5d09d816df 100644
--- a/lib/python/qmk/git.py
+++ b/lib/python/qmk/git.py
@@ -62,6 +62,25 @@ def git_get_tag():
return git_tag.stdout.strip()
+def git_get_last_log_entry(branch_name):
+ """Retrieves the last log entry for the branch being worked on.
+ """
+ git_lastlog = cli.run(['git', '--no-pager', 'log', '--pretty=format:%ad (%h) -- %s', '--date=iso', '-n1', branch_name])
+
+ if git_lastlog.returncode == 0 and git_lastlog.stdout:
+ return git_lastlog.stdout.strip()
+
+
+def git_get_common_ancestor(branch_a, branch_b):
+ """Retrieves the common ancestor between for the two supplied branches.
+ """
+ git_merge_base = cli.run(['git', 'merge-base', branch_a, branch_b])
+ git_branchpoint_log = cli.run(['git', '--no-pager', 'log', '--pretty=format:%ad (%h) -- %s', '--date=iso', '-n1', git_merge_base.stdout.strip()])
+
+ if git_branchpoint_log.returncode == 0 and git_branchpoint_log.stdout:
+ return git_branchpoint_log.stdout.strip()
+
+
def git_get_remotes():
"""Returns the current remotes for a repo.
"""