Changeset 2a99a56 in trac.git
- Timestamp:
- Jun 2, 2021, 7:57:57 PM (3 years ago)
- Branches:
- 1.6-stable, trunk
- Children:
- 71eb25e
- Parents:
- f24965c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tracopt/versioncontrol/git/PyGIT.py
rf24965c r2a99a56 333 333 def git_version(git_bin='git'): 334 334 GIT_VERSION_MIN_REQUIRED = (1, 5, 6) 335 g = GitCore(git_bin=git_bin) 336 # 'version' has usually at least 3 numeric version 337 # components, e.g.:: 335 version = str(GitCore(git_bin=git_bin).version(), 'utf-8') 336 # 'version' should have at least 3 numeric version components: 337 # 1.5.6 338 # 1.5.6.windows.1 338 339 # 1.5.6.2 339 340 # 1.5.6.3.230.g2db511 340 341 # 1.5.6.GIT 341 try: 342 v = g.version() 343 m = re.match(b'git version (.*)\n$', v) 344 version = str(m.group(1), 'utf-8') 345 split_version = tuple(as_int(s, s) for s in version.split('.')) 346 except Exception as e: 347 raise GitError("Could not retrieve GIT version (tried to " 348 "execute/parse '%s --version' but got %s)" 349 % (git_bin, repr(e))) 342 m = re.match('git version (.*)\n$', version) 343 if not m: 344 raise GitError("Could not retrieve GIT version. " 345 "'%s --version' returned %s" 346 % (git_bin, repr(version))) 347 version_str = m.group(1) 348 version_tuple = tuple(as_int(s, s) for s in version_str.split('.')) 350 349 return { 351 'v_str': version, 352 'v_tuple': split_version, 350 'v_str': version_str, 351 'v_tuple': version_tuple, 352 'v_min_str': '.'.join(map(str, GIT_VERSION_MIN_REQUIRED)), 353 353 'v_min_tuple': GIT_VERSION_MIN_REQUIRED, 354 'v_min_str': '.'.join(map(str, GIT_VERSION_MIN_REQUIRED)), 355 'v_compatible': split_version >= GIT_VERSION_MIN_REQUIRED, 354 'v_compatible': version_tuple >= GIT_VERSION_MIN_REQUIRED, 356 355 } 357 356
Note:
See TracChangeset
for help on using the changeset viewer.