diff --git a/doc/TODO b/doc/TODO index 5d0654d5d..0d3a5558f 100644 --- a/doc/TODO +++ b/doc/TODO @@ -45,7 +45,6 @@ Improvements / minor features - Color statusbar in insert mode - set_toggle to toggle setting between two states - Customizable statusbar -- Timestamp of git commit in version - Show size of widgets in __repr__ - Ask whether to close when downloads are running or maybe if form fields are unsubmitted (book page 187) diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py index 3e423d4ca..a3e05fa57 100644 --- a/qutebrowser/utils/version.py +++ b/qutebrowser/utils/version.py @@ -97,20 +97,24 @@ def _git_str(): def _git_str_subprocess(gitpath): - """Try to get the git commit ID by calling git. + """Try to get the git commit ID and timestamp by calling git. Args: gitpath: The path where the .git folder is. Return: - The path on success, None on failure. + The ID/timestamp on success, None on failure. """ if not os.path.isdir(os.path.join(gitpath, ".git")): return None try: - return subprocess.check_output( + cid = subprocess.check_output( ['git', 'describe', '--tags', '--dirty', '--always'], cwd=gitpath).decode('UTF-8').strip() + date = subprocess.check_output( + ['git', 'show', '-s', '--format=%ci', 'HEAD'], + cwd=gitpath).decode('UTF-8').strip() + return '{} ({})'.format(cid, date) except (subprocess.CalledProcessError, FileNotFoundError): return None diff --git a/scripts/setupcommon.py b/scripts/setupcommon.py index 43a955612..b1737391b 100644 --- a/scripts/setupcommon.py +++ b/scripts/setupcommon.py @@ -61,7 +61,7 @@ def _git_str(): """Try to find out git version. Return: - string containing the git commit ID. + string containing the git commit ID and timestamp. None if there was an error or we're not in a git repo. """ if BASEDIR is None: @@ -69,9 +69,13 @@ def _git_str(): if not os.path.isdir(os.path.join(BASEDIR, ".git")): return None try: - return subprocess.check_output( + cid = subprocess.check_output( ['git', 'describe', '--tags', '--dirty', '--always'], cwd=BASEDIR).decode('UTF-8').strip() + date = subprocess.check_output( + ['git', 'show', '-s', '--format=%ci', 'HEAD'], + cwd=BASEDIR).decode('UTF-8').strip() + return '{} ({})'.format(cid, date) except (subprocess.CalledProcessError, FileNotFoundError): return None