【发布时间】:2012-02-28 23:15:12
【问题描述】:
我有一个脚本可以自动在多个 git 存储库上重写作者。
def filter_history(old, new, name, repoPath):
command = """--env-filter '
an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"
if [[ "$GIT_COMMITTER_NAME" = "|old|" ]]
then
cn="|name|"
cm="|new|"
fi
if [[ "$GIT_AUTHOR_NAME" = "|old|" ]]
then
an="|name|"
am="|new|"
fi
export GIT_AUTHOR_NAME="$an"
export GIT_AUTHOR_EMAIL="$am"
export GIT_COMMITTER_NAME="$cn"
export GIT_COMMITTER_EMAIL="$cm"
'
"""
#DO string replace
command = command.replace("|old|", old)
command = command.replace("|new|", new)
command = command.replace("|name|", name)
print "git filter-branch -f " + command
process = subprocess.Popen(['git filter-branch -f', command],cwd=os.path.dirname(repoPath), shell=True)
process.wait()
该命令执行良好,但告诉我回购历史中没有任何变化。但是,如果我使用打印出来的命令(应该是正在执行的命令),将其放入 shell 脚本并执行它,它会很好地更改历史记录。我认为该命令在某种程度上没有正确执行。有什么办法可以查看子进程模块正在执行什么命令?
【问题讨论】:
标签: python