首页 > 解决方案 > 无法在 python (AWS Lambda) 中使用“lambda-git”库使用“diff”命令

问题描述

我在 AWS lambda(python 3.7) 中导入了 git (lambda-git) 库。我能够执行以下所有命令。

git.exec_command("clone", "repo-url", "/tmp/repo")
new_repo_path = '/tmp/repo'
git.exec_command('init', cwd=new_repo_path) 
git.exec_command('branch', '-v', cwd=new_repo_path)
git.exec_command('fetch' , cwd=new_repo_path )
git.exec_command('checkout' , 'branch', cwd=new_repo_path )

但是当我尝试使用以下命令时,

git.exec_command('diff','--name-only HEAD HEAD~1', cwd=new_repo_path)

我收到以下错误,

[ERROR] GitExecutionError: command=['git', 'diff', '--name-only HEAD HEAD~1'] returncode=255 stdout="b''" stderr="b'error: invalid option: --name-only HEAD HEAD~1\n'"

但是当我尝试运行与 git cli 相同的命令(如下所示)时,我得到了正确的结果

git diff --name-only HEAD HEAD~1

有什么我想念的吗?有人可以帮我弄这个吗?

标签: python-3.xgitamazon-web-serviceslambdaaws-lambda

解决方案


推荐阅读