diff options
-rwxr-xr-x | contrib/update_committers.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/contrib/update_committers.py b/contrib/update_committers.py index 27dbc5abf..8f9bbefbc 100755 --- a/contrib/update_committers.py +++ b/contrib/update_committers.py @@ -49,7 +49,7 @@ def get_table_entry(entry: str) -> str: def find_repository_root() -> str: root = os.getcwd() try: - root = subprocess.check_output('git rev-parse --show-toplevel', shell=True) + root = subprocess.check_output(['git', 'rev-parse', '--show-toplevel']) except CalledProcessError as e: print('The current working directory is not a git repository. \ \"git rev-parse --show-toplevel\" exited with code {}.'.format(e.returncode)) @@ -71,16 +71,15 @@ def create_committers_file(committers: OrderedDict): def commit_changes_if_needed(token: str): - committers_file = os.path.join(find_repository_root(), 'COMMITTERS.rst') - git_diff = subprocess.call('git diff --quiet {}'.format(committers_file), shell=True) + committers_file = str(os.path.join(find_repository_root(), 'COMMITTERS.rst')) + git_diff = subprocess.run(['git', 'diff' ,'--quiet', committers_file]) if git_diff: commit_message = '\'Update COMMITTERS.rst\'' branch_name = 'update_committers' - subprocess.call('git add {}'.format(committers_file), shell=True) - subprocess.call('git commit -m {}'.format(commit_message), shell=True) + subprocess.run(['git', 'add', committers_file]) + subprocess.run(['git', 'commit', '-m', commit_message]) try: - subprocess.call('git push -u origin {} 2>&1'.format(branch_name), - shell=True) + subprocess.run(['git', 'push', '-u', 'origin', branch_name], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) except CalledProcessError as e: print('Could not push to remote branch. \"git push -u origin {}\" \ exited with code {}.'.format(branch_name, e.returncode)) |