INNER CODE UNIT · Python
run_git_command
wikimedia/apps-android-wikipedia · scripts/bump-version-code.py:40
def run_git_command(*args, cwd=None):
"""
Run a git command with the given arguments in a cross-platform way.
"""
cmd = ['git'] + list(args)
try:
result = subprocess.run(cmd, cwd=cwd, check=True, capture_output=True, text=True)
return result.stdout.strip()
except subprocess.CalledProcessError as e:
raise RuntimeError(f"Git command failed: {' '.join(cmd)}\nError: {e.stderr}")
def transform_file(file_path, *funcs):
"""
Transforms the file given in file_path by passing it
serially through all the functions in *func and then
writing it back out to file_path
"""