From 9a0c94475b208518a183bc1102af405e447175c6 Mon Sep 17 00:00:00 2001 From: shahabhijeet Date: Tue, 19 Feb 2019 22:54:01 -0800 Subject: [PATCH 1/2] adding example for creating PR from fork --- docs/demos/exploring-pull-requests.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/demos/exploring-pull-requests.md b/docs/demos/exploring-pull-requests.md index 231cfe929b..b6db64e195 100644 --- a/docs/demos/exploring-pull-requests.md +++ b/docs/demos/exploring-pull-requests.md @@ -1,3 +1,25 @@ +### Creating new pull request from a fork +```csharp +public void CreatePR() +{ + /* + Scenario: Creating a pull request from a fork/branch (head) and merging into octokit.net/master (base) + When you are opening a PR against a repository within an organization, owner is the name of the organization + In this scenario as we are merging to octokit/octokit.net:master, owner=octokit + */ + + GitHubClient ghClient = new GitHubClient(new ProductHeaderValue("MyLib", "v2.0.0")); + ghClient.Credentials = new Credentials("apiToken"); + + NewPullRequest newPr = new NewPullRequest("PrTitle", "forkName:branchName", "master"); + Repository octokitRepo = ghClient.Repository.Get("octokit", "ocktokit.net").GetAwaiter().GetResult(); + + PullRequest pr = ghClient.PullRequest.Create("octokit", "octokit.net", newPr).GetAwaiter().GetResult(); + //Or + PullRequest alternatePr = ghClient.PullRequest.Create(octokitRepo.Id, newPr).GetAwaiter().GetResult(); +} +``` + **Scenario:** I have a lot of small pull requests to review, but things are a mess - old pull requests which might be superseded by new ones, and it's hard to see from the descriptions what the changes actually represent. From 96324913dae2d6beb30695b5f3968785ff23c3ba Mon Sep 17 00:00:00 2001 From: shahabhijeet Date: Wed, 20 Feb 2019 11:21:10 -0800 Subject: [PATCH 2/2] addressing pr feedback --- docs/demos/exploring-pull-requests.md | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/docs/demos/exploring-pull-requests.md b/docs/demos/exploring-pull-requests.md index b6db64e195..577cae3318 100644 --- a/docs/demos/exploring-pull-requests.md +++ b/docs/demos/exploring-pull-requests.md @@ -1,22 +1,21 @@ ### Creating new pull request from a fork +**Scenario:** +Creating a pull request from a fork/branch (head) and pulling into octokit.net/master (base) +When you are opening a PR against a repository within an organization, owner is the name of the organization +In this scenario as we are merging to octokit/octokit.net:master, owner=octokit + ```csharp -public void CreatePR() -{ - /* - Scenario: Creating a pull request from a fork/branch (head) and merging into octokit.net/master (base) - When you are opening a PR against a repository within an organization, owner is the name of the organization - In this scenario as we are merging to octokit/octokit.net:master, owner=octokit - */ - +public async Task CreatePullRequestFromFork() +{ GitHubClient ghClient = new GitHubClient(new ProductHeaderValue("MyLib", "v2.0.0")); ghClient.Credentials = new Credentials("apiToken"); NewPullRequest newPr = new NewPullRequest("PrTitle", "forkName:branchName", "master"); - Repository octokitRepo = ghClient.Repository.Get("octokit", "ocktokit.net").GetAwaiter().GetResult(); + var octokitRepo = await ghClient.Repository.Get("octokit", "ocktokit.net"); - PullRequest pr = ghClient.PullRequest.Create("octokit", "octokit.net", newPr).GetAwaiter().GetResult(); - //Or - PullRequest alternatePr = ghClient.PullRequest.Create(octokitRepo.Id, newPr).GetAwaiter().GetResult(); + var pullRequest = await ghClient.PullRequest.Create("octokit", "octokit.net", newPr); + // Or + var alternatePr = await ghClient.PullRequest.Create(octokitRepo.Id, newPr); } ```