diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py index 0f1b2233d..9cb770710 100644 --- a/qutebrowser/utils/version.py +++ b/qutebrowser/utils/version.py @@ -148,13 +148,18 @@ def _git_str_subprocess(gitpath): if not os.path.isdir(os.path.join(gitpath, ".git")): return None try: - cid = subprocess.check_output( - ['git', 'describe', '--tags', '--dirty', '--always'], + commit_hash = subprocess.check_output( + ['git', + 'describe', + '--match=NeVeRmAtCh', + '--always', + '--abbrev=40', + '--dirty'], 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) + return '{} ({})'.format(commit_hash, date) except (subprocess.CalledProcessError, OSError): return None diff --git a/tests/unit/utils/test_version.py b/tests/unit/utils/test_version.py index 489806f8c..cfd8c06a6 100644 --- a/tests/unit/utils/test_version.py +++ b/tests/unit/utils/test_version.py @@ -356,7 +356,9 @@ class TestGitStrSubprocess: def test_real_git(self, git_repo): """Test with a real git repository.""" ret = version._git_str_subprocess(str(git_repo)) - assert ret == 'foobar (1970-01-01 01:00:00 +0100)' + assert ret == \ + '6e4b65a529c0ab78fb370c1527d5809f7436b8f3 ' \ + + '(1970-01-01 01:00:00 +0100)' def test_missing_dir(self, tmpdir): """Test with a directory which doesn't exist."""