From d611472dcffc3c7f4a9ff0b67cc61ee9c3e4e859 Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Thu, 26 Jun 2014 05:22:43 +1000 Subject: [PATCH] Add sha1_short attribute to GitCommit object --- utils/git_log.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/utils/git_log.py b/utils/git_log.py index bbef40f..2945a58 100644 --- a/utils/git_log.py +++ b/utils/git_log.py @@ -77,6 +77,22 @@ class GitCommit: ) return p.stdout.read() + @property + def sha1_short(self): + cmd = ( + "git", + "--git-dir", + self._git_dir, + "rev-parse", + "--short", + self.sha1, + ) + p = subprocess.Popen( + cmd, + stdout=subprocess.PIPE, + ) + return p.stdout.read().strip().decode('ascii') + @property def author(self): ret = self._author -- GitLab