Changeset View
Changeset View
Standalone View
Standalone View
scap/utils.py
Show First 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | with open(os.devnull, 'wb') as dev_null: | ||||
remote = subprocess.check_output( | remote = subprocess.check_output( | ||||
('/usr/bin/git', 'remote'), | ('/usr/bin/git', 'remote'), | ||||
cwd=repo_directory, stderr=dev_null).strip() | cwd=repo_directory, stderr=dev_null).strip() | ||||
return subprocess.check_output( | return subprocess.check_output( | ||||
('/usr/bin/git', 'merge-base', 'HEAD', remote), | ('/usr/bin/git', 'merge-base', 'HEAD', remote), | ||||
cwd=repo_directory, stderr=dev_null).strip() | cwd=repo_directory, stderr=dev_null).strip() | ||||
def git_describe(location): | |||||
"""Returns a convenient label for the current state of the git repo.""" | |||||
ensure_git_dir(location) | |||||
with cd(location): | |||||
cmd = '/usr/bin/git describe --always' | |||||
return subprocess.check_output(cmd, shell=True).strip() | |||||
def git_info(directory): | def git_info(directory): | ||||
"""Compute git version information for a given directory that is | """Compute git version information for a given directory that is | ||||
compatible with MediaWiki's GitInfo class. | compatible with MediaWiki's GitInfo class. | ||||
:param directory: Directory to scan for git information | :param directory: Directory to scan for git information | ||||
:returns: Dict of information about current repository state | :returns: Dict of information about current repository state | ||||
""" | """ | ||||
git_dir = os.path.join(directory, '.git') | git_dir = os.path.join(directory, '.git') | ||||
▲ Show 20 Lines • Show All 535 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 3.0 (CC-BY-SA) unless otherwise noted; code licensed under GNU General Public License (GPL) or other open source licenses. By using this site, you agree to the Terms of Use, Privacy Policy, and Code of Conduct. · Wikimedia Foundation · Privacy Policy · Code of Conduct · Terms of Use · Disclaimer · CC-BY-SA · GPL