diff --git a/README.md b/README.md index 00b9566..85a76e8 100644 --- a/README.md +++ b/README.md @@ -84,8 +84,6 @@ https://github.com/settings/tokens/new?scopes=repo ## Todos -- **Editing files** based on current content - Add support to pass a function as file content, the function will be called with the current file content, if present. - **Multiple commits** Split up changes among multiple edits diff --git a/src/create-pull-request.ts b/src/create-pull-request.ts index 665723e..c9991ae 100644 --- a/src/create-pull-request.ts +++ b/src/create-pull-request.ts @@ -15,7 +15,7 @@ type Options = { type Changes = { files: { - [path: string]: string | File; + [path: string]: string | File | UpdateFunction; }; commit: string; }; @@ -26,6 +26,14 @@ type File = { encoding: "utf-8" | "base64"; }; +type UpdateFunctionFile = { + size: number; + encoding: "base64"; + content: string; +}; + +type UpdateFunction = (file: UpdateFunctionFile) => string | File; + export async function octokitCreatePullRequest( octokit: Octokit, { owner, repo, title, body, base, head, changes }: Options @@ -113,31 +121,24 @@ export async function octokitCreatePullRequest( } } - // Text files can be changed through the .content key - if (typeof value === "string") { - return { - path, - mode: "100644", - content: value, - }; + // When passed a function, retrieve the content of the file, pass it + // to the function, then return the result + if (typeof value === "function") { + const { data: file } = await octokit.request( + "GET /repos/:owner/:repo/contents/:path", + { + owner: fork, + repo, + ref: firstCommit.sha, + path, + } + ); + + const result = await value(file as UpdateFunctionFile); + return valueToTreeObject(octokit, owner, repo, path, result); } - // Binary files need to be created first using the git blob API, - // then changed by referencing in the .sha key - const { data } = await octokit.request( - "POST /repos/:owner/:repo/git/blobs", - { - owner, - repo, - ...value, - } - ); - const blobSha = data.sha; - return { - path, - mode: "100644", - sha: blobSha, - }; + return valueToTreeObject(octokit, owner, repo, path, value); }) ) ).filter(Boolean) as TreeParameter; @@ -181,3 +182,34 @@ export async function octokitCreatePullRequest( body, }); } + +async function valueToTreeObject( + octokit: Octokit, + owner: string, + repo: string, + path: string, + value: string | File +) { + // Text files can be changed through the .content key + if (typeof value === "string") { + return { + path, + mode: "100644", + content: value, + }; + } + + // Binary files need to be created first using the git blob API, + // then changed by referencing in the .sha key + const { data } = await octokit.request("POST /repos/:owner/:repo/git/blobs", { + owner, + repo, + ...value, + }); + const blobSha = data.sha; + return { + path, + mode: "100644", + sha: blobSha, + }; +} diff --git a/test/create-binary-file.test.ts b/test/create-binary-file.test.ts index cc9dfa5..dfb47c1 100644 --- a/test/create-binary-file.test.ts +++ b/test/create-binary-file.test.ts @@ -4,7 +4,7 @@ import { RequestError } from "@octokit/request-error"; import { createPullRequest } from "../src"; const Octokit = Core.plugin(createPullRequest); -test("happy path", async () => { +test("create binary file", async () => { const fixtures = require("./fixtures/create-binary-file"); const fixturePr = fixtures[fixtures.length - 1].response; const octokit = new Octokit(); diff --git a/test/delete-files.test.ts b/test/delete-files.test.ts index 844ed99..7b27e4f 100644 --- a/test/delete-files.test.ts +++ b/test/delete-files.test.ts @@ -4,7 +4,7 @@ import { RequestError } from "@octokit/request-error"; import { createPullRequest } from "../src"; const Octokit = Core.plugin(createPullRequest); -test("happy path", async () => { +test("delete files", async () => { const fixtures = require("./fixtures/delete-files"); const fixturePr = fixtures[fixtures.length - 1].response; const octokit = new Octokit(); diff --git a/test/fixtures/update-readme.json b/test/fixtures/update-readme.json new file mode 100644 index 0000000..51b4475 --- /dev/null +++ b/test/fixtures/update-readme.json @@ -0,0 +1,970 @@ +[ + { + "request": { + "method": "GET", + "baseUrl": "https://api.github.com", + "headers": { + "accept": "application/vnd.github.v3+json", + "user-agent": "octokit-core.js/3.0.0 Node.js/14.3.0 (macOS Catalina; x64)" + }, + "mediaType": { + "format": "", + "previews": [] + }, + "request": {}, + "url": "/repos/:owner/:repo", + "owner": "gr2m", + "repo": "pull-request-test" + }, + "response": { + "status": 200, + "url": "https://api.github.com/repos/gr2m/pull-request-test", + "headers": { + "access-control-allow-origin": "*", + "access-control-expose-headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset", + "cache-control": "private, max-age=60, s-maxage=60", + "connection": "close", + "content-encoding": "gzip", + "content-security-policy": "default-src 'none'", + "content-type": "application/json; charset=utf-8", + "date": "Tue, 16 Jun 2020 18:09:51 GMT", + "etag": "W/\"37c65f62850bcaed0b20068aef322429\"", + "last-modified": "Mon, 28 Jan 2019 17:23:18 GMT", + "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "server": "GitHub.com", + "status": "200 OK", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "transfer-encoding": "chunked", + "vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With, Accept-Encoding", + "x-accepted-oauth-scopes": "repo", + "x-content-type-options": "nosniff", + "x-frame-options": "deny", + "x-github-media-type": "github.v3; format=json", + "x-github-request-id": "CB3E:71D3:B2AC5:D9BB1:5EE90AEF", + "x-oauth-scopes": "repo", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4923", + "x-ratelimit-reset": "1592333500", + "x-xss-protection": "1; mode=block" + }, + "data": { + "id": 160987492, + "node_id": "MDEwOlJlcG9zaXRvcnkxNjA5ODc0OTI=", + "name": "pull-request-test", + "full_name": "gr2m/pull-request-test", + "private": false, + "owner": { + "login": "gr2m", + "id": 39992, + "node_id": "MDQ6VXNlcjM5OTky", + "avatar_url": "https://avatars3.githubusercontent.com/u/39992?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/gr2m", + "html_url": "https://github.com/gr2m", + "followers_url": "https://api.github.com/users/gr2m/followers", + "following_url": "https://api.github.com/users/gr2m/following{/other_user}", + "gists_url": "https://api.github.com/users/gr2m/gists{/gist_id}", + "starred_url": "https://api.github.com/users/gr2m/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/gr2m/subscriptions", + "organizations_url": "https://api.github.com/users/gr2m/orgs", + "repos_url": "https://api.github.com/users/gr2m/repos", + "events_url": "https://api.github.com/users/gr2m/events{/privacy}", + "received_events_url": "https://api.github.com/users/gr2m/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/gr2m/pull-request-test", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/gr2m/pull-request-test", + "forks_url": "https://api.github.com/repos/gr2m/pull-request-test/forks", + "keys_url": "https://api.github.com/repos/gr2m/pull-request-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/gr2m/pull-request-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/gr2m/pull-request-test/teams", + "hooks_url": "https://api.github.com/repos/gr2m/pull-request-test/hooks", + "issue_events_url": "https://api.github.com/repos/gr2m/pull-request-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/gr2m/pull-request-test/events", + "assignees_url": "https://api.github.com/repos/gr2m/pull-request-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/gr2m/pull-request-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/gr2m/pull-request-test/tags", + "blobs_url": "https://api.github.com/repos/gr2m/pull-request-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/gr2m/pull-request-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/gr2m/pull-request-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/gr2m/pull-request-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/gr2m/pull-request-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/gr2m/pull-request-test/languages", + "stargazers_url": "https://api.github.com/repos/gr2m/pull-request-test/stargazers", + "contributors_url": "https://api.github.com/repos/gr2m/pull-request-test/contributors", + "subscribers_url": "https://api.github.com/repos/gr2m/pull-request-test/subscribers", + "subscription_url": "https://api.github.com/repos/gr2m/pull-request-test/subscription", + "commits_url": "https://api.github.com/repos/gr2m/pull-request-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/gr2m/pull-request-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/gr2m/pull-request-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/gr2m/pull-request-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/gr2m/pull-request-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/gr2m/pull-request-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/gr2m/pull-request-test/merges", + "archive_url": "https://api.github.com/repos/gr2m/pull-request-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/gr2m/pull-request-test/downloads", + "issues_url": "https://api.github.com/repos/gr2m/pull-request-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/gr2m/pull-request-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/gr2m/pull-request-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/gr2m/pull-request-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/gr2m/pull-request-test/labels{/name}", + "releases_url": "https://api.github.com/repos/gr2m/pull-request-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/gr2m/pull-request-test/deployments", + "created_at": "2018-12-08T23:26:26Z", + "updated_at": "2019-01-28T17:23:18Z", + "pushed_at": "2020-06-16T18:09:24Z", + "git_url": "git://github.com/gr2m/pull-request-test.git", + "ssh_url": "git@github.com:gr2m/pull-request-test.git", + "clone_url": "https://github.com/gr2m/pull-request-test.git", + "svn_url": "https://github.com/gr2m/pull-request-test", + "homepage": null, + "size": 229, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": false, + "has_projects": false, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "forks_count": 1, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 1, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "temp_clone_token": "", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "delete_branch_on_merge": false, + "network_count": 1, + "subscribers_count": 0 + } + } + }, + { + "request": { + "method": "GET", + "baseUrl": "https://api.github.com", + "headers": { + "accept": "application/vnd.github.v3+json", + "user-agent": "octokit-core.js/3.0.0 Node.js/14.3.0 (macOS Catalina; x64)" + }, + "mediaType": { + "format": "", + "previews": [] + }, + "request": {}, + "url": "/repos/:owner/:repo/commits", + "owner": "gr2m", + "repo": "pull-request-test", + "sha": "master", + "per_page": 1 + }, + "response": { + "status": 200, + "url": "https://api.github.com/repos/gr2m/pull-request-test/commits?sha=master&per_page=1", + "headers": { + "access-control-allow-origin": "*", + "access-control-expose-headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset", + "cache-control": "private, max-age=60, s-maxage=60", + "connection": "close", + "content-encoding": "gzip", + "content-security-policy": "default-src 'none'", + "content-type": "application/json; charset=utf-8", + "date": "Tue, 16 Jun 2020 18:09:52 GMT", + "etag": "W/\"4d7d45b8c5d414615ddbb66bec5159b4\"", + "last-modified": "Mon, 28 Jan 2019 17:23:16 GMT", + "link": "; rel=\"next\", ; rel=\"last\"", + "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "server": "GitHub.com", + "status": "200 OK", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "transfer-encoding": "chunked", + "vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With, Accept-Encoding", + "x-accepted-oauth-scopes": "", + "x-content-type-options": "nosniff", + "x-frame-options": "deny", + "x-github-media-type": "github.v3; format=json", + "x-github-request-id": "CB3F:1FFB:A153BE:C108FF:5EE90AF0", + "x-oauth-scopes": "repo", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4922", + "x-ratelimit-reset": "1592333501", + "x-xss-protection": "1; mode=block" + }, + "data": [ + { + "sha": "3b6c2a2df60769aa026013f5bc1649cc004bd925", + "node_id": "MDY6Q29tbWl0MTYwOTg3NDkyOjNiNmMyYTJkZjYwNzY5YWEwMjYwMTNmNWJjMTY0OWNjMDA0YmQ5MjU=", + "commit": { + "author": { + "name": "Gregor Martynus", + "email": "gregor@martynus.net", + "date": "2019-01-28T17:23:16Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2019-01-28T17:23:16Z" + }, + "message": "Delete file3.txt", + "tree": { + "sha": "fb00ef8a5edaf5cae464878939b413004407b9e4", + "url": "https://api.github.com/repos/gr2m/pull-request-test/git/trees/fb00ef8a5edaf5cae464878939b413004407b9e4" + }, + "url": "https://api.github.com/repos/gr2m/pull-request-test/git/commits/3b6c2a2df60769aa026013f5bc1649cc004bd925", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJcTzqECRBK7hj4Ov3rIwAAdHIIAFUzX7EFHp8G4gTI1ejBL3g0\nsDcdDhpfsS82QGCZ4N5sKifqWflZg0pU+1gEQxzaoh1uISLZ/NuFj5Jl9aw8wmrU\nQlkpwOKoLJgoCeygZAfU1hgiz4RLzeKc4J4QcEB56PpFdy10StEwVcgqvmGDxEzy\nYdYwKBLfDahIgE+AIPVWfgIGm+Ti/pZdA71BNgWa5ABEqTsBZ6Be2rBCsXV+WcV3\nZKgKo/HVfFORqzp7s4XhQpkiwsQHb68U6fDyalINTVHyKz8akXjkXQvHDKhQmxR6\nuxczLZlnlT3wsHw8qoomGid6cYiOxG9awFIVEzl4mCaunVuhUlEf0BACA9nF1rw=\n=vp8W\n-----END PGP SIGNATURE-----\n", + "payload": "tree fb00ef8a5edaf5cae464878939b413004407b9e4\nparent 520063648488c9c2eb94d820c9017fd7e8b5a1c4\nauthor Gregor Martynus 1548696196 -0800\ncommitter GitHub 1548696196 -0800\n\nDelete file3.txt" + } + }, + "url": "https://api.github.com/repos/gr2m/pull-request-test/commits/3b6c2a2df60769aa026013f5bc1649cc004bd925", + "html_url": "https://github.com/gr2m/pull-request-test/commit/3b6c2a2df60769aa026013f5bc1649cc004bd925", + "comments_url": "https://api.github.com/repos/gr2m/pull-request-test/commits/3b6c2a2df60769aa026013f5bc1649cc004bd925/comments", + "author": { + "login": "gr2m", + "id": 39992, + "node_id": "MDQ6VXNlcjM5OTky", + "avatar_url": "https://avatars3.githubusercontent.com/u/39992?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/gr2m", + "html_url": "https://github.com/gr2m", + "followers_url": "https://api.github.com/users/gr2m/followers", + "following_url": "https://api.github.com/users/gr2m/following{/other_user}", + "gists_url": "https://api.github.com/users/gr2m/gists{/gist_id}", + "starred_url": "https://api.github.com/users/gr2m/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/gr2m/subscriptions", + "organizations_url": "https://api.github.com/users/gr2m/orgs", + "repos_url": "https://api.github.com/users/gr2m/repos", + "events_url": "https://api.github.com/users/gr2m/events{/privacy}", + "received_events_url": "https://api.github.com/users/gr2m/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/web-flow", + "html_url": "https://github.com/web-flow", + "followers_url": "https://api.github.com/users/web-flow/followers", + "following_url": "https://api.github.com/users/web-flow/following{/other_user}", + "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", + "organizations_url": "https://api.github.com/users/web-flow/orgs", + "repos_url": "https://api.github.com/users/web-flow/repos", + "events_url": "https://api.github.com/users/web-flow/events{/privacy}", + "received_events_url": "https://api.github.com/users/web-flow/received_events", + "type": "User", + "site_admin": false + }, + "parents": [ + { + "sha": "520063648488c9c2eb94d820c9017fd7e8b5a1c4", + "url": "https://api.github.com/repos/gr2m/pull-request-test/commits/520063648488c9c2eb94d820c9017fd7e8b5a1c4", + "html_url": "https://github.com/gr2m/pull-request-test/commit/520063648488c9c2eb94d820c9017fd7e8b5a1c4" + } + ] + } + ] + } + }, + { + "request": { + "method": "GET", + "baseUrl": "https://api.github.com", + "headers": { + "accept": "application/vnd.github.v3+json", + "user-agent": "octokit-core.js/3.0.0 Node.js/14.3.0 (macOS Catalina; x64)" + }, + "mediaType": { + "format": "", + "previews": [] + }, + "request": {}, + "url": "/repos/:owner/:repo/contents/:path", + "owner": "gr2m", + "repo": "pull-request-test", + "ref": "3b6c2a2df60769aa026013f5bc1649cc004bd925", + "path": "README.md" + }, + "response": { + "status": 200, + "url": "https://api.github.com/repos/gr2m/pull-request-test/contents/README.md?ref=3b6c2a2df60769aa026013f5bc1649cc004bd925", + "headers": { + "access-control-allow-origin": "*", + "access-control-expose-headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset", + "cache-control": "private, max-age=60, s-maxage=60", + "connection": "close", + "content-encoding": "gzip", + "content-security-policy": "default-src 'none'", + "content-type": "application/json; charset=utf-8", + "date": "Tue, 16 Jun 2020 18:09:53 GMT", + "etag": "W/\"9e7a7ca5b0bcf466c6d2e8e5a8ea61e7307f62d1\"", + "last-modified": "Mon, 28 Jan 2019 17:23:16 GMT", + "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "server": "GitHub.com", + "status": "200 OK", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "transfer-encoding": "chunked", + "vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With, Accept-Encoding", + "x-accepted-oauth-scopes": "", + "x-content-type-options": "nosniff", + "x-frame-options": "deny", + "x-github-media-type": "github.v3; format=json", + "x-github-request-id": "CB40:71DA:546E3C:64D482:5EE90AF1", + "x-oauth-scopes": "repo", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4921", + "x-ratelimit-reset": "1592333501", + "x-xss-protection": "1; mode=block" + }, + "data": { + "name": "README.md", + "path": "README.md", + "sha": "9e7a7ca5b0bcf466c6d2e8e5a8ea61e7307f62d1", + "size": 19, + "url": "https://api.github.com/repos/gr2m/pull-request-test/contents/README.md?ref=3b6c2a2df60769aa026013f5bc1649cc004bd925", + "html_url": "https://github.com/gr2m/pull-request-test/blob/3b6c2a2df60769aa026013f5bc1649cc004bd925/README.md", + "git_url": "https://api.github.com/repos/gr2m/pull-request-test/git/blobs/9e7a7ca5b0bcf466c6d2e8e5a8ea61e7307f62d1", + "download_url": "https://raw.githubusercontent.com/gr2m/pull-request-test/3b6c2a2df60769aa026013f5bc1649cc004bd925/README.md", + "type": "file", + "content": "IyBwdWxsLXJlcXVlc3QtdGVzdA==\n", + "encoding": "base64", + "_links": { + "self": "https://api.github.com/repos/gr2m/pull-request-test/contents/README.md?ref=3b6c2a2df60769aa026013f5bc1649cc004bd925", + "git": "https://api.github.com/repos/gr2m/pull-request-test/git/blobs/9e7a7ca5b0bcf466c6d2e8e5a8ea61e7307f62d1", + "html": "https://github.com/gr2m/pull-request-test/blob/3b6c2a2df60769aa026013f5bc1649cc004bd925/README.md" + } + } + } + }, + { + "request": { + "method": "POST", + "baseUrl": "https://api.github.com", + "headers": { + "accept": "application/vnd.github.v3+json", + "user-agent": "octokit-core.js/3.0.0 Node.js/14.3.0 (macOS Catalina; x64)" + }, + "mediaType": { + "format": "", + "previews": [] + }, + "request": {}, + "url": "/repos/:owner/:repo/git/trees", + "owner": "gr2m", + "repo": "pull-request-test", + "base_tree": "fb00ef8a5edaf5cae464878939b413004407b9e4", + "tree": [ + { + "path": "README.md", + "mode": "100644", + "content": "# PULL-REQUEST-TEST" + } + ] + }, + "response": { + "status": 201, + "url": "https://api.github.com/repos/gr2m/pull-request-test/git/trees", + "headers": { + "access-control-allow-origin": "*", + "access-control-expose-headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset", + "cache-control": "private, max-age=60, s-maxage=60", + "connection": "close", + "content-length": "615", + "content-security-policy": "default-src 'none'", + "content-type": "application/json; charset=utf-8", + "date": "Tue, 16 Jun 2020 18:09:55 GMT", + "etag": "\"8d114af9a2b30267d08c88de0639ac1c\"", + "location": "https://api.github.com/repos/gr2m/pull-request-test/git/trees/74e8a6137ddcf84a3c287235dadf04a98e4173d8", + "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "server": "GitHub.com", + "status": "201 Created", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With, Accept-Encoding", + "x-accepted-oauth-scopes": "", + "x-content-type-options": "nosniff", + "x-frame-options": "deny", + "x-github-media-type": "github.v3; format=json", + "x-github-request-id": "CB41:627B:A4BEF1:C555DF:5EE90AF2", + "x-oauth-scopes": "repo", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4920", + "x-ratelimit-reset": "1592333501", + "x-xss-protection": "1; mode=block" + }, + "data": { + "sha": "74e8a6137ddcf84a3c287235dadf04a98e4173d8", + "url": "https://api.github.com/repos/gr2m/pull-request-test/git/trees/74e8a6137ddcf84a3c287235dadf04a98e4173d8", + "tree": [ + { + "path": "README.md", + "mode": "100644", + "type": "blob", + "sha": "9374e33362555f9818a94b72b3341f3fb033d623", + "size": 19, + "url": "https://api.github.com/repos/gr2m/pull-request-test/git/blobs/9374e33362555f9818a94b72b3341f3fb033d623" + }, + { + "path": "path", + "mode": "040000", + "type": "tree", + "sha": "8a200a3a3bb9e2743f228a04d0ede326f45de6b8", + "url": "https://api.github.com/repos/gr2m/pull-request-test/git/trees/8a200a3a3bb9e2743f228a04d0ede326f45de6b8" + } + ], + "truncated": false + } + } + }, + { + "request": { + "method": "POST", + "baseUrl": "https://api.github.com", + "headers": { + "accept": "application/vnd.github.v3+json", + "user-agent": "octokit-core.js/3.0.0 Node.js/14.3.0 (macOS Catalina; x64)" + }, + "mediaType": { + "format": "", + "previews": [] + }, + "request": {}, + "url": "/repos/:owner/:repo/git/commits", + "owner": "gr2m", + "repo": "pull-request-test", + "message": "up up up", + "tree": "74e8a6137ddcf84a3c287235dadf04a98e4173d8", + "parents": ["3b6c2a2df60769aa026013f5bc1649cc004bd925"] + }, + "response": { + "status": 201, + "url": "https://api.github.com/repos/gr2m/pull-request-test/git/commits", + "headers": { + "access-control-allow-origin": "*", + "access-control-expose-headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset", + "cache-control": "private, max-age=60, s-maxage=60", + "connection": "close", + "content-length": "1109", + "content-security-policy": "default-src 'none'", + "content-type": "application/json; charset=utf-8", + "date": "Tue, 16 Jun 2020 18:09:56 GMT", + "etag": "\"66ca6a11d5a93afd9edd35a3840942ca\"", + "location": "https://api.github.com/repos/gr2m/pull-request-test/git/commits/028c1ead40ebd88222d8f94af605402524b48570", + "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "server": "GitHub.com", + "status": "201 Created", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With, Accept-Encoding", + "x-accepted-oauth-scopes": "", + "x-content-type-options": "nosniff", + "x-frame-options": "deny", + "x-github-media-type": "github.v3; format=json", + "x-github-request-id": "CB42:50F0:99685B:B6CC69:5EE90AF3", + "x-oauth-scopes": "repo", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4919", + "x-ratelimit-reset": "1592333501", + "x-xss-protection": "1; mode=block" + }, + "data": { + "sha": "028c1ead40ebd88222d8f94af605402524b48570", + "node_id": "MDY6Q29tbWl0MTYwOTg3NDkyOjAyOGMxZWFkNDBlYmQ4ODIyMmQ4Zjk0YWY2MDU0MDI1MjRiNDg1NzA=", + "url": "https://api.github.com/repos/gr2m/pull-request-test/git/commits/028c1ead40ebd88222d8f94af605402524b48570", + "html_url": "https://github.com/gr2m/pull-request-test/commit/028c1ead40ebd88222d8f94af605402524b48570", + "author": { + "name": "Gregor Martynus", + "email": "gregor@martynus.net", + "date": "2020-06-16T18:09:56Z" + }, + "committer": { + "name": "Gregor Martynus", + "email": "gregor@martynus.net", + "date": "2020-06-16T18:09:56Z" + }, + "tree": { + "sha": "74e8a6137ddcf84a3c287235dadf04a98e4173d8", + "url": "https://api.github.com/repos/gr2m/pull-request-test/git/trees/74e8a6137ddcf84a3c287235dadf04a98e4173d8" + }, + "message": "up up up", + "parents": [ + { + "sha": "3b6c2a2df60769aa026013f5bc1649cc004bd925", + "url": "https://api.github.com/repos/gr2m/pull-request-test/git/commits/3b6c2a2df60769aa026013f5bc1649cc004bd925", + "html_url": "https://github.com/gr2m/pull-request-test/commit/3b6c2a2df60769aa026013f5bc1649cc004bd925" + } + ], + "verification": { + "verified": false, + "reason": "unsigned", + "signature": null, + "payload": null + } + } + } + }, + { + "request": { + "method": "POST", + "baseUrl": "https://api.github.com", + "headers": { + "accept": "application/vnd.github.v3+json", + "user-agent": "octokit-core.js/3.0.0 Node.js/14.3.0 (macOS Catalina; x64)" + }, + "mediaType": { + "format": "", + "previews": [] + }, + "request": {}, + "url": "/repos/:owner/:repo/git/refs", + "owner": "gr2m", + "repo": "pull-request-test", + "sha": "028c1ead40ebd88222d8f94af605402524b48570", + "ref": "refs/heads/test" + }, + "response": { + "status": 201, + "url": "https://api.github.com/repos/gr2m/pull-request-test/git/refs", + "headers": { + "access-control-allow-origin": "*", + "access-control-expose-headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset", + "cache-control": "private, max-age=60, s-maxage=60", + "connection": "close", + "content-length": "351", + "content-security-policy": "default-src 'none'", + "content-type": "application/json; charset=utf-8", + "date": "Tue, 16 Jun 2020 18:09:57 GMT", + "etag": "\"d7c486dcaaebcbaaa60ba98ff195fd49\"", + "location": "https://api.github.com/repos/gr2m/pull-request-test/git/refs/heads/test", + "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "server": "GitHub.com", + "status": "201 Created", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With, Accept-Encoding", + "x-accepted-oauth-scopes": "repo", + "x-content-type-options": "nosniff", + "x-frame-options": "deny", + "x-github-media-type": "github.v3; format=json", + "x-github-request-id": "CB43:1B47:95619C:B3AC7C:5EE90AF4", + "x-oauth-scopes": "repo", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4918", + "x-ratelimit-reset": "1592333501", + "x-xss-protection": "1; mode=block" + }, + "data": { + "ref": "refs/heads/test", + "node_id": "MDM6UmVmMTYwOTg3NDkyOnJlZnMvaGVhZHMvdGVzdA==", + "url": "https://api.github.com/repos/gr2m/pull-request-test/git/refs/heads/test", + "object": { + "sha": "028c1ead40ebd88222d8f94af605402524b48570", + "type": "commit", + "url": "https://api.github.com/repos/gr2m/pull-request-test/git/commits/028c1ead40ebd88222d8f94af605402524b48570" + } + } + } + }, + { + "request": { + "method": "POST", + "baseUrl": "https://api.github.com", + "headers": { + "accept": "application/vnd.github.v3+json", + "user-agent": "octokit-core.js/3.0.0 Node.js/14.3.0 (macOS Catalina; x64)" + }, + "mediaType": { + "format": "", + "previews": [] + }, + "request": {}, + "url": "/repos/:owner/:repo/pulls", + "owner": "gr2m", + "repo": "pull-request-test", + "head": "gr2m:test", + "base": "master", + "title": "Test", + "body": "" + }, + "response": { + "status": 201, + "url": "https://api.github.com/repos/gr2m/pull-request-test/pulls", + "headers": { + "access-control-allow-origin": "*", + "access-control-expose-headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset", + "cache-control": "private, max-age=60, s-maxage=60", + "connection": "close", + "content-length": "14747", + "content-security-policy": "default-src 'none'", + "content-type": "application/json; charset=utf-8", + "date": "Tue, 16 Jun 2020 18:09:59 GMT", + "etag": "\"ff413f128ef4268ec170db61a9795cfd\"", + "location": "https://api.github.com/repos/gr2m/pull-request-test/pulls/41", + "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "server": "GitHub.com", + "status": "201 Created", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With, Accept-Encoding", + "x-accepted-oauth-scopes": "", + "x-content-type-options": "nosniff", + "x-frame-options": "deny", + "x-github-media-type": "github.v3; format=json", + "x-github-request-id": "CB44:1B44:B1F57:D5996:5EE90AF5", + "x-oauth-scopes": "repo", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4917", + "x-ratelimit-reset": "1592333501", + "x-xss-protection": "1; mode=block" + }, + "data": { + "url": "https://api.github.com/repos/gr2m/pull-request-test/pulls/41", + "id": 435387120, + "node_id": "MDExOlB1bGxSZXF1ZXN0NDM1Mzg3MTIw", + "html_url": "https://github.com/gr2m/pull-request-test/pull/41", + "diff_url": "https://github.com/gr2m/pull-request-test/pull/41.diff", + "patch_url": "https://github.com/gr2m/pull-request-test/pull/41.patch", + "issue_url": "https://api.github.com/repos/gr2m/pull-request-test/issues/41", + "number": 41, + "state": "open", + "locked": false, + "title": "Test", + "user": { + "login": "gr2m", + "id": 39992, + "node_id": "MDQ6VXNlcjM5OTky", + "avatar_url": "https://avatars3.githubusercontent.com/u/39992?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/gr2m", + "html_url": "https://github.com/gr2m", + "followers_url": "https://api.github.com/users/gr2m/followers", + "following_url": "https://api.github.com/users/gr2m/following{/other_user}", + "gists_url": "https://api.github.com/users/gr2m/gists{/gist_id}", + "starred_url": "https://api.github.com/users/gr2m/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/gr2m/subscriptions", + "organizations_url": "https://api.github.com/users/gr2m/orgs", + "repos_url": "https://api.github.com/users/gr2m/repos", + "events_url": "https://api.github.com/users/gr2m/events{/privacy}", + "received_events_url": "https://api.github.com/users/gr2m/received_events", + "type": "User", + "site_admin": false + }, + "body": "", + "created_at": "2020-06-16T18:09:58Z", + "updated_at": "2020-06-16T18:09:58Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": null, + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [], + "milestone": null, + "draft": false, + "commits_url": "https://api.github.com/repos/gr2m/pull-request-test/pulls/41/commits", + "review_comments_url": "https://api.github.com/repos/gr2m/pull-request-test/pulls/41/comments", + "review_comment_url": "https://api.github.com/repos/gr2m/pull-request-test/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/gr2m/pull-request-test/issues/41/comments", + "statuses_url": "https://api.github.com/repos/gr2m/pull-request-test/statuses/028c1ead40ebd88222d8f94af605402524b48570", + "head": { + "label": "gr2m:test", + "ref": "test", + "sha": "028c1ead40ebd88222d8f94af605402524b48570", + "user": { + "login": "gr2m", + "id": 39992, + "node_id": "MDQ6VXNlcjM5OTky", + "avatar_url": "https://avatars3.githubusercontent.com/u/39992?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/gr2m", + "html_url": "https://github.com/gr2m", + "followers_url": "https://api.github.com/users/gr2m/followers", + "following_url": "https://api.github.com/users/gr2m/following{/other_user}", + "gists_url": "https://api.github.com/users/gr2m/gists{/gist_id}", + "starred_url": "https://api.github.com/users/gr2m/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/gr2m/subscriptions", + "organizations_url": "https://api.github.com/users/gr2m/orgs", + "repos_url": "https://api.github.com/users/gr2m/repos", + "events_url": "https://api.github.com/users/gr2m/events{/privacy}", + "received_events_url": "https://api.github.com/users/gr2m/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 160987492, + "node_id": "MDEwOlJlcG9zaXRvcnkxNjA5ODc0OTI=", + "name": "pull-request-test", + "full_name": "gr2m/pull-request-test", + "private": false, + "owner": { + "login": "gr2m", + "id": 39992, + "node_id": "MDQ6VXNlcjM5OTky", + "avatar_url": "https://avatars3.githubusercontent.com/u/39992?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/gr2m", + "html_url": "https://github.com/gr2m", + "followers_url": "https://api.github.com/users/gr2m/followers", + "following_url": "https://api.github.com/users/gr2m/following{/other_user}", + "gists_url": "https://api.github.com/users/gr2m/gists{/gist_id}", + "starred_url": "https://api.github.com/users/gr2m/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/gr2m/subscriptions", + "organizations_url": "https://api.github.com/users/gr2m/orgs", + "repos_url": "https://api.github.com/users/gr2m/repos", + "events_url": "https://api.github.com/users/gr2m/events{/privacy}", + "received_events_url": "https://api.github.com/users/gr2m/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/gr2m/pull-request-test", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/gr2m/pull-request-test", + "forks_url": "https://api.github.com/repos/gr2m/pull-request-test/forks", + "keys_url": "https://api.github.com/repos/gr2m/pull-request-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/gr2m/pull-request-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/gr2m/pull-request-test/teams", + "hooks_url": "https://api.github.com/repos/gr2m/pull-request-test/hooks", + "issue_events_url": "https://api.github.com/repos/gr2m/pull-request-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/gr2m/pull-request-test/events", + "assignees_url": "https://api.github.com/repos/gr2m/pull-request-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/gr2m/pull-request-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/gr2m/pull-request-test/tags", + "blobs_url": "https://api.github.com/repos/gr2m/pull-request-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/gr2m/pull-request-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/gr2m/pull-request-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/gr2m/pull-request-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/gr2m/pull-request-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/gr2m/pull-request-test/languages", + "stargazers_url": "https://api.github.com/repos/gr2m/pull-request-test/stargazers", + "contributors_url": "https://api.github.com/repos/gr2m/pull-request-test/contributors", + "subscribers_url": "https://api.github.com/repos/gr2m/pull-request-test/subscribers", + "subscription_url": "https://api.github.com/repos/gr2m/pull-request-test/subscription", + "commits_url": "https://api.github.com/repos/gr2m/pull-request-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/gr2m/pull-request-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/gr2m/pull-request-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/gr2m/pull-request-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/gr2m/pull-request-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/gr2m/pull-request-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/gr2m/pull-request-test/merges", + "archive_url": "https://api.github.com/repos/gr2m/pull-request-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/gr2m/pull-request-test/downloads", + "issues_url": "https://api.github.com/repos/gr2m/pull-request-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/gr2m/pull-request-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/gr2m/pull-request-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/gr2m/pull-request-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/gr2m/pull-request-test/labels{/name}", + "releases_url": "https://api.github.com/repos/gr2m/pull-request-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/gr2m/pull-request-test/deployments", + "created_at": "2018-12-08T23:26:26Z", + "updated_at": "2019-01-28T17:23:18Z", + "pushed_at": "2020-06-16T18:09:57Z", + "git_url": "git://github.com/gr2m/pull-request-test.git", + "ssh_url": "git@github.com:gr2m/pull-request-test.git", + "clone_url": "https://github.com/gr2m/pull-request-test.git", + "svn_url": "https://github.com/gr2m/pull-request-test", + "homepage": null, + "size": 229, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": false, + "has_projects": false, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "forks_count": 1, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "forks": 1, + "open_issues": 1, + "watchers": 0, + "default_branch": "master" + } + }, + "base": { + "label": "gr2m:master", + "ref": "master", + "sha": "3b6c2a2df60769aa026013f5bc1649cc004bd925", + "user": { + "login": "gr2m", + "id": 39992, + "node_id": "MDQ6VXNlcjM5OTky", + "avatar_url": "https://avatars3.githubusercontent.com/u/39992?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/gr2m", + "html_url": "https://github.com/gr2m", + "followers_url": "https://api.github.com/users/gr2m/followers", + "following_url": "https://api.github.com/users/gr2m/following{/other_user}", + "gists_url": "https://api.github.com/users/gr2m/gists{/gist_id}", + "starred_url": "https://api.github.com/users/gr2m/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/gr2m/subscriptions", + "organizations_url": "https://api.github.com/users/gr2m/orgs", + "repos_url": "https://api.github.com/users/gr2m/repos", + "events_url": "https://api.github.com/users/gr2m/events{/privacy}", + "received_events_url": "https://api.github.com/users/gr2m/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 160987492, + "node_id": "MDEwOlJlcG9zaXRvcnkxNjA5ODc0OTI=", + "name": "pull-request-test", + "full_name": "gr2m/pull-request-test", + "private": false, + "owner": { + "login": "gr2m", + "id": 39992, + "node_id": "MDQ6VXNlcjM5OTky", + "avatar_url": "https://avatars3.githubusercontent.com/u/39992?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/gr2m", + "html_url": "https://github.com/gr2m", + "followers_url": "https://api.github.com/users/gr2m/followers", + "following_url": "https://api.github.com/users/gr2m/following{/other_user}", + "gists_url": "https://api.github.com/users/gr2m/gists{/gist_id}", + "starred_url": "https://api.github.com/users/gr2m/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/gr2m/subscriptions", + "organizations_url": "https://api.github.com/users/gr2m/orgs", + "repos_url": "https://api.github.com/users/gr2m/repos", + "events_url": "https://api.github.com/users/gr2m/events{/privacy}", + "received_events_url": "https://api.github.com/users/gr2m/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/gr2m/pull-request-test", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/gr2m/pull-request-test", + "forks_url": "https://api.github.com/repos/gr2m/pull-request-test/forks", + "keys_url": "https://api.github.com/repos/gr2m/pull-request-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/gr2m/pull-request-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/gr2m/pull-request-test/teams", + "hooks_url": "https://api.github.com/repos/gr2m/pull-request-test/hooks", + "issue_events_url": "https://api.github.com/repos/gr2m/pull-request-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/gr2m/pull-request-test/events", + "assignees_url": "https://api.github.com/repos/gr2m/pull-request-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/gr2m/pull-request-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/gr2m/pull-request-test/tags", + "blobs_url": "https://api.github.com/repos/gr2m/pull-request-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/gr2m/pull-request-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/gr2m/pull-request-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/gr2m/pull-request-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/gr2m/pull-request-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/gr2m/pull-request-test/languages", + "stargazers_url": "https://api.github.com/repos/gr2m/pull-request-test/stargazers", + "contributors_url": "https://api.github.com/repos/gr2m/pull-request-test/contributors", + "subscribers_url": "https://api.github.com/repos/gr2m/pull-request-test/subscribers", + "subscription_url": "https://api.github.com/repos/gr2m/pull-request-test/subscription", + "commits_url": "https://api.github.com/repos/gr2m/pull-request-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/gr2m/pull-request-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/gr2m/pull-request-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/gr2m/pull-request-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/gr2m/pull-request-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/gr2m/pull-request-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/gr2m/pull-request-test/merges", + "archive_url": "https://api.github.com/repos/gr2m/pull-request-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/gr2m/pull-request-test/downloads", + "issues_url": "https://api.github.com/repos/gr2m/pull-request-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/gr2m/pull-request-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/gr2m/pull-request-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/gr2m/pull-request-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/gr2m/pull-request-test/labels{/name}", + "releases_url": "https://api.github.com/repos/gr2m/pull-request-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/gr2m/pull-request-test/deployments", + "created_at": "2018-12-08T23:26:26Z", + "updated_at": "2019-01-28T17:23:18Z", + "pushed_at": "2020-06-16T18:09:57Z", + "git_url": "git://github.com/gr2m/pull-request-test.git", + "ssh_url": "git@github.com:gr2m/pull-request-test.git", + "clone_url": "https://github.com/gr2m/pull-request-test.git", + "svn_url": "https://github.com/gr2m/pull-request-test", + "homepage": null, + "size": 229, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": false, + "has_projects": false, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "forks_count": 1, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "forks": 1, + "open_issues": 1, + "watchers": 0, + "default_branch": "master" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/gr2m/pull-request-test/pulls/41" + }, + "html": { + "href": "https://github.com/gr2m/pull-request-test/pull/41" + }, + "issue": { + "href": "https://api.github.com/repos/gr2m/pull-request-test/issues/41" + }, + "comments": { + "href": "https://api.github.com/repos/gr2m/pull-request-test/issues/41/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/gr2m/pull-request-test/pulls/41/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/gr2m/pull-request-test/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/gr2m/pull-request-test/pulls/41/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/gr2m/pull-request-test/statuses/028c1ead40ebd88222d8f94af605402524b48570" + } + }, + "author_association": "OWNER", + "active_lock_reason": null, + "merged": false, + "mergeable": null, + "rebaseable": null, + "mergeable_state": "unknown", + "merged_by": null, + "comments": 0, + "review_comments": 0, + "maintainer_can_modify": false, + "commits": 1, + "additions": 1, + "deletions": 1, + "changed_files": 1 + } + } + } +] diff --git a/test/update-readme.test.ts b/test/update-readme.test.ts new file mode 100644 index 0000000..4233ce4 --- /dev/null +++ b/test/update-readme.test.ts @@ -0,0 +1,60 @@ +import { Octokit as Core } from "@octokit/core"; +import { RequestError } from "@octokit/request-error"; + +import { createPullRequest } from "../src"; +const Octokit = Core.plugin(createPullRequest); + +test("update readme", async () => { + const fixtures = require("./fixtures/update-readme"); + const fixturePr = fixtures[fixtures.length - 1].response; + const octokit = new Octokit(); + + octokit.hook.wrap("request", (_, options) => { + const currentFixtures = fixtures.shift(); + const { + baseUrl, + method, + url, + request, + headers, + mediaType, + ...params + } = options; + + expect(currentFixtures.request.method).toEqual(options.method); + expect(currentFixtures.request.url).toEqual(options.url); + + Object.keys(params).forEach((paramName) => { + expect(currentFixtures.request[paramName]).toStrictEqual( + params[paramName] + ); + }); + + if (currentFixtures.response.status >= 400) { + throw new RequestError("Error", currentFixtures.response.status, { + request: currentFixtures.request, + headers: currentFixtures.response.headers, + }); + } + return currentFixtures.response; + }); + + const pr = await octokit.createPullRequest({ + owner: "gr2m", + repo: "pull-request-test", + title: "Test", + head: "test", + body: "", + changes: { + files: { + "README.md": ({ encoding, content }) => { + return Buffer.from(content, encoding).toString("utf-8").toUpperCase(); + }, + }, + commit: "up up up", + }, + }); + + expect(pr).toStrictEqual(fixturePr); + expect(fixtures.length).toEqual(0); +}); diff --git a/test/use-fork.test.ts b/test/use-fork.test.ts index a9b1d51..d8026ee 100644 --- a/test/use-fork.test.ts +++ b/test/use-fork.test.ts @@ -3,7 +3,7 @@ import { Octokit as Core } from "@octokit/core"; import { createPullRequest } from "../src"; const Octokit = Core.plugin(createPullRequest); -test("create fork", async () => { +test("use fork", async () => { const fixtures = require("./fixtures/use-fork"); const octokit = new Octokit();