在python子流程中使用git shortlog获取每个文件的贡献者

在python子流程中使用git shortlog获取每个文件的贡献者,git,python-3.x,Git,Python 3.x,当我试图获取以下命令的输出时,出现了一个问题: git shortlog-s--[文件路径] 使用Python3.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-s--[文件路径]
使用Python3.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 shortlog HEAD

subprocess.Popen(['git shortlog HEAD -s -- ' + file_path],
                  cwd=path,  shell=True, stdin=subprocess.PIPE, 
                  stdout=subprocess.PIPE).communicate()[0]

要了解原因,请参见

您找到答案了吗?这也是我的问题。例如,当执行
git status
git log
时,一切正常,但当执行
git shortlog
时,它停止工作。不,我没有。我只是放弃了
git-shortlog
,通过分析
git-log
输出来获取必要的数据。你找到答案了吗?这也是我的问题。例如,当执行
git status
git log
时,一切正常,但当执行
git shortlog
时,它停止工作。不,我没有。我只是放弃了
git-shortlog
,从
git-log
输出的解析中获取必要的数据。