使用gitpython模块,我正在编写python脚本来检查所有修改过的文件的git diff - > git add.最后我想提交所有这些更改,但我没有找到命令的确切语法.
我正在尝试使用下面的代码,'git add'工作正常,但'git commit'会出错.
import git
repo = git.Repo(os.getcwd())
files = repo.git.diff(None, name_only=True)
for f in files.split('\n'):
show_diff(f)
repo.git.add(f)
repo.git.commit('test commit', author='sunilt@xxx.com')
Run Code Online (Sandbox Code Playgroud)
这是我看到的错误,似乎cmd参数中缺少某些东西.
In [10]: repo.git.commit("test commit", author="sunilt@xxx.com")
---------------------------------------------------------------------------
GitCommandError Traceback (most recent call last)
<ipython-input-10-b4505b7c53c2> in <module>()
----> 1 repo.git.commit("test commit", author="sunil.thorat@nuance.com")
c:\python27\lib\site-packages\git\cmd.pyc in <lambda>(*args, **kwargs)
421 if name[0] == '_':
422 return LazyMixin.__getattr__(self, name)
--> 423 return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
424
425 def set_persistent_git_options(self, **kwargs):
c:\python27\lib\site-packages\git\cmd.pyc …Run Code Online (Sandbox Code Playgroud)