Search code examples
pythongitseleniumpushgitpython

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



I'm about executing test using python and as selenium webdriver as a server , i added the gitpython module that i can apply a git test (clone , add , commit and push)

Every thing is Ok , and the test is passed but , when i check my repo i don't find the file that supposed pushed in the repository.

This is the code :

    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")

This is the result :

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

     Ran 1 test in 88.865s

      OK

Can any one help me to resolve this.

Thank you for your help.


Solution


  • I tried to fix it like this and it works good :)

    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