当我尝试获取以下命令的输出时遇到问题:
git shortlog -s -- [文件路径]
使用 python 3.6 子进程模块。
这里是代码:
import subprocess
x = subprocess.Popen(['git shortlog -s -- ' + file_path], cwd=path,
shell=True, stdin=subprocess.PIPE,
stdout=subprocess.PIPE).communicate()[0]
print(x)
执行结果为空。 我做错了什么?
最佳答案
你需要调用git shortlog HEAD
subprocess.Popen(['git shortlog HEAD -s -- ' + file_path],
cwd=path, shell=True, stdin=subprocess.PIPE,
stdout=subprocess.PIPE).communicate()[0]
关于git - 在 python 子进程中使用 git shortlog 获取每个文件的贡献者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46676481/