Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation on creating a pull request #148

Open
lynna-heng opened this issue Mar 30, 2020 · 3 comments
Open

Documentation on creating a pull request #148

lynna-heng opened this issue Mar 30, 2020 · 3 comments

Comments

@lynna-heng
Copy link

Hi,

I am trying to use this package to create a pull request from the script. Is there a document that I read or shed some light on this?

Thanks,
Lynna

@lynna-heng
Copy link
Author

I looked at the module pullrequests.py and found the class below expects to pass in "parent".
What is the value of "parent'?

class PullRequest(ResourceBase):
def init(self, id, url, client, parent):
.
.
.

Thanks,
Lynna

@lynna-heng
Copy link
Author

Here's the errors I encountered when I compile the code. The issue is the "parent" parameter, and I don't know what should the right value. Please shed some light on this.

$python test.py
Traceback (most recent call last):
File "test.py", line 8, in
creq=req.create("Talking CLI PR Title", "refs/heads/test-pr-python", "refs/heads/master", description='CLI Python', state='OPEN', reviewers="monica")
File "", line 2, in create
File "/usr/lib/python2.7/site-packages/stashy/errors.py", line 62, in response_or_error
response = fn(*args, **kw)
File "/usr/lib/python2.7/site-packages/stashy/pullrequests.py", line 264, in create
fromRef=self._make_ref(fromRef, "fromRef"),
File "/usr/lib/python2.7/site-packages/stashy/pullrequests.py", line 248, in _make_ref
repo = self._parent.get()
AttributeError: 'str' object has no attribute 'get'

=================================================
$ cat test.py
import stashy
from stashy.pullrequests import PullRequest, PullRequests
stash=stashy.connect("http://mybitbucker.com:7990", "admin", "admin")
client=stash._client;
parent=""
req=PullRequests("http://mybitbucker.com:7990", client, parent)
creq=req.create("Talking CLI PR Title", "refs/heads/test-pr-python", "refs/heads/master", description='CLI Python', state='OPEN', reviewers="monica")

@rwilcox
Copy link

rwilcox commented Apr 15, 2020

Ok, so here's what worked for me

import stashy
from stashy.pullrequests import PullRequest, PullRequests
stash=stashy.connect("http://mybitbucker.com:7990", "admin", "admin")
client=stash._client;

projectKey = 'PROJECT_KEY_FROM_THAT_PROJECT_LIST_COLUMN_IN_THE_UI'
repoKey = 'MY_DESTINATION_REPO'

project = stash.projects[projectKey]
parent= project.repos['repoKey]

req=PullRequests("/projects/" + projectKey + "/repos/" + repoKey + "/pull-requests", client, parent)
# ^^^^ you super need that /pull-requests part of the path!!!!

creq=req.create("Talking CLI PR Title", "refs/heads/test-pr-python", "refs/heads/master", description='CLI Python', state='OPEN', reviewers="monica")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants