widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #14748
[Merge] lp:~widelands-dev/widelands/detect_revision_update into lp:widelands
Tino has proposed merging lp:~widelands-dev/widelands/detect_revision_update into lp:widelands.
Commit message:
use git rev-parse instead of show with head
remove use of deprecated os.open
avoid leaking of stderr into cmake output on windows
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/detect_revision_update/+merge/355590
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/detect_revision_update into lp:widelands.
=== modified file 'utils/detect_revision.py'
--- utils/detect_revision.py 2016-12-04 07:02:25 +0000
+++ utils/detect_revision.py 2018-09-25 08:31:49 +0000
@@ -44,17 +44,19 @@
def detect_git_revision():
if not sys.platform.startswith('linux') and \
not sys.platform.startswith('darwin'):
- git_revnum = os.popen(
- 'git show --pretty=format:%h | head -n 1').read().rstrip()
- if git_revnum:
- return 'unofficial-git-%s' % (git_revnum,)
- else:
- return None
+ try:
+ git_revnum = subprocess.Popen(
+ 'git rev-parse --short HEAD',stdout=subprocess.PIPE).stdout.read().rstrip()
+ if git_revnum:
+ return 'unofficial-git-%s' % (git_revnum,)
+ except:
+ pass
+ return None
- is_git_workdir = os.system('git show >/dev/null 2>&1') == 0
+ is_git_workdir = subprocess.Popen('git show >/dev/null 2>&1',stdout=subprocess.PIPE).returncode == 0
if is_git_workdir:
- git_revnum = os.popen(
- 'git show --pretty=format:%h | head -n 1').read().rstrip()
+ git_revnum = subprocess.Popen(
+ 'git rev-parse --short HEAD',stdout=subprocess.PIPE).stdout.read().rstrip()
return 'unofficial-git-%s' % (git_revnum,)
Follow ups