我想使用 python-gitlab 更新我的 Gitlab 存储库中的多个文件。我知道如何更新单个文件,但我不想一个一个地更新每个文件。
通常,我们使用以下命令实现此目的:
- 进行更改
- git添加
- Git 提交
- git推送
有没有办法可以使用 python-gitlab 实现这一目标?
# update a single file
file_path = "/tmp/test1.txt"
gl = gitlab.Gitlab("https://gitlab.example.com/", private_token=access_token)
project = gl.projects.get(3278)
file = project.files.get(file_path=file_path, ref="PR")
file.content = 'new content'
file.save(branch='PR', commit_message='Update testfile')