From: Paul Brossier Date: Thu, 23 Mar 2017 20:47:10 +0000 (+0100) Subject: this_version.py: simplify git clean check X-Git-Tag: 0.4.5~45^2 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=115b4526f8875d3bbf6b419ddab940db5de249cc;p=aubio.git this_version.py: simplify git clean check --- diff --git a/this_version.py b/this_version.py index 7674ef74..4629f140 100644 --- a/this_version.py +++ b/this_version.py @@ -84,19 +84,16 @@ def get_git_revision_hash(short=True): print('git command error :%s' % e) return None # check if we have a clean tree - gitcmd = ['git', '-C', aubio_dir, 'diff-index', '--quiet'] - gitcmd.append('HEAD') + gitcmd = ['git', '-C', aubio_dir, 'status', '--porcelain'] try: - output = subprocess.check_output(gitcmd) - except subprocess.CalledProcessError: - try: - import sys - sys.stdout.write('Info: current git tree is not clean\n') - gitstatus = subprocess.check_output(['git', 'status']) - sys.stdout.write(gitstatus.decode('utf8')) - except Exception: - pass - gitsha += '+mods' + output = subprocess.check_output(gitcmd).decode('utf8') + if len(output): + print('Info: current tree is not clean\n') + print(output) + gitsha += '+mods' + except subprocess.CalledProcessError as e: + print (e) + pass return gitsha if __name__ == '__main__':