all repos — mgba @ 9edbe75ff8c2741b1e7a9c54718f849227d7941b

mGBA Game Boy Advance Emulator

Python: Better handling of Git revision info (fixes #1933)
Vicki Pfau vi@endrift.com
Sat, 07 Nov 2020 17:12:24 -0800
commit

9edbe75ff8c2741b1e7a9c54718f849227d7941b

parent

cb2a2126f293663d1607d0040250094da82b9a84

1 files changed, 17 insertions(+), 15 deletions(-)

jump to
M src/platform/python/mgba/__init__.pysrc/platform/python/mgba/__init__.py

@@ -5,7 +5,23 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this

# file, You can obtain one at http://mozilla.org/MPL/2.0/. from ._pylib import ffi, lib # pylint: disable=no-name-in-module -from collections import namedtuple + +class Git: + commit = None + if lib.gitCommit and lib.gitCommit != "(unknown)": + commit = ffi.string(lib.gitCommit).decode('utf-8') + + commitShort = None + if lib.gitCommitShort and lib.gitCommitShort != "(unknown)": + commitShort = ffi.string(lib.gitCommitShort).decode('utf-8') + + branch = None + if lib.gitBranch and lib.gitBranch != "(unknown)": + branch = ffi.string(lib.gitBranch).decode('utf-8') + + revision = None + if lib.gitRevision > 0: + revision = lib.gitRevision def create_callback(struct_name, cb_name, func_name=None):

@@ -20,17 +36,3 @@ return ffi.def_extern(name=func_name)(callback)

__version__ = ffi.string(lib.projectVersion).decode('utf-8') - -GitInfo = namedtuple("GitInfo", "commit commitShort branch revision") - -GIT = {} -if lib.gitCommit and lib.gitCommit != "(unknown)": - GIT['commit'] = ffi.string(lib.gitCommit).decode('utf-8') -if lib.gitCommitShort and lib.gitCommitShort != "(unknown)": - GIT['commitShort'] = ffi.string(lib.gitCommitShort).decode('utf-8') -if lib.gitBranch and lib.gitBranch != "(unknown)": - GIT['branch'] = ffi.string(lib.gitBranch).decode('utf-8') -if lib.gitRevision > 0: - GIT['revision'] = lib.gitRevision - -GIT = GitInfo(**GIT)