{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/wcf/pulls/comments/58727055","id":58727055,"diff_hunk":"@@ -0,0 +1,217 @@\n+ // Copyright (c) Microsoft. All rights reserved.\n+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.\n+ \n+<%@ WebHandler Language=\"C#\" Class=\"PullRequestHandler\" %>\n+\n+// This script is called to prepare a local repo for testing\n+// ASSUMES: \n+//   - Git is installed on the system to \"C:\\Program Files\\Git\\bin\\git.exe\"\n+//   - IIS web site points to this script\n+//   - This script is committed to ./src/System.Private.ServiceModel/tools/PRService\n+//   - \n+//   - The Git repo is set up as follows: \n+//     [remote \"origin\"]\n+//\t       url = https://github.com/dotnet/wcf\n+//\t       fetch = +refs/heads/*:refs/remotes/origin/*\n+//\t       fetch = +refs/pull/*/head:refs/remotes/origin/pr/*      <-- allows us to run git checkout pr/{id} \n+\n+using System;\n+using System.Collections.Generic;\n+using System.Diagnostics;\n+using System.Web;\n+using System.IO;\n+using System.Text;\n+using System.Text.RegularExpressions;\n+using System.Web;\n+\n+public class PullRequestHandler : IHttpHandler\n+{\n+    private const string _gitExecutablePath = @\"C:\\Program Files\\Git\\bin\\git.exe\";\n+    private static string _gitRepoPath;\n+    private const int _gitExecutionTimeoutMilliseconds = 100000;\n+\n+    public void ProcessRequest(HttpContext context)\n+    {\n+        _gitRepoPath = context.Request.PhysicalApplicationPath + \"..\\\\..\\\\..\\\\..\";\n+        string prString = context.Request.QueryString[\"pr\"];\n+\n+        context.Response.Write(string.Format(\"PR = {0}<br/>\", HttpUtility.HtmlEncode(prString) ?? \"Unspecified\"));\n+\n+        StringBuilder result = new StringBuilder();\n+\n+        bool success = CheckPrerequisites(result);\n+\n+        if (success) \n+        {\n+            success = CleanupMergedBranches(result); \n+        }\n+\n+        if (success)\n+        {\n+            // Check inputs to the script\n+            uint pr;\n+            if (!string.IsNullOrEmpty(prString) && uint.TryParse(prString, out pr))\n+            {\n+                success = SyncToPr(pr, result);\n+            }\n+            else\n+            {\n+                context.Response.Write(string.Format(\"Invalid PR ID specified<br/>\"));\n+                success = false;\n+            }\n+        } \n+        \n+        if (!success)\n+        {\n+            context.Response.StatusCode = 400;\n+        }\n+\n+        if (context.Request.IsLocal)\n+        {\n+            // Don't allow error results to leak to non-local machines","path":"src/System.Private.ServiceModel/tools/PRService/pr.ashx","position":71,"original_position":71,"commit_id":"a62a3a52f966470c7924cd80838ca8511171d624","original_commit_id":"a62a3a52f966470c7924cd80838ca8511171d624","user":{"login":"roncain","id":3913124,"avatar_url":"https://avatars.githubusercontent.com/u/3913124?v=3","gravatar_id":"","url":"https://api.github.com/users/roncain","html_url":"https://github.com/roncain","followers_url":"https://api.github.com/users/roncain/followers","following_url":"https://api.github.com/users/roncain/following{/other_user}","gists_url":"https://api.github.com/users/roncain/gists{/gist_id}","starred_url":"https://api.github.com/users/roncain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roncain/subscriptions","organizations_url":"https://api.github.com/users/roncain/orgs","repos_url":"https://api.github.com/users/roncain/repos","events_url":"https://api.github.com/users/roncain/events{/privacy}","received_events_url":"https://api.github.com/users/roncain/received_events","type":"User","site_admin":false},"body":"Personally I'd prefer to spew everything that went wrong and find a way to protect the PRService from being used by anything other than the CI Jobs, especially while we're kicking the tires on it.  But the securing of PRService can wait till we need it.","created_at":"2016-04-06T15:32:46Z","updated_at":"2016-04-06T15:32:46Z","html_url":"https://github.com/dotnet/wcf/pull/981#discussion_r58727055","pull_request_url":"https://api.github.com/repos/dotnet/wcf/pulls/981","_links":{"self":{"href":"https://api.github.com/repos/dotnet/wcf/pulls/comments/58727055"},"html":{"href":"https://github.com/dotnet/wcf/pull/981#discussion_r58727055"},"pull_request":{"href":"https://api.github.com/repos/dotnet/wcf/pulls/981"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/wcf/pulls/981","id":65291276,"html_url":"https://github.com/dotnet/wcf/pull/981","diff_url":"https://github.com/dotnet/wcf/pull/981.diff","patch_url":"https://github.com/dotnet/wcf/pull/981.patch","issue_url":"https://api.github.com/repos/dotnet/wcf/issues/981","number":981,"state":"open","locked":false,"title":"Add pull request service for test infrastructure","user":{"login":"iamjasonp","id":1616847,"avatar_url":"https://avatars.githubusercontent.com/u/1616847?v=3","gravatar_id":"","url":"https://api.github.com/users/iamjasonp","html_url":"https://github.com/iamjasonp","followers_url":"https://api.github.com/users/iamjasonp/followers","following_url":"https://api.github.com/users/iamjasonp/following{/other_user}","gists_url":"https://api.github.com/users/iamjasonp/gists{/gist_id}","starred_url":"https://api.github.com/users/iamjasonp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iamjasonp/subscriptions","organizations_url":"https://api.github.com/users/iamjasonp/orgs","repos_url":"https://api.github.com/users/iamjasonp/repos","events_url":"https://api.github.com/users/iamjasonp/events{/privacy}","received_events_url":"https://api.github.com/users/iamjasonp/received_events","type":"User","site_admin":false},"body":"skip ci please","created_at":"2016-04-05T11:51:10Z","updated_at":"2016-04-06T15:32:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"52979f4a045f99d6cae569c4132c8abf6355675c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/wcf/pulls/981/commits","review_comments_url":"https://api.github.com/repos/dotnet/wcf/pulls/981/comments","review_comment_url":"https://api.github.com/repos/dotnet/wcf/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/wcf/issues/981/comments","statuses_url":"https://api.github.com/repos/dotnet/wcf/statuses/a62a3a52f966470c7924cd80838ca8511171d624","head":{"label":"iamjasonp:prservice","ref":"prservice","sha":"a62a3a52f966470c7924cd80838ca8511171d624","user":{"login":"iamjasonp","id":1616847,"avatar_url":"https://avatars.githubusercontent.com/u/1616847?v=3","gravatar_id":"","url":"https://api.github.com/users/iamjasonp","html_url":"https://github.com/iamjasonp","followers_url":"https://api.github.com/users/iamjasonp/followers","following_url":"https://api.github.com/users/iamjasonp/following{/other_user}","gists_url":"https://api.github.com/users/iamjasonp/gists{/gist_id}","starred_url":"https://api.github.com/users/iamjasonp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iamjasonp/subscriptions","organizations_url":"https://api.github.com/users/iamjasonp/orgs","repos_url":"https://api.github.com/users/iamjasonp/repos","events_url":"https://api.github.com/users/iamjasonp/events{/privacy}","received_events_url":"https://api.github.com/users/iamjasonp/received_events","type":"User","site_admin":false},"repo":{"id":35954677,"name":"wcf","full_name":"iamjasonp/wcf","owner":{"login":"iamjasonp","id":1616847,"avatar_url":"https://avatars.githubusercontent.com/u/1616847?v=3","gravatar_id":"","url":"https://api.github.com/users/iamjasonp","html_url":"https://github.com/iamjasonp","followers_url":"https://api.github.com/users/iamjasonp/followers","following_url":"https://api.github.com/users/iamjasonp/following{/other_user}","gists_url":"https://api.github.com/users/iamjasonp/gists{/gist_id}","starred_url":"https://api.github.com/users/iamjasonp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iamjasonp/subscriptions","organizations_url":"https://api.github.com/users/iamjasonp/orgs","repos_url":"https://api.github.com/users/iamjasonp/repos","events_url":"https://api.github.com/users/iamjasonp/events{/privacy}","received_events_url":"https://api.github.com/users/iamjasonp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/iamjasonp/wcf","description":"This repo contains the client-oriented WCF libraries that enable applications built on .NET Core to communicate with WCF services.","fork":true,"url":"https://api.github.com/repos/iamjasonp/wcf","forks_url":"https://api.github.com/repos/iamjasonp/wcf/forks","keys_url":"https://api.github.com/repos/iamjasonp/wcf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iamjasonp/wcf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iamjasonp/wcf/teams","hooks_url":"https://api.github.com/repos/iamjasonp/wcf/hooks","issue_events_url":"https://api.github.com/repos/iamjasonp/wcf/issues/events{/number}","events_url":"https://api.github.com/repos/iamjasonp/wcf/events","assignees_url":"https://api.github.com/repos/iamjasonp/wcf/assignees{/user}","branches_url":"https://api.github.com/repos/iamjasonp/wcf/branches{/branch}","tags_url":"https://api.github.com/repos/iamjasonp/wcf/tags","blobs_url":"https://api.github.com/repos/iamjasonp/wcf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iamjasonp/wcf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iamjasonp/wcf/git/refs{/sha}","trees_url":"https://api.github.com/repos/iamjasonp/wcf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iamjasonp/wcf/statuses/{sha}","languages_url":"https://api.github.com/repos/iamjasonp/wcf/languages","stargazers_url":"https://api.github.com/repos/iamjasonp/wcf/stargazers","contributors_url":"https://api.github.com/repos/iamjasonp/wcf/contributors","subscribers_url":"https://api.github.com/repos/iamjasonp/wcf/subscribers","subscription_url":"https://api.github.com/repos/iamjasonp/wcf/subscription","commits_url":"https://api.github.com/repos/iamjasonp/wcf/commits{/sha}","git_commits_url":"https://api.github.com/repos/iamjasonp/wcf/git/commits{/sha}","comments_url":"https://api.github.com/repos/iamjasonp/wcf/comments{/number}","issue_comment_url":"https://api.github.com/repos/iamjasonp/wcf/issues/comments{/number}","contents_url":"https://api.github.com/repos/iamjasonp/wcf/contents/{+path}","compare_url":"https://api.github.com/repos/iamjasonp/wcf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iamjasonp/wcf/merges","archive_url":"https://api.github.com/repos/iamjasonp/wcf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iamjasonp/wcf/downloads","issues_url":"https://api.github.com/repos/iamjasonp/wcf/issues{/number}","pulls_url":"https://api.github.com/repos/iamjasonp/wcf/pulls{/number}","milestones_url":"https://api.github.com/repos/iamjasonp/wcf/milestones{/number}","notifications_url":"https://api.github.com/repos/iamjasonp/wcf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iamjasonp/wcf/labels{/name}","releases_url":"https://api.github.com/repos/iamjasonp/wcf/releases{/id}","deployments_url":"https://api.github.com/repos/iamjasonp/wcf/deployments","created_at":"2015-05-20T14:54:42Z","updated_at":"2016-01-26T19:54:29Z","pushed_at":"2016-04-06T09:00:18Z","git_url":"git://github.com/iamjasonp/wcf.git","ssh_url":"git@github.com:iamjasonp/wcf.git","clone_url":"https://github.com/iamjasonp/wcf.git","svn_url":"https://github.com/iamjasonp/wcf","homepage":"","size":5192,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"2f7f055a1d9dc6b13ba0405f1dece0fa68931b26","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":35562993,"name":"wcf","full_name":"dotnet/wcf","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/wcf","description":"This repo contains the client-oriented WCF libraries that enable applications built on .NET Core to communicate with WCF services.","fork":false,"url":"https://api.github.com/repos/dotnet/wcf","forks_url":"https://api.github.com/repos/dotnet/wcf/forks","keys_url":"https://api.github.com/repos/dotnet/wcf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/wcf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/wcf/teams","hooks_url":"https://api.github.com/repos/dotnet/wcf/hooks","issue_events_url":"https://api.github.com/repos/dotnet/wcf/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/wcf/events","assignees_url":"https://api.github.com/repos/dotnet/wcf/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/wcf/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/wcf/tags","blobs_url":"https://api.github.com/repos/dotnet/wcf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/wcf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/wcf/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/wcf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/wcf/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/wcf/languages","stargazers_url":"https://api.github.com/repos/dotnet/wcf/stargazers","contributors_url":"https://api.github.com/repos/dotnet/wcf/contributors","subscribers_url":"https://api.github.com/repos/dotnet/wcf/subscribers","subscription_url":"https://api.github.com/repos/dotnet/wcf/subscription","commits_url":"https://api.github.com/repos/dotnet/wcf/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/wcf/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/wcf/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/wcf/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/wcf/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/wcf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/wcf/merges","archive_url":"https://api.github.com/repos/dotnet/wcf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/wcf/downloads","issues_url":"https://api.github.com/repos/dotnet/wcf/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/wcf/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/wcf/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/wcf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/wcf/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/wcf/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/wcf/deployments","created_at":"2015-05-13T17:17:03Z","updated_at":"2016-04-06T05:00:58Z","pushed_at":"2016-04-06T15:25:49Z","git_url":"git://github.com/dotnet/wcf.git","ssh_url":"git@github.com:dotnet/wcf.git","clone_url":"https://github.com/dotnet/wcf.git","svn_url":"https://github.com/dotnet/wcf","homepage":"","size":6340,"stargazers_count":593,"watchers_count":593,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":200,"mirror_url":null,"open_issues_count":146,"forks":200,"open_issues":146,"watchers":593,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/wcf/pulls/981"},"html":{"href":"https://github.com/dotnet/wcf/pull/981"},"issue":{"href":"https://api.github.com/repos/dotnet/wcf/issues/981"},"comments":{"href":"https://api.github.com/repos/dotnet/wcf/issues/981/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/wcf/pulls/981/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/wcf/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/wcf/pulls/981/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/wcf/statuses/a62a3a52f966470c7924cd80838ca8511171d624"}}}}