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

feat: Add support for creating PullRequests. #63

Merged
merged 1 commit into from
Jan 21, 2020
Merged

feat: Add support for creating PullRequests. #63

merged 1 commit into from
Jan 21, 2020

Conversation

bigkevmcd
Copy link

@bigkevmcd bigkevmcd commented Jan 16, 2020

This adds support for creating a PullRequest with title, body branch references in the GitHub and GitLab drivers.

The fake driver records created PullRequestInput records.

The other drivers return NotSupported errors.

@jenkins-x-bot
Copy link

Hi @bigkevmcd. Thanks for your PR.

I'm waiting for a jenkins-x member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@bigkevmcd bigkevmcd changed the title [WIP] Add support for creating PullRequests. Add support for creating PullRequests. Jan 16, 2020
@bigkevmcd bigkevmcd changed the title Add support for creating PullRequests. feat: Add support for creating PullRequests. Jan 16, 2020
This adds support for creating a PullRequest with title, body branch references in the GitHub and GitLab drivers.

The fake driver records created PullRequestInput records.

The other drivers return NotSupported errors.
@jstrachan
Copy link
Member

/ok-to-test

@jstrachan
Copy link
Member

/lgtm

@jenkins-x-bot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jstrachan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jenkins-x-bot jenkins-x-bot merged commit 8039690 into jenkins-x:master Jan 21, 2020
@bigkevmcd bigkevmcd deleted the create-pull-request branch January 21, 2020 14:19
abayer added a commit to abayer/go-scm that referenced this pull request Jan 30, 2020
Basically the same as jenkins-x#63, but for updating rather than
creating. Again only supporting GitHub and GitLab right now, but I'll
come back and do BitBucket and Stash (aka Cloud and Server) sometime
in the non-distant future.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
@abayer
Copy link

abayer commented Jan 30, 2020

@bigkevmcd Sorry to bug you, but have you actually tested the PR creation on gitlab? I have a sinking feeling it won't do anything -

func (c *wrapper) do(ctx context.Context, method, path string, in, out interface{}) (*scm.Response, error) {
doesn't actually pass in to the request, which...yeah, that'll be a problem. =) I'll play around with it on #68, where I'm adding updating PRs, but I think we need to do something more like
in.Set("title", input.Title)
in.Set("description", input.Body)
path := fmt.Sprintf("api/v4/projects/%s/issues?%s", encode(repo), in.Encode())
.

I'm legitimately not sure why we're encoding as parameters rather than just passing as data with application/json in general for Gitlab, but if that works, it's fine by me. =)

@bigkevmcd
Copy link
Author

bigkevmcd commented Feb 3, 2020

@abayer sorry, I was travelling last week.

I tested the GitHub version, but alas, I didn't test the GitLab one, and naively assumed that the tests would cover it, dunno why I didn't test it given that it was a 2 line change to run the code against GitLab, and yes, it responds with a 400.

I'm happy to rework the implementation to convert to JSON, which is what it should be doing, yes.

@abayer
Copy link

abayer commented Feb 3, 2020

No worries! I'm traveling this week, so my responses won't be timely either. =) I've started reworking the gl web hook stuff completely - no rush on the GL api side from my perspective. It feels like a lot of the GL code was copied loosely from somewhere else without fully implementing everything, let alone testing it, so I don't expect this is gonna be speedy.

@abayer
Copy link

abayer commented Feb 3, 2020

Oh, and at least it's not BitBucket. Sigh.

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

Successfully merging this pull request may close these issues.

4 participants