diff --git a/README.md b/README.md index 184ab5c..8a9eeda 100644 --- a/README.md +++ b/README.md @@ -83,9 +83,16 @@ octokit .toString("utf-8") .toUpperCase(); }, + "path/to/file5.sh": { + content: "echo Hello World", + encoding: "utf-8", + // one of the modes supported by the git tree object + // https://developer.github.com/v3/git/trees/#tree-object + mode: "100755", + }, }, commit: - "creating file1.txt, file2.png, deleting file3.txt, updating file4.txt (if it exists)", + "creating file1.txt, file2.png, deleting file3.txt, updating file4.txt (if it exists), file5.sh", }, ], }) diff --git a/src/types.ts b/src/types.ts index ab72139..4bfebbb 100644 --- a/src/types.ts +++ b/src/types.ts @@ -27,6 +27,7 @@ export type Changes = { export type File = { content: string; encoding: "utf-8" | "base64"; + mode?: string; }; export type UpdateFunctionFile = diff --git a/src/value-to-tree-object.ts b/src/value-to-tree-object.ts index 2495627..67ff98b 100644 --- a/src/value-to-tree-object.ts +++ b/src/value-to-tree-object.ts @@ -8,11 +8,16 @@ export async function valueToTreeObject( path: string, value: string | File ) { + let mode = "100644"; + if (value !== null && typeof value !== "string") { + mode = value.mode || mode; + } + // Text files can be changed through the .content key if (typeof value === "string") { return { path, - mode: "100644", + mode: mode, content: value, }; } @@ -28,9 +33,10 @@ export async function valueToTreeObject( } ); const blobSha = data.sha; + return { path, - mode: "100644", + mode: mode, sha: blobSha, }; } diff --git a/test/fixtures/happy-path-with-mode.json b/test/fixtures/happy-path-with-mode.json new file mode 100644 index 0000000..4251905 --- /dev/null +++ b/test/fixtures/happy-path-with-mode.json @@ -0,0 +1,1076 @@ +[ + { + "request": { + "method": "GET", + "baseUrl": "https://api.github.com", + "headers": { + "accept": "application/vnd.github.v3+json", + "user-agent": "octokit-core.js/3.2.5 Node.js/10.19.0 (linux; x64)" + }, + "mediaType": { + "format": "", + "previews": [] + }, + "request": {}, + "url": "/repos/{owner}/{repo}", + "owner": "kennethzfeng", + "repo": "pull-request-test" + }, + "response": { + "status": 200, + "url": "https://api.github.com/repos/kennethzfeng/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-Used, X-RateLimit-Resource, 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": "Mon, 18 Oct 2021 20:26:56 GMT", + "etag": "W/\"80b12b22ca1ed16386d328be809ac5c9a0390c225ecf8b4944a7640eeb208810\"", + "github-authentication-token-expiration": "2021-10-25 19:52:01 UTC", + "last-modified": "Mon, 18 Oct 2021 20:02:26 GMT", + "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "server": "GitHub.com", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "transfer-encoding": "chunked", + "vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With", + "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": "E07E:6387:65EAB5:186BE14:616DD890", + "x-oauth-scopes": "repo", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4949", + "x-ratelimit-reset": "1634590073", + "x-ratelimit-resource": "core", + "x-ratelimit-used": "51", + "x-xss-protection": "0" + }, + "data": { + "id": 418650543, + "node_id": "R_kgDOGPQZrw", + "name": "pull-request-test", + "full_name": "kennethzfeng/pull-request-test", + "private": false, + "owner": { + "login": "kennethzfeng", + "id": 2454440, + "node_id": "MDQ6VXNlcjI0NTQ0NDA=", + "avatar_url": "https://avatars.githubusercontent.com/u/2454440?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kennethzfeng", + "html_url": "https://github.com/kennethzfeng", + "followers_url": "https://api.github.com/users/kennethzfeng/followers", + "following_url": "https://api.github.com/users/kennethzfeng/following{/other_user}", + "gists_url": "https://api.github.com/users/kennethzfeng/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kennethzfeng/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kennethzfeng/subscriptions", + "organizations_url": "https://api.github.com/users/kennethzfeng/orgs", + "repos_url": "https://api.github.com/users/kennethzfeng/repos", + "events_url": "https://api.github.com/users/kennethzfeng/events{/privacy}", + "received_events_url": "https://api.github.com/users/kennethzfeng/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/kennethzfeng/pull-request-test", + "description": "Playground for testing out pull request", + "fork": false, + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test", + "forks_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/forks", + "keys_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/teams", + "hooks_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/hooks", + "issue_events_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/events", + "assignees_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/tags", + "blobs_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/languages", + "stargazers_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/stargazers", + "contributors_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/contributors", + "subscribers_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/subscribers", + "subscription_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/subscription", + "commits_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/merges", + "archive_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/downloads", + "issues_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/labels{/name}", + "releases_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/deployments", + "created_at": "2021-10-18T20:02:22Z", + "updated_at": "2021-10-18T20:02:26Z", + "pushed_at": "2021-10-18T20:25:33Z", + "git_url": "git://github.com/kennethzfeng/pull-request-test.git", + "ssh_url": "git@github.com:kennethzfeng/pull-request-test.git", + "clone_url": "https://github.com/kennethzfeng/pull-request-test.git", + "svn_url": "https://github.com/kennethzfeng/pull-request-test", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 2, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "allow_forking": true, + "is_template": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 2, + "watchers": 0, + "default_branch": "main", + "permissions": { + "admin": true, + "maintain": true, + "push": true, + "triage": true, + "pull": true + }, + "temp_clone_token": "", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "network_count": 0, + "subscribers_count": 1 + } + } + }, + { + "request": { + "method": "GET", + "baseUrl": "https://api.github.com", + "headers": { + "accept": "application/vnd.github.v3+json", + "user-agent": "octokit-core.js/3.2.5 Node.js/10.19.0 (linux; x64)" + }, + "mediaType": { + "format": "", + "previews": [] + }, + "request": {}, + "url": "/repos/{owner}/{repo}/commits", + "owner": "kennethzfeng", + "repo": "pull-request-test", + "sha": "main", + "per_page": 1 + }, + "response": { + "status": 200, + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test/commits?sha=main&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-Used, X-RateLimit-Resource, 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": "Mon, 18 Oct 2021 20:26:56 GMT", + "etag": "W/\"3d7652601b8a0b7a7563f8c047434a0c80cee6fdd0e1de6adbd9299109b12ed4\"", + "github-authentication-token-expiration": "2021-10-25 19:52:01 UTC", + "last-modified": "Mon, 18 Oct 2021 20:02:23 GMT", + "link": "; rel=\"next\", ; rel=\"last\"", + "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "server": "GitHub.com", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "transfer-encoding": "chunked", + "vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With", + "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": "E080:744C:386DDB4:62EC8CF:616DD890", + "x-oauth-scopes": "repo", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4948", + "x-ratelimit-reset": "1634590073", + "x-ratelimit-resource": "core", + "x-ratelimit-used": "52", + "x-xss-protection": "0" + }, + "data": [ + { + "sha": "962db08cb65d1790bb5e0b8ab0122b9df14bc33b", + "node_id": "C_kwDOGPQZr9oAKDk2MmRiMDhjYjY1ZDE3OTBiYjVlMGI4YWIwMTIyYjlkZjE0YmMzM2I", + "commit": { + "author": { + "name": "Kenneth Feng", + "email": "2454440+kennethzfeng@users.noreply.github.com", + "date": "2021-10-18T20:02:23Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2021-10-18T20:02:23Z" + }, + "message": "Initial commit", + "tree": { + "sha": "135bbed09b091e6250feb16e66d5465759fe3f50", + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/trees/135bbed09b091e6250feb16e66d5465759fe3f50" + }, + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/commits/962db08cb65d1790bb5e0b8ab0122b9df14bc33b", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJhbdLPCRBK7hj4Ov3rIwAAMAIIAJ6I0QY1A6nZylzhSsAwfquj\nw3ggQg4H16m8t6UEqNA42jiLF7ZmyMATnU+g8oe4ZZjqYKZXhGq2407TM5BmT8+l\nUL5lU1vSSFoNNnxiIIPfSv1C7GT9zqhjux2P8a2ebI+gttr1raPn2g5LsBM9g5Nl\n5QEkLZvT9QnUgefEZ/cGqa4BE07fSuMMd2AmA5vpfaBhidwhc9YACsSgIKjYGXj0\neBsXz1KGtaGSTYC+wK9JwHTTt//YgoUyQEZ1yR8LNQcDmt8OVEXlelcFfPih/hlM\nD5CS/m06cIgDA5nOWnzLKMFH2DptVEfdQKEc89zsiVxBg8mP+IP8z4y+w/kPp/E=\n=AaFV\n-----END PGP SIGNATURE-----\n", + "payload": "tree 135bbed09b091e6250feb16e66d5465759fe3f50\nauthor Kenneth Feng <2454440+kennethzfeng@users.noreply.github.com> 1634587343 -0400\ncommitter GitHub 1634587343 -0400\n\nInitial commit" + } + }, + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test/commits/962db08cb65d1790bb5e0b8ab0122b9df14bc33b", + "html_url": "https://github.com/kennethzfeng/pull-request-test/commit/962db08cb65d1790bb5e0b8ab0122b9df14bc33b", + "comments_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/commits/962db08cb65d1790bb5e0b8ab0122b9df14bc33b/comments", + "author": { + "login": "kennethzfeng", + "id": 2454440, + "node_id": "MDQ6VXNlcjI0NTQ0NDA=", + "avatar_url": "https://avatars.githubusercontent.com/u/2454440?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kennethzfeng", + "html_url": "https://github.com/kennethzfeng", + "followers_url": "https://api.github.com/users/kennethzfeng/followers", + "following_url": "https://api.github.com/users/kennethzfeng/following{/other_user}", + "gists_url": "https://api.github.com/users/kennethzfeng/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kennethzfeng/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kennethzfeng/subscriptions", + "organizations_url": "https://api.github.com/users/kennethzfeng/orgs", + "repos_url": "https://api.github.com/users/kennethzfeng/repos", + "events_url": "https://api.github.com/users/kennethzfeng/events{/privacy}", + "received_events_url": "https://api.github.com/users/kennethzfeng/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars.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": [] + } + ] + } + }, + { + "request": { + "method": "POST", + "baseUrl": "https://api.github.com", + "headers": { + "accept": "application/vnd.github.v3+json", + "user-agent": "octokit-core.js/3.2.5 Node.js/10.19.0 (linux; x64)" + }, + "mediaType": { + "format": "", + "previews": [] + }, + "request": {}, + "url": "/repos/{owner}/{repo}/git/blobs", + "owner": "kennethzfeng", + "repo": "pull-request-test", + "content": "Content for file2", + "encoding": "utf-8" + }, + "response": { + "status": 201, + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/blobs", + "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-Used, X-RateLimit-Resource, 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": "169", + "content-security-policy": "default-src 'none'", + "content-type": "application/json; charset=utf-8", + "date": "Mon, 18 Oct 2021 20:26:56 GMT", + "etag": "\"8c746b2b420dec51df768728f9315a6ba77e9d5dab0ae71b5c4d1cd59edd5eea\"", + "github-authentication-token-expiration": "2021-10-25 19:52:01 UTC", + "location": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/blobs/36e1dc2cc1bbbf0a75a06279b9bdb27fad6b78e3", + "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "server": "GitHub.com", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With", + "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": "E082:6BBC:26AB1B9:6AB0C84:616DD890", + "x-oauth-scopes": "repo", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4947", + "x-ratelimit-reset": "1634590073", + "x-ratelimit-resource": "core", + "x-ratelimit-used": "53", + "x-xss-protection": "0" + }, + "data": { + "sha": "36e1dc2cc1bbbf0a75a06279b9bdb27fad6b78e3", + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/blobs/36e1dc2cc1bbbf0a75a06279b9bdb27fad6b78e3" + } + } + }, + { + "request": { + "method": "POST", + "baseUrl": "https://api.github.com", + "headers": { + "accept": "application/vnd.github.v3+json", + "user-agent": "octokit-core.js/3.2.5 Node.js/10.19.0 (linux; x64)" + }, + "mediaType": { + "format": "", + "previews": [] + }, + "request": {}, + "url": "/repos/{owner}/{repo}/git/blobs", + "owner": "kennethzfeng", + "repo": "pull-request-test", + "content": "echo Hello World", + "encoding": "utf-8", + "mode": "100755" + }, + "response": { + "status": 201, + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/blobs", + "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-Used, X-RateLimit-Resource, 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": "169", + "content-security-policy": "default-src 'none'", + "content-type": "application/json; charset=utf-8", + "date": "Mon, 18 Oct 2021 20:26:56 GMT", + "etag": "\"db4b1a78a4d7f54a120f2567cc2c6251d562da4f27c46daaa82841b5aa323ab7\"", + "github-authentication-token-expiration": "2021-10-25 19:52:01 UTC", + "location": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/blobs/c346b86cea27ec508d99b869b35d45b5edbd53f0", + "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "server": "GitHub.com", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With", + "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": "E084:3352:251DE7B:692768F:616DD890", + "x-oauth-scopes": "repo", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4946", + "x-ratelimit-reset": "1634590073", + "x-ratelimit-resource": "core", + "x-ratelimit-used": "54", + "x-xss-protection": "0" + }, + "data": { + "sha": "c346b86cea27ec508d99b869b35d45b5edbd53f0", + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/blobs/c346b86cea27ec508d99b869b35d45b5edbd53f0" + } + } + }, + { + "request": { + "method": "POST", + "baseUrl": "https://api.github.com", + "headers": { + "accept": "application/vnd.github.v3+json", + "user-agent": "octokit-core.js/3.2.5 Node.js/10.19.0 (linux; x64)" + }, + "mediaType": { + "format": "", + "previews": [] + }, + "request": {}, + "url": "/repos/{owner}/{repo}/git/trees", + "owner": "kennethzfeng", + "repo": "pull-request-test", + "base_tree": "135bbed09b091e6250feb16e66d5465759fe3f50", + "tree": [ + { + "path": "path/to/file1.txt", + "mode": "100644", + "content": "Content for file1" + }, + { + "path": "path/to/file2.txt", + "mode": "100644", + "sha": "36e1dc2cc1bbbf0a75a06279b9bdb27fad6b78e3" + }, + { + "path": "path/to/file3.sh", + "mode": "100755", + "sha": "c346b86cea27ec508d99b869b35d45b5edbd53f0" + } + ] + }, + "response": { + "status": 201, + "url": "https://api.github.com/repos/kennethzfeng/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-Used, X-RateLimit-Resource, 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": "868", + "content-security-policy": "default-src 'none'", + "content-type": "application/json; charset=utf-8", + "date": "Mon, 18 Oct 2021 20:26:56 GMT", + "etag": "\"a55c360d28eb8e5d111c8fd8140fcfa4323424046606ab3bc78ac01dc9706d77\"", + "github-authentication-token-expiration": "2021-10-25 19:52:01 UTC", + "location": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/trees/de79be237038094dd092d06d8c37d7339baa39aa", + "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "server": "GitHub.com", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With", + "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": "E086:214C:455665F:77EDDD5:616DD890", + "x-oauth-scopes": "repo", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4945", + "x-ratelimit-reset": "1634590073", + "x-ratelimit-resource": "core", + "x-ratelimit-used": "55", + "x-xss-protection": "0" + }, + "data": { + "sha": "de79be237038094dd092d06d8c37d7339baa39aa", + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/trees/de79be237038094dd092d06d8c37d7339baa39aa", + "tree": [ + { + "path": "LICENSE", + "mode": "100644", + "type": "blob", + "sha": "6306c770c3da45786cec2a9e3a0cecc014b97e1e", + "size": 1069, + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/blobs/6306c770c3da45786cec2a9e3a0cecc014b97e1e" + }, + { + "path": "README.md", + "mode": "100644", + "type": "blob", + "sha": "3ba6b06be3edc04e5ccfcf64fc763d5d6a2b99bc", + "size": 60, + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/blobs/3ba6b06be3edc04e5ccfcf64fc763d5d6a2b99bc" + }, + { + "path": "path", + "mode": "040000", + "type": "tree", + "sha": "68ecbd9e566e28497bc461088b86095fff31e040", + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/trees/68ecbd9e566e28497bc461088b86095fff31e040" + } + ], + "truncated": false + } + } + }, + { + "request": { + "method": "POST", + "baseUrl": "https://api.github.com", + "headers": { + "accept": "application/vnd.github.v3+json", + "user-agent": "octokit-core.js/3.2.5 Node.js/10.19.0 (linux; x64)" + }, + "mediaType": { + "format": "", + "previews": [] + }, + "request": {}, + "url": "/repos/{owner}/{repo}/git/commits", + "owner": "kennethzfeng", + "repo": "pull-request-test", + "message": "why", + "tree": "de79be237038094dd092d06d8c37d7339baa39aa", + "parents": [ + "962db08cb65d1790bb5e0b8ab0122b9df14bc33b" + ] + }, + "response": { + "status": 201, + "url": "https://api.github.com/repos/kennethzfeng/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-Used, X-RateLimit-Resource, 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": "1179", + "content-security-policy": "default-src 'none'", + "content-type": "application/json; charset=utf-8", + "date": "Mon, 18 Oct 2021 20:26:57 GMT", + "etag": "\"9f7057869c3a1f594ef391b46e8d1a881a669646c747a1ab2f3c2098a4a4ba92\"", + "github-authentication-token-expiration": "2021-10-25 19:52:01 UTC", + "location": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/commits/9f060742080617ab5a320f503c3b97de6fc5fc28", + "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "server": "GitHub.com", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With", + "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": "E088:0A81:1597F28:2E66E01:616DD890", + "x-oauth-scopes": "repo", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4944", + "x-ratelimit-reset": "1634590073", + "x-ratelimit-resource": "core", + "x-ratelimit-used": "56", + "x-xss-protection": "0" + }, + "data": { + "sha": "9f060742080617ab5a320f503c3b97de6fc5fc28", + "node_id": "C_kwDOGPQZr9oAKDlmMDYwNzQyMDgwNjE3YWI1YTMyMGY1MDNjM2I5N2RlNmZjNWZjMjg", + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/commits/9f060742080617ab5a320f503c3b97de6fc5fc28", + "html_url": "https://github.com/kennethzfeng/pull-request-test/commit/9f060742080617ab5a320f503c3b97de6fc5fc28", + "author": { + "name": "Kenneth Feng", + "email": "2454440+kennethzfeng@users.noreply.github.com", + "date": "2021-10-18T20:26:57Z" + }, + "committer": { + "name": "Kenneth Feng", + "email": "2454440+kennethzfeng@users.noreply.github.com", + "date": "2021-10-18T20:26:57Z" + }, + "tree": { + "sha": "de79be237038094dd092d06d8c37d7339baa39aa", + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/trees/de79be237038094dd092d06d8c37d7339baa39aa" + }, + "message": "why", + "parents": [ + { + "sha": "962db08cb65d1790bb5e0b8ab0122b9df14bc33b", + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/commits/962db08cb65d1790bb5e0b8ab0122b9df14bc33b", + "html_url": "https://github.com/kennethzfeng/pull-request-test/commit/962db08cb65d1790bb5e0b8ab0122b9df14bc33b" + } + ], + "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.2.5 Node.js/10.19.0 (linux; x64)" + }, + "mediaType": { + "format": "", + "previews": [] + }, + "request": {}, + "url": "/repos/{owner}/{repo}/git/refs", + "owner": "kennethzfeng", + "repo": "pull-request-test", + "sha": "9f060742080617ab5a320f503c3b97de6fc5fc28", + "ref": "refs/heads/patch" + }, + "response": { + "status": 201, + "url": "https://api.github.com/repos/kennethzfeng/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-Used, X-RateLimit-Resource, 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": "361", + "content-security-policy": "default-src 'none'", + "content-type": "application/json; charset=utf-8", + "date": "Mon, 18 Oct 2021 20:26:57 GMT", + "etag": "\"fdc98ccfe310552b520c24a9068b6c6d5b1c0defac3772571798c0e7c0fa5e03\"", + "github-authentication-token-expiration": "2021-10-25 19:52:01 UTC", + "location": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/refs/heads/patch", + "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "server": "GitHub.com", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With", + "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": "E08A:5D91:2136D15:65DFCE3:616DD891", + "x-oauth-scopes": "repo", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4943", + "x-ratelimit-reset": "1634590073", + "x-ratelimit-resource": "core", + "x-ratelimit-used": "57", + "x-xss-protection": "0" + }, + "data": { + "ref": "refs/heads/patch", + "node_id": "REF_kwDOGPQZr7ByZWZzL2hlYWRzL3BhdGNo", + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/refs/heads/patch", + "object": { + "sha": "9f060742080617ab5a320f503c3b97de6fc5fc28", + "type": "commit", + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/commits/9f060742080617ab5a320f503c3b97de6fc5fc28" + } + } + } + }, + { + "request": { + "method": "POST", + "baseUrl": "https://api.github.com", + "headers": { + "accept": "application/vnd.github.v3+json", + "user-agent": "octokit-core.js/3.2.5 Node.js/10.19.0 (linux; x64)" + }, + "mediaType": { + "format": "", + "previews": [] + }, + "request": {}, + "url": "/repos/{owner}/{repo}/pulls", + "owner": "kennethzfeng", + "repo": "pull-request-test", + "head": "kennethzfeng:patch", + "base": "main", + "title": "One comes, one goes", + "body": "because", + "draft": false + }, + "response": { + "status": 201, + "url": "https://api.github.com/repos/kennethzfeng/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-Used, X-RateLimit-Resource, 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": "16528", + "content-security-policy": "default-src 'none'", + "content-type": "application/json; charset=utf-8", + "date": "Mon, 18 Oct 2021 20:26:58 GMT", + "etag": "\"d6e14b516d1833c001c10a3271b539fed034e372f2457529aaae7b759c30f2a7\"", + "github-authentication-token-expiration": "2021-10-25 19:52:01 UTC", + "location": "https://api.github.com/repos/kennethzfeng/pull-request-test/pulls/3", + "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "server": "GitHub.com", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With", + "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": "E08C:024D:3323116:5FECBBD:616DD891", + "x-oauth-scopes": "repo", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4942", + "x-ratelimit-reset": "1634590073", + "x-ratelimit-resource": "core", + "x-ratelimit-used": "58", + "x-xss-protection": "0" + }, + "data": { + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test/pulls/3", + "id": 760833614, + "node_id": "PR_kwDOGPQZr84tWWZO", + "html_url": "https://github.com/kennethzfeng/pull-request-test/pull/3", + "diff_url": "https://github.com/kennethzfeng/pull-request-test/pull/3.diff", + "patch_url": "https://github.com/kennethzfeng/pull-request-test/pull/3.patch", + "issue_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/issues/3", + "number": 3, + "state": "open", + "locked": false, + "title": "One comes, one goes", + "user": { + "login": "kennethzfeng", + "id": 2454440, + "node_id": "MDQ6VXNlcjI0NTQ0NDA=", + "avatar_url": "https://avatars.githubusercontent.com/u/2454440?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kennethzfeng", + "html_url": "https://github.com/kennethzfeng", + "followers_url": "https://api.github.com/users/kennethzfeng/followers", + "following_url": "https://api.github.com/users/kennethzfeng/following{/other_user}", + "gists_url": "https://api.github.com/users/kennethzfeng/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kennethzfeng/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kennethzfeng/subscriptions", + "organizations_url": "https://api.github.com/users/kennethzfeng/orgs", + "repos_url": "https://api.github.com/users/kennethzfeng/repos", + "events_url": "https://api.github.com/users/kennethzfeng/events{/privacy}", + "received_events_url": "https://api.github.com/users/kennethzfeng/received_events", + "type": "User", + "site_admin": false + }, + "body": "because", + "created_at": "2021-10-18T20:26:57Z", + "updated_at": "2021-10-18T20:26:57Z", + "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/kennethzfeng/pull-request-test/pulls/3/commits", + "review_comments_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/pulls/3/comments", + "review_comment_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/issues/3/comments", + "statuses_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/statuses/9f060742080617ab5a320f503c3b97de6fc5fc28", + "head": { + "label": "kennethzfeng:patch", + "ref": "patch", + "sha": "9f060742080617ab5a320f503c3b97de6fc5fc28", + "user": { + "login": "kennethzfeng", + "id": 2454440, + "node_id": "MDQ6VXNlcjI0NTQ0NDA=", + "avatar_url": "https://avatars.githubusercontent.com/u/2454440?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kennethzfeng", + "html_url": "https://github.com/kennethzfeng", + "followers_url": "https://api.github.com/users/kennethzfeng/followers", + "following_url": "https://api.github.com/users/kennethzfeng/following{/other_user}", + "gists_url": "https://api.github.com/users/kennethzfeng/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kennethzfeng/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kennethzfeng/subscriptions", + "organizations_url": "https://api.github.com/users/kennethzfeng/orgs", + "repos_url": "https://api.github.com/users/kennethzfeng/repos", + "events_url": "https://api.github.com/users/kennethzfeng/events{/privacy}", + "received_events_url": "https://api.github.com/users/kennethzfeng/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 418650543, + "node_id": "R_kgDOGPQZrw", + "name": "pull-request-test", + "full_name": "kennethzfeng/pull-request-test", + "private": false, + "owner": { + "login": "kennethzfeng", + "id": 2454440, + "node_id": "MDQ6VXNlcjI0NTQ0NDA=", + "avatar_url": "https://avatars.githubusercontent.com/u/2454440?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kennethzfeng", + "html_url": "https://github.com/kennethzfeng", + "followers_url": "https://api.github.com/users/kennethzfeng/followers", + "following_url": "https://api.github.com/users/kennethzfeng/following{/other_user}", + "gists_url": "https://api.github.com/users/kennethzfeng/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kennethzfeng/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kennethzfeng/subscriptions", + "organizations_url": "https://api.github.com/users/kennethzfeng/orgs", + "repos_url": "https://api.github.com/users/kennethzfeng/repos", + "events_url": "https://api.github.com/users/kennethzfeng/events{/privacy}", + "received_events_url": "https://api.github.com/users/kennethzfeng/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/kennethzfeng/pull-request-test", + "description": "Playground for testing out pull request", + "fork": false, + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test", + "forks_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/forks", + "keys_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/teams", + "hooks_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/hooks", + "issue_events_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/events", + "assignees_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/tags", + "blobs_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/languages", + "stargazers_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/stargazers", + "contributors_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/contributors", + "subscribers_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/subscribers", + "subscription_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/subscription", + "commits_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/merges", + "archive_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/downloads", + "issues_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/labels{/name}", + "releases_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/deployments", + "created_at": "2021-10-18T20:02:22Z", + "updated_at": "2021-10-18T20:02:26Z", + "pushed_at": "2021-10-18T20:26:57Z", + "git_url": "git://github.com/kennethzfeng/pull-request-test.git", + "ssh_url": "git@github.com:kennethzfeng/pull-request-test.git", + "clone_url": "https://github.com/kennethzfeng/pull-request-test.git", + "svn_url": "https://github.com/kennethzfeng/pull-request-test", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 3, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "allow_forking": true, + "is_template": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 3, + "watchers": 0, + "default_branch": "main" + } + }, + "base": { + "label": "kennethzfeng:main", + "ref": "main", + "sha": "962db08cb65d1790bb5e0b8ab0122b9df14bc33b", + "user": { + "login": "kennethzfeng", + "id": 2454440, + "node_id": "MDQ6VXNlcjI0NTQ0NDA=", + "avatar_url": "https://avatars.githubusercontent.com/u/2454440?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kennethzfeng", + "html_url": "https://github.com/kennethzfeng", + "followers_url": "https://api.github.com/users/kennethzfeng/followers", + "following_url": "https://api.github.com/users/kennethzfeng/following{/other_user}", + "gists_url": "https://api.github.com/users/kennethzfeng/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kennethzfeng/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kennethzfeng/subscriptions", + "organizations_url": "https://api.github.com/users/kennethzfeng/orgs", + "repos_url": "https://api.github.com/users/kennethzfeng/repos", + "events_url": "https://api.github.com/users/kennethzfeng/events{/privacy}", + "received_events_url": "https://api.github.com/users/kennethzfeng/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 418650543, + "node_id": "R_kgDOGPQZrw", + "name": "pull-request-test", + "full_name": "kennethzfeng/pull-request-test", + "private": false, + "owner": { + "login": "kennethzfeng", + "id": 2454440, + "node_id": "MDQ6VXNlcjI0NTQ0NDA=", + "avatar_url": "https://avatars.githubusercontent.com/u/2454440?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kennethzfeng", + "html_url": "https://github.com/kennethzfeng", + "followers_url": "https://api.github.com/users/kennethzfeng/followers", + "following_url": "https://api.github.com/users/kennethzfeng/following{/other_user}", + "gists_url": "https://api.github.com/users/kennethzfeng/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kennethzfeng/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kennethzfeng/subscriptions", + "organizations_url": "https://api.github.com/users/kennethzfeng/orgs", + "repos_url": "https://api.github.com/users/kennethzfeng/repos", + "events_url": "https://api.github.com/users/kennethzfeng/events{/privacy}", + "received_events_url": "https://api.github.com/users/kennethzfeng/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/kennethzfeng/pull-request-test", + "description": "Playground for testing out pull request", + "fork": false, + "url": "https://api.github.com/repos/kennethzfeng/pull-request-test", + "forks_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/forks", + "keys_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/teams", + "hooks_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/hooks", + "issue_events_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/events", + "assignees_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/tags", + "blobs_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/languages", + "stargazers_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/stargazers", + "contributors_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/contributors", + "subscribers_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/subscribers", + "subscription_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/subscription", + "commits_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/merges", + "archive_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/downloads", + "issues_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/labels{/name}", + "releases_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/kennethzfeng/pull-request-test/deployments", + "created_at": "2021-10-18T20:02:22Z", + "updated_at": "2021-10-18T20:02:26Z", + "pushed_at": "2021-10-18T20:26:57Z", + "git_url": "git://github.com/kennethzfeng/pull-request-test.git", + "ssh_url": "git@github.com:kennethzfeng/pull-request-test.git", + "clone_url": "https://github.com/kennethzfeng/pull-request-test.git", + "svn_url": "https://github.com/kennethzfeng/pull-request-test", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 3, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "allow_forking": true, + "is_template": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 3, + "watchers": 0, + "default_branch": "main" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/kennethzfeng/pull-request-test/pulls/3" + }, + "html": { + "href": "https://github.com/kennethzfeng/pull-request-test/pull/3" + }, + "issue": { + "href": "https://api.github.com/repos/kennethzfeng/pull-request-test/issues/3" + }, + "comments": { + "href": "https://api.github.com/repos/kennethzfeng/pull-request-test/issues/3/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/kennethzfeng/pull-request-test/pulls/3/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/kennethzfeng/pull-request-test/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/kennethzfeng/pull-request-test/pulls/3/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/kennethzfeng/pull-request-test/statuses/9f060742080617ab5a320f503c3b97de6fc5fc28" + } + }, + "author_association": "OWNER", + "auto_merge": null, + "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": 3, + "deletions": 0, + "changed_files": 3 + } + } + } +] diff --git a/test/happy-path-with-mode.test.ts b/test/happy-path-with-mode.test.ts new file mode 100644 index 0000000..bb96d3c --- /dev/null +++ b/test/happy-path-with-mode.test.ts @@ -0,0 +1,56 @@ +import { Octokit as Core } from "@octokit/core"; +import { createPullRequest } from "../src"; +const Octokit = Core.plugin(createPullRequest); + +test("happy path with mode", async () => { + const fixtures = require("./fixtures/happy-path-with-mode"); + 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(options.method).toEqual(currentFixtures.request.method); + expect(options.url).toEqual(currentFixtures.request.url); + + Object.keys(params).forEach((paramName) => { + expect(params[paramName]).toEqual(currentFixtures.request[paramName]); + }); + return currentFixtures.response; + }); + + const pr = await octokit.createPullRequest({ + owner: "kennethzfeng", + repo: "pull-request-test", + title: "One comes, one goes", + body: "because", + head: "patch", + changes: { + files: { + "path/to/file1.txt": "Content for file1", + "path/to/file2.txt": { + content: "Content for file2", + encoding: "utf-8", + }, + "path/to/file3.sh": { + content: "echo Hello World", + encoding: "utf-8", + mode: "100755", + }, + }, + commit: "why", + }, + }); + + expect(pr).toStrictEqual(fixturePr); + expect(fixtures.length).toEqual(0); +});