没有找到处理程序的记录器" git.remote"

时间:2017-07-10 12:24:23

标签: python git gerrit gitpython

所以我使用gitpython来解决问题:

  

无法找到记录器" git.remote"

的处理程序

我的代码

print repo_object.remote() # origin
print repo_object.active_branch # master
print repo_object.active_branch.name # master
refspec = repo_object.active_branch.name + ":refs/for/" + repo_object.active_branch.name
print refspec # master:/refs/for/master
print "Push " + refspec # push master:refs/for/master
print remote.push(refspec) # [<git.remote.PushInfo object at 0x....>]
remote.push(refspec)

pushed_repos.append(repo_name)
print pushed_repos # my project repo

我的目标是将新添加(创建/更新)的子文件推送到gerrit。

编辑:来自@Arount的请求

好的,所以我有一个名为

的函数
del_proj_gerrit(pushed_repos, commit_message, repo_path, repo_name, push)

参数具有以下值:

pushed_repos # []
commit_message # just a commit message
repo_name_path # path to my local repo
repo_name # name of the project repo
push # A value of True is set here

del_proj_gerrit函数中,我有:

add_all_files("./")
    if push == True:
    commit_and_push(pushed_repos, commit_message, repo_path, repo_name)

commit_and_push函数中,我有:

repo_path_new = repo_path+repo_name
repo_object = Repo(repo_path_new) # <git.Repo "C\localpath\.git\modules\repo-project">
if commit_command_line(commit_message, repo_object, repo_name):
    # Inside the if-statement you have the code I posted before

我在commit_command_line函数内部:

cmd = "git commit -m \"%s\"" % commit_message
errmsg = "Failed command:\n" + cmd
success = True
try:
    execute_shell_process(cmd, errmsg, True, True)
except CommonProcessError as e:
    print "Error during commit for repo '" + repo_name + "' (ret code " + \
        str(e.returncode) + ")."
    print "Assuming that there was no changes to last commit    => continue"
    success = False
return success

1 个答案:

答案 0 :(得分:0)

GitPython使用python日志记录,因此您只需配置它即可。根据{{​​3}},最小配置为:

import logging
logging.basicConfig(level=logging.INFO)