Merge lp:~widelands-dev/widelands/detect_revision_update into lp:widelands

Proposed by Tino
Status: Merged
Merged at revision: 8862
Proposed branch: lp:~widelands-dev/widelands/detect_revision_update
Merge into: lp:widelands
Diff against target: 64 lines (+21/-16)
1 file modified
utils/detect_revision.py (+21/-16)
To merge this branch: bzr merge lp:~widelands-dev/widelands/detect_revision_update
Reviewer Review Type Date Requested Status
Tino Approve
GunChleoc Approve
Review via email: mp+355590@code.launchpad.net

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

To post a comment you must log in.
Revision history for this message
GunChleoc (gunchleoc) wrote :

Code LGTM. Not tested.

review: Approve
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4038. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/432860634.
Appveyor build 3834. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_detect_revision_update-3834.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Appveyor builds are working, compiling from Git on Linux will not. We have to wait for https://code.launchpad.net/~widelands-dev/widelands/cmake_errors_WL_VERSION/+merge/355728, merge in trunk and then test again.

Revision history for this message
Tino (tino79) wrote :

No, the cmake warning is not causing the failure.
I've updated the whole function, should work on every os...

Revision history for this message
Tino (tino79) wrote :

Ok, currently at least on travis (MacOS and Linux) and on Travis (Windows) CMake + DetectRevision.py can determine the git version.
On my local machine (windows) both git and bzr work.

So this can go in from my side.

review: Approve
Revision history for this message
GunChleoc (gunchleoc) wrote :

I have tested both git and bzr. Linux is fine, so is git on MSys2. I could not it to work with bazaar on MSys2, but that's because the bzr pypi package is buggy, and it's accordingly already broken in trunk.

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'utils/detect_revision.py'
--- utils/detect_revision.py 2018-09-26 08:47:26 +0000
+++ utils/detect_revision.py 2018-09-28 08:20:49 +0000
@@ -42,20 +42,19 @@
4242
4343
44def detect_git_revision():44def detect_git_revision():
45 if not sys.platform.startswith('linux') and \45 try:
46 not sys.platform.startswith('darwin'):46 cmd = subprocess.Popen(
47 git_revnum = os.popen(47 ['git','rev-parse','--short','HEAD'],
48 'git show --pretty=format:%h | head -n 1').read().rstrip()48 stdout=subprocess.PIPE,
49 stderr=subprocess.PIPE,cwd=base_path
50 )
51 stdout,stderr = cmd.communicate()
52 git_revnum = stdout.rstrip()
49 if git_revnum:53 if git_revnum:
50 return 'unofficial-git-%s' % (git_revnum,)54 return 'unofficial-git-%s' % git_revnum
51 else:55 except Exception as e:
52 return None56 pass
5357 return None
54 is_git_workdir = os.system('git show >/dev/null 2>&1') == 0
55 if is_git_workdir:
56 git_revnum = os.popen(
57 'git show --pretty=format:%h | head -n 1').read().rstrip()
58 return 'unofficial-git-%s' % (git_revnum,)
5958
6059
61def check_for_explicit_version():60def check_for_explicit_version():
@@ -72,8 +71,12 @@
7271
73def detect_bzr_revision():72def detect_bzr_revision():
74 if __has_bzrlib:73 if __has_bzrlib:
75 b = BzrDir.open(base_path).open_branch()74 try:
76 revno, nick = b.revno(), b.nick75 b = BzrDir.open(base_path).open_branch()
76 revno, nick = b.revno(), b.nick
77 return 'bzr%s[%s]' % (revno, nick)
78 except:
79 return None
77 else:80 else:
78 # Windows stand alone installer do not come with bzrlib. We try to81 # Windows stand alone installer do not come with bzrlib. We try to
79 # parse the output of bzr then directly82 # parse the output of bzr then directly
@@ -83,9 +86,11 @@
83 ).stdout.read().strip().decode('utf-8')86 ).stdout.read().strip().decode('utf-8')
84 revno = run_bzr('revno')87 revno = run_bzr('revno')
85 nick = run_bzr('nick')88 nick = run_bzr('nick')
89 return 'bzr%s[%s]' % (revno, nick)
86 except OSError:90 except OSError:
87 return None91 return None
88 return 'bzr%s[%s]' % (revno, nick)92 return None
93
8994
9095
91def detect_revision():96def detect_revision():

Subscribers

People subscribed via source and target branches

to status/vote changes: