pygit2 icon indicating copy to clipboard operation
pygit2 copied to clipboard

Unable to push to remote after committing files

Open rjsbhatia opened this issue 4 years ago • 2 comments

I am committing some files using pygit2 and want to push to remote branch. This is what i am doing:

        repo = pygit2.Repository(build_dir)
        branch = repo.lookup_branch(local_branch)
        repo.checkout(branch)
        for fl in files:
           repo.index.add(fl)
        repo.index.write()
        message = f"Commiting files {files}"
        tree = repo.index.write_tree()
        parent, ref = repo.resolve_refish(refish=repo.head.name)
        author = pygit2.Signature("user", "email")
        commiter = pygit2.Signature("user", "email")

        repo.create_commit(
            ref.name,
            author,
            commiter,
            message,
            tree,
            [parent.oid],
        )



        remote = repo.remotes["origin"]
        callbacks = pygit2.RemoteCallbacks(pygit2.UserPass("username", GITHUB_PERSONAL_ACCESS_TOKEN))
        remote.push(['refs/heads/master'],callbacks=callbacks)

And i get an error: _pygit2.GitError: unsupported URL protocol

I cannot find any documentation or any clarity on whats going on here.

Any help will be much appreciated.

thanks

rjsbhatia avatar Dec 16 '20 16:12 rjsbhatia

@rjsbhatia, did you ever solve this issue?

jwheeler31 avatar Oct 08 '21 19:10 jwheeler31

Yeah, i think I was doing this on travis ci and travis had a checkedout state of repo that couldn't write back to master. I dont remember how i fixed that problem. Something to do with travis. Since then we have stopped using travis :-(

rjsbhatia avatar Oct 08 '21 19:10 rjsbhatia