Skip to content

Commit 2f1e82f

Browse files
authored
feat: apps.createContentAttachmentForRepo(), reactions.createForRelease(), repos.compareCommitsWithBasehead() (#390)
1 parent e8087b4 commit 2f1e82f

File tree

14 files changed

+653
-38
lines changed

14 files changed

+653
-38
lines changed

docs/apps/createContentAttachment.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type: API method
88

99
# Create a content attachment
1010

11-
Creates an attachment under a content reference URL in the body or comment of an issue or pull request. Use the `id` of the content reference from the [`content_reference` event](https://docs.github.com/webhooks/event-payloads/#content_reference) to create an attachment.
11+
**Deprecated:** use `apps.createContentAttachmentForRepo()` (`POST /repos/{owner}/{repo}/content_references/{content_reference_id}/attachments`) instead. Creates an attachment under a content reference URL in the body or comment of an issue or pull request. Use the `id` of the content reference from the [`content_reference` event](https://docs.github.com/webhooks/event-payloads/#content_reference) to create an attachment.
1212

1313
The app must create a content attachment within six hours of the content reference URL being posted. See "[Using content attachments](https://docs.github.com/apps/using-content-attachments/)" for details about content attachments.
1414

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
name: Create a content attachment
3+
example: octokit.rest.apps.createContentAttachmentForRepo({ owner, repo, content_reference_id, title, body })
4+
route: POST /repos/{owner}/{repo}/content_references/{content_reference_id}/attachments
5+
scope: apps
6+
type: API method
7+
---
8+
9+
# Create a content attachment
10+
11+
Creates an attachment under a content reference URL in the body or comment of an issue or pull request. Use the `id` and `repository` `full_name` of the content reference from the [`content_reference` event](https://docs.github.com/webhooks/event-payloads/#content_reference) to create an attachment.
12+
13+
The app must create a content attachment within six hours of the content reference URL being posted. See "[Using content attachments](https://docs.github.com/apps/using-content-attachments/)" for details about content attachments.
14+
15+
You must use an [installation access token](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-an-installation) to access this endpoint.
16+
17+
```js
18+
octokit.rest.apps.createContentAttachmentForRepo({
19+
owner,
20+
repo,
21+
content_reference_id,
22+
title,
23+
body,
24+
});
25+
```
26+
27+
## Parameters
28+
29+
<table>
30+
<thead>
31+
<tr>
32+
<th>name</th>
33+
<th>required</th>
34+
<th>description</th>
35+
</tr>
36+
</thead>
37+
<tbody>
38+
<tr><td>owner</td><td>yes</td><td>
39+
40+
The owner of the repository. Determined from the `repository` `full_name` of the `content_reference` event.
41+
42+
</td></tr>
43+
<tr><td>repo</td><td>yes</td><td>
44+
45+
The name of the repository. Determined from the `repository` `full_name` of the `content_reference` event.
46+
47+
</td></tr>
48+
<tr><td>content_reference_id</td><td>yes</td><td>
49+
50+
The `id` of the `content_reference` event.
51+
52+
</td></tr>
53+
<tr><td>title</td><td>yes</td><td>
54+
55+
The title of the attachment
56+
57+
</td></tr>
58+
<tr><td>body</td><td>yes</td><td>
59+
60+
The body of the attachment
61+
62+
</td></tr>
63+
</tbody>
64+
</table>
65+
66+
See also: [GitHub Developer Guide documentation](https://docs.github.com/rest/reference/apps#create-a-content-attachment).

docs/codeScanning/uploadSarif.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Uploads SARIF data containing the results of a code scanning analysis to make th
1212

1313
There are two places where you can upload code scanning results.
1414

15-
- If you upload to a pull request, for example `--ref refs/pull/42/merge` or `--ref refs/pull/42/head`, then the results appear as alerts in a pull request check. For more information, see "[Triaging code scanning alerts in pull requests](/github/finding-security-vulnerabilities-and-errors-in-your-code/triaging-code-scanning-alerts-in-pull-requests)."
16-
- If you upload to a branch, for example `--ref refs/heads/my-branch`, then the results appear in the **Security** tab for your repository. For more information, see "[Managing code scanning alerts for your repository](/github/finding-security-vulnerabilities-and-errors-in-your-code/managing-code-scanning-alerts-for-your-repository#viewing-the-alerts-for-a-repository)."
15+
- If you upload to a pull request, for example `--ref refs/pull/42/merge` or `--ref refs/pull/42/head`, then the results appear as alerts in a pull request check. For more information, see "[Triaging code scanning alerts in pull requests](/code-security/secure-coding/triaging-code-scanning-alerts-in-pull-requests)."
16+
- If you upload to a branch, for example `--ref refs/heads/my-branch`, then the results appear in the **Security** tab for your repository. For more information, see "[Managing code scanning alerts for your repository](/code-security/secure-coding/managing-code-scanning-alerts-for-your-repository#viewing-the-alerts-for-a-repository)."
1717

1818
You must compress the SARIF-formatted analysis data that you want to upload, using `gzip`, and then encode it as a Base64 format string. For example:
1919

@@ -67,7 +67,7 @@ The full Git reference, formatted as `refs/heads/<branch name>`,
6767
</td></tr>
6868
<tr><td>sarif</td><td>yes</td><td>
6969

70-
A Base64 string representing the SARIF file to upload. You must first compress your SARIF file using [`gzip`](http://www.gnu.org/software/gzip/manual/gzip.html) and then translate the contents of the file into a Base64 encoding string. For more information, see "[SARIF support for code scanning](https://docs.github.com/github/finding-security-vulnerabilities-and-errors-in-your-code/sarif-support-for-code-scanning)."
70+
A Base64 string representing the SARIF file to upload. You must first compress your SARIF file using [`gzip`](http://www.gnu.org/software/gzip/manual/gzip.html) and then translate the contents of the file into a Base64 encoding string. For more information, see "[SARIF support for code scanning](https://docs.github.com/code-security/secure-coding/sarif-support-for-code-scanning)."
7171

7272
</td></tr>
7373
<tr><td>checkout_uri</td><td>no</td><td>

docs/projects/createCard.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ type: API method
88

99
# Create a project card
1010

11-
**Note**: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. For this reason, "Issues" endpoints may return both issues and pull requests in the response. You can identify pull requests by the `pull_request` key.
12-
13-
Be aware that the `id` of a pull request returned from "Issues" endpoints will be an _issue id_. To find out the pull request id, use the "[List pull requests](https://docs.github.com/rest/reference/pulls#list-pull-requests)" endpoint.
14-
1511
```js
1612
octokit.rest.projects.createCard({
1713
column_id,

docs/reactions/createForRelease.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
name: Create reaction for a release
3+
example: octokit.rest.reactions.createForRelease({ owner, repo, release_id, content })
4+
route: POST /repos/{owner}/{repo}/releases/{release_id}/reactions
5+
scope: reactions
6+
type: API method
7+
---
8+
9+
# Create reaction for a release
10+
11+
Create a reaction to a [release](https://docs.github.com/rest/reference/repos#releases). A response with a `Status: 200 OK` means that you already added the reaction type to this release.
12+
13+
```js
14+
octokit.rest.reactions.createForRelease({
15+
owner,
16+
repo,
17+
release_id,
18+
content,
19+
});
20+
```
21+
22+
## Parameters
23+
24+
<table>
25+
<thead>
26+
<tr>
27+
<th>name</th>
28+
<th>required</th>
29+
<th>description</th>
30+
</tr>
31+
</thead>
32+
<tbody>
33+
<tr><td>owner</td><td>yes</td><td>
34+
35+
</td></tr>
36+
<tr><td>repo</td><td>yes</td><td>
37+
38+
</td></tr>
39+
<tr><td>release_id</td><td>yes</td><td>
40+
41+
release_id parameter
42+
43+
</td></tr>
44+
<tr><td>content</td><td>yes</td><td>
45+
46+
The [reaction type](https://docs.github.com/rest/reference/reactions#reaction-types) to add to the release.
47+
48+
</td></tr>
49+
</tbody>
50+
</table>
51+
52+
See also: [GitHub Developer Guide documentation](https://docs.github.com/rest/reference/reactions/#create-reaction-for-a-release).

docs/repos/compareCommits.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type: API method
88

99
# Compare two commits
1010

11-
Both `:base` and `:head` must be branch names in `:repo`. To compare branches across other repositories in the same network as `:repo`, use the format `<USERNAME>:branch`.
11+
**Deprecated**: Use `repos.compareCommitsWithBasehead()` (`GET /repos/{owner}/{repo}/compare/{basehead}`) instead. Both `:base` and `:head` must be branch names in `:repo`. To compare branches across other repositories in the same network as `:repo`, use the format `<USERNAME>:branch`.
1212

1313
The response from the API is equivalent to running the `git log base..head` command; however, commits are returned in chronological order. Pass the appropriate [media type](https://docs.github.com/rest/overview/media-types/#commits-commit-comparison-and-pull-requests) to fetch diff and patch formats.
1414

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
name: Compare two commits
3+
example: octokit.rest.repos.compareCommitsWithBasehead({ owner, repo, basehead })
4+
route: GET /repos/{owner}/{repo}/compare/{basehead}
5+
scope: repos
6+
type: API method
7+
---
8+
9+
# Compare two commits
10+
11+
The `basehead` param is comprised of two parts: `base` and `head`. Both must be branch names in `repo`. To compare branches across other repositories in the same network as `repo`, use the format `<USERNAME>:branch`.
12+
13+
The response from the API is equivalent to running the `git log base..head` command; however, commits are returned in chronological order. Pass the appropriate [media type](https://docs.github.com/rest/overview/media-types/#commits-commit-comparison-and-pull-requests) to fetch diff and patch formats.
14+
15+
The response also includes details on the files that were changed between the two commits. This includes the status of the change (for example, if a file was added, removed, modified, or renamed), and details of the change itself. For example, files with a `renamed` status have a `previous_filename` field showing the previous filename of the file, and files with a `modified` status have a `patch` field showing the changes made to the file.
16+
17+
**Working with large comparisons**
18+
19+
To process a response with a large number of commits, you can use (`per_page` or `page`) to paginate the results. When using paging, the list of changed files is only returned with page 1, but includes all changed files for the entire comparison. For more information on working with pagination, see "[Traversing with pagination](/rest/guides/traversing-with-pagination)."
20+
21+
When calling this API without any paging parameters (`per_page` or `page`), the returned list is limited to 250 commits and the last commit in the list is the most recent of the entire comparison. When a paging parameter is specified, the first commit in the returned list of each page is the earliest.
22+
23+
**Signature verification object**
24+
25+
The response will include a `verification` object that describes the result of verifying the commit's signature. The following fields are included in the `verification` object:
26+
27+
| Name | Type | Description |
28+
| ----------- | --------- | ------------------------------------------------------------------------------------------------ |
29+
| `verified` | `boolean` | Indicates whether GitHub considers the signature in this commit to be verified. |
30+
| `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. |
31+
| `signature` | `string` | The signature that was extracted from the commit. |
32+
| `payload` | `string` | The value that was signed. |
33+
34+
These are the possible values for `reason` in the `verification` object:
35+
36+
| Value | Description |
37+
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
38+
| `expired_key` | The key that made the signature is expired. |
39+
| `not_signing_key` | The "signing" flag is not among the usage flags in the GPG key that made the signature. |
40+
| `gpgverify_error` | There was an error communicating with the signature verification service. |
41+
| `gpgverify_unavailable` | The signature verification service is currently unavailable. |
42+
| `unsigned` | The object does not include a signature. |
43+
| `unknown_signature_type` | A non-PGP signature was found in the commit. |
44+
| `no_user` | No user was associated with the `committer` email address in the commit. |
45+
| `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on her/his account. |
46+
| `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. |
47+
| `unknown_key` | The key that made the signature has not been registered with any user's account. |
48+
| `malformed_signature` | There was an error parsing the signature. |
49+
| `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. |
50+
| `valid` | None of the above errors applied, so the signature is considered to be verified. |
51+
52+
```js
53+
octokit.rest.repos.compareCommitsWithBasehead({
54+
owner,
55+
repo,
56+
basehead,
57+
});
58+
```
59+
60+
## Parameters
61+
62+
<table>
63+
<thead>
64+
<tr>
65+
<th>name</th>
66+
<th>required</th>
67+
<th>description</th>
68+
</tr>
69+
</thead>
70+
<tbody>
71+
<tr><td>owner</td><td>yes</td><td>
72+
73+
</td></tr>
74+
<tr><td>repo</td><td>yes</td><td>
75+
76+
</td></tr>
77+
<tr><td>page</td><td>no</td><td>
78+
79+
Page number of the results to fetch.
80+
81+
</td></tr>
82+
<tr><td>per_page</td><td>no</td><td>
83+
84+
Results per page (max 100)
85+
86+
</td></tr>
87+
<tr><td>basehead</td><td>yes</td><td>
88+
89+
The base branch and head branch to compare. This parameter expects the format `{base}...{head}`.
90+
91+
</td></tr>
92+
</tbody>
93+
</table>
94+
95+
See also: [GitHub Developer Guide documentation](https://docs.github.com/rest/reference/repos#compare-two-commits).

docs/repos/listPublic.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ type: API method
1010

1111
Lists all public repositories in the order that they were created.
1212

13-
Notes:
13+
Note:
1414

15-
- For GitHub Enterprise Server and GitHub AE, this endpoint will only list repositories available to all users on the enterprise.
15+
- For GitHub Enterprise Server, this endpoint will only list repositories available to all users on the enterprise.
1616
- Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header) to get the URL for the next page of repositories.
1717

1818
```js

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"author": "Gregor Martynus (https://twitter.com/gr2m)",
2525
"license": "MIT",
2626
"dependencies": {
27-
"@octokit/types": "^6.15.0",
27+
"@octokit/types": "^6.16.0",
2828
"deprecation": "^2.3.1"
2929
},
3030
"devDependencies": {

0 commit comments

Comments
 (0)