Gitpython: 测试 python 通过但没有文件推送到存储库

Gitpython: test python pass but no file pushed in the repository


我要使用 python 执行测试并将 selenium webdriver 作为服务器,我添加了 gitpython 模块,我可以应用 git 测试(克隆、添加、提交和推送)

一切正常,测试通过,但是,当我检查我的存储库时,我没有找到应该推送到存储库中的文件。

这是代码:

    myrepo = Repo.clone_from(clonefield,local_repo_path,env={'GIT_SSH_COMMAND': ssh_cmd})
    assert myrepo.__class__ is Repo  
    myfile = os.path.join(local_repo_path, 'new-file')
    # This function just creates an empty file ...
    open(myfile, 'wb').close()
    myrepo.index.add([myfile])
    myrepo.index.commit("initial commit")

    # Setup a local tracking branch of a remote branch

    print myrepo.remote().push("HEAD:refs/drafts/master")

这是结果:

     No handlers could be found for logger "git.remote"
     [git.remote.PushInfo object at 0x24fb9b0]
     .

     Ran 1 test in 88.865s

      OK

谁能帮我解决这个问题。

感谢您的帮助。


我试着像这样修复它并且效果很好 :)

myrepo = Repo.clone_from(clonefield,local_repo_path,env={'GIT_SSH_COMMAND': ssh_cmd})
assert myrepo.__class__ is Repo  
myfile = os.path.join(local_repo_path, 'new-file')
# This function just creates an empty file ...
open(myfile, 'wb').close()
myrepo.index.add([myfile])
author = Actor("author", "author@example.com")
committer = Actor("committer", "committer@exapmle.com")
index.commit("my commit message", author=author, committer=committer)

# Setup a local tracking branch of a remote branch
myrepo.remotes.origin.push("HEAD:refs/drafts/master")[0].summary