私のジェンキンスジョブにpythonを使用しようとしています。このジョブはプロジェクトの行を更新してからコミットしてプルリクエストを作成します。GitPythonのドキュメントを私のできるだけ難しいのですが、私の下脳は何の意味も持てません。GitPythonでGit Pull Requestを作成する方法
import git
import os
import os.path as osp
path = "banana-post/infrastructure/"
repo = git.Repo.clone_from('https://github.myproject.git',
osp.join('/Users/monkeyman/PycharmProjects/projectfolder/', 'monkey-post'), branch='banana-refresh')
os.chdir(path)
latest_banana = '123456'
input_file_name = "banana.yml"
output_file_name = "banana.yml"
with open(input_file_name, 'r') as f_in, open(output_file_name, 'w') as f_out:
for line in f_in:
if line.startswith("banana_version:"):
f_out.write("banana_version: {}".format(latest_banana))
f_out.write("\n")
else:
f_out.write(line)
os.remove("deploy.yml")
os.rename("deploy1.yml", "banana.yml")
files = repo.git.diff(None, name_only=True)
for f in files.split('\n'):
repo.git.add(f)
repo.git.commit('-m', 'This an Auto banana Refresh, contact [email protected]',
author='[email protected]')
この変更をコミットした後、私はこの変更push
にしようとしていますし、branch='banana-integration'
にbranch='banana-refresh'
からpull request
を作成します。
私はGitPythonについて知らないが、あなたは* *コマンドラインからそれを行うことができます。https://git-scm.com/docs/git-request-pull。私はGitPythonが単にそのラッパーであると思います。 – SwiftsNamesake