From 8887af5635446a74391423cdebf32e5a0b4030a1 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 30 Aug 2024 11:40:11 -0700 Subject: [PATCH] feat: implement git hash retrieval in __init__.py --- aider/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/aider/__init__.py b/aider/__init__.py index 2ee8a6499..b1dde9da7 100644 --- a/aider/__init__.py +++ b/aider/__init__.py @@ -2,11 +2,17 @@ __version__ = "0.54.8-dev" """ [[[cog -# TODO: write python to emit `git_hash = "X"`, where X is the latest 7-char git hash -# python goes here +import subprocess + +try: + git_hash = subprocess.check_output(['git', 'rev-parse', '--short=7', 'HEAD'], universal_newlines=True).strip() +except subprocess.CalledProcessError: + git_hash = "" + +print(f'git_hash = "{git_hash}"') ]]] """ -git_hash = "deadbee" +git_hash = "deadbee" # This line will be replaced by cog """ [[[end]]] """