I have created a script that will locally push the branch to remote using python git lib.
But at the same time, I would like to create the PR for the master branch...I tried to look into all the options, but I can't find any way to push other than API calls
git_pulls_api = "https://github.com/api/v3/repos/{0}/{1}/pulls".format(
project_name,
repo_name)
Is there any python git libs which will do this?
Related
I'm trying to read a branch from a Git repository without having a local copy or cloning the repo.
The GitPython API seems to assume a repo either exists locally or you with to clone it to read it.
All i'd like to do is access all the commits from a branch, for a repo, without it existing locally.
I'm after something like this:
branch = git.Repo(https://github.com/MyOrg/MyRepo, 'master')
for commit in branch.commits:
print(commit)
I'm looking at the API and I just don't see anything like this.
Is this possible?
I'm localizing the ckan archiver plugin for additional languages.
For testing puropses I'd like to
fork the Github repo
make and test my changes locally
update my forked Github repo and use it with multiple customer installations
make a Github pull request to integrate my changes to the official repo
My question: How to tell CKAN to use my forked Github repo?
Is this possible in the plugin spec ckan.ini:
[app:main]
ckan.plugins = stats text_view recline_view archiver # old
ckan.plugins = stats text_view recline_view mygithubaccount/myarchiverfork # new?
or how can this be achieved instead?
Inside the virtual environment, you need to install your fork:
. /usr/lib/ckan/default/bin/activate
git clone your forked_repo
cd forked_repo && python setup.py develop
Then just use the same name inside the ckan.plugins
For automating some of our workflows I am implementing some Python scripts which create project templates. The content of a project template is located in a folder which also is a local git repository. So the project in the end will be linked and pushed to a remote repository on our company server. Each project additionally uses some of our own created libraries which are added as a git submodule into the project folder and is part of the project git repository.
So my script should now first create the local project git repository which I do by using Gitpython with the following code:
Repo.init(os.path.join(sRepoPath, '.git'), bare=True)
After the repository is created, I want to add one or more remote repositories as a submodule and then clone them into the project folder. But I can't find out how to do it from the Gitpython documentation. It does not cover such a case with remotes as a submodule.
I've already tried several code combinations from the Gitpython documentation. Something like (of course not working):
mainRepo = Repo(sDestinationRepoPath)
test_remote = mainRepo.create_remote('submodule', "ssh://git#bb.mycompany.corp:1234/fwlib/system_lib.git")
mainRepo.create_submodule(test_remote)
But I can't sort it out how it should be done. Can anyone tell me how to do it?
I am just messing around, but I have a blank project in Gitlab. I have a Python script (well, ipython notebook). I would like the Python script to simply push any files in "C:/users/files" to the Gitlab project.
I cannot find any instruction on how to do this from the API webpage here - https://python-gitlab.readthedocs.io/en/stable/gl_objects/commits.html.
It looks to me like it is impossible to do this, but surely it is.
Push is not possible with API but only possible with Git protocol. You can use GitPython (depends on git as it runs git under the hood) or dulwich (doesn't depends on git as it implements Git protocol in Python).
I have to clone a set of projects from one repository and push it then to a remote repository automatically. Therefore i'm using python and the specific module GitPython. Until now i can clone the project with gitpython like this:
def main():
Repo.clone_from(cloneUrl, localRepoPath)
# Missing: Push the cloned repo to a remote repo.
How can i use GitPython to push the cloned repo to a remote repo?
it's all in the documentation:
repo = Repo.clone_from(cloneUrl, localRepopath)
remote = repo.create_remote(remote_name, url=another_url)
remote.push(refspec='{}:{}'.format(local_branch, remote_branch))
see also the push reference API. You can avoid the refspec setting if you set a tracking branch for the remote you want to push to.
It should work like this
r = Repo.clone_from(cloneUrl, localRepoPath)
r.remotes.origin.push()
provided that a tracking branch was setup already.
Otherwise you would set a refspec:
r.remotes.origin.push(refspec='master:master')