@osdlc/typed-gh 0.7.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/CONTRIBUTING.md +1 -1
- package/README.md +116 -92
- package/SECURITY.md +4 -4
- package/dist/async.d.ts +28 -27
- package/dist/async.js +37 -43
- package/dist/doors.d.ts +25 -23
- package/dist/doors.js +29 -27
- package/dist/failure.d.ts +8 -8
- package/dist/failure.js +6 -6
- package/dist/index.d.ts +14 -14
- package/dist/index.js +15 -15
- package/dist/parse.d.ts +21 -21
- package/dist/parse.js +34 -36
- package/dist/repo.d.ts +13 -13
- package/dist/repo.js +13 -13
- package/dist/run.d.ts +36 -0
- package/dist/run.js +48 -0
- package/dist/sync.d.ts +66 -64
- package/dist/sync.js +71 -78
- package/dist/types.d.ts +31 -32
- package/dist/types.js +8 -8
- package/dist/verbs.d.ts +122 -122
- package/dist/verbs.js +128 -112
- package/package.json +5 -5
package/dist/verbs.d.ts
CHANGED
|
@@ -1,66 +1,67 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The verb table
|
|
2
|
+
* The verb table: every `gh` call this library knows, as data.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* the other's parsing.
|
|
4
|
+
* It has the same shape as `@osdlc/typed-git`'s. A {@link GhVerb} pairs the
|
|
5
|
+
* argv to run with the function that reads the result, and nothing here
|
|
6
|
+
* starts a process. So the sync client, the async client and callers with
|
|
7
|
+
* their own runner all use the same definitions and the same parsing.
|
|
9
8
|
*
|
|
10
9
|
* `checked` marks a verb the runner throws for on a non-zero exit, with
|
|
11
|
-
* stderr
|
|
12
|
-
* unchecked and `parse`
|
|
13
|
-
*
|
|
14
|
-
* `doors.ts`) instead
|
|
15
|
-
* `absent` or is a `probe`.
|
|
10
|
+
* stderr. That is every mutation, and `prDiff`, which is a read. Other
|
|
11
|
+
* queries run unchecked, and `parse` turns a failure into `null`, which is
|
|
12
|
+
* what `soft` returns. The clients' methods that throw read them through
|
|
13
|
+
* `settle` (see `doors.ts`) instead. There a failure throws, except where the
|
|
14
|
+
* verb declares `absent` or is a `probe`.
|
|
16
15
|
*/
|
|
17
16
|
import { type CommandResult } from '@osdlc/command-seam';
|
|
18
17
|
import type { IssueRow, Label, PrSearchHit, PullRequest, Repository } from './types.ts';
|
|
19
18
|
/** One `gh` invocation: what to run, and how to read what came back. */
|
|
20
19
|
export interface GhVerb<T> {
|
|
21
20
|
argv: string[];
|
|
22
|
-
/** True for every mutation and for `prDiff
|
|
21
|
+
/** True for every mutation and for `prDiff`: throw on a non-zero exit instead of parsing. */
|
|
23
22
|
checked: boolean;
|
|
24
23
|
/**
|
|
25
|
-
* True when the call only reads
|
|
26
|
-
* is read-only, and so is `prDiff
|
|
24
|
+
* True when the call only reads and changes nothing on GitHub. Every query
|
|
25
|
+
* is read-only, and so is `prDiff`. No mutation is. A caller that
|
|
27
26
|
* keeps an allowlist of safe calls can check this before running a verb.
|
|
28
27
|
*/
|
|
29
28
|
readOnly: boolean;
|
|
30
29
|
/** Written to the child's stdin, for a verb whose payload is too large or structured for argv. */
|
|
31
30
|
input?: string | undefined;
|
|
32
31
|
/**
|
|
33
|
-
* Variables to set on the child, for a target gh
|
|
34
|
-
* on `gh search` and `gh repo list`.
|
|
32
|
+
* Variables to set on the child process, for a target gh has no flag for:
|
|
33
|
+
* `GH_HOST` on `gh search` and `gh repo list`.
|
|
35
34
|
*/
|
|
36
35
|
env?: Record<string, string> | undefined;
|
|
37
36
|
/**
|
|
38
|
-
* True for a read whose failure is part of its answer
|
|
39
|
-
* `authStatus` and `api` return what `parse` makes of any result, in
|
|
40
|
-
*
|
|
37
|
+
* True for a read whose failure is part of its answer. `installed`,
|
|
38
|
+
* `authStatus` and `api` return what `parse` makes of any result, in all
|
|
39
|
+
* three call styles. Other reads throw from the plain method when gh exits
|
|
40
|
+
* non-zero.
|
|
41
41
|
*/
|
|
42
42
|
probe?: boolean | undefined;
|
|
43
43
|
/**
|
|
44
44
|
* For a read of one thing: whether a non-zero result means GitHub has no such
|
|
45
|
-
* thing (`prView`, `issueView`, `repoView`). The plain
|
|
46
|
-
* `parse` makes of it, `null`, because
|
|
47
|
-
* results fail the call.
|
|
45
|
+
* thing (`prView`, `issueView`, `repoView`). The plain method then returns
|
|
46
|
+
* what `parse` makes of it, `null`, because a missing item is an answer.
|
|
47
|
+
* Other non-zero results fail the call.
|
|
48
48
|
*/
|
|
49
49
|
absent?: ((result: CommandResult) => boolean) | undefined;
|
|
50
50
|
parse(result: CommandResult): T;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
* The repository and host a verb talks to. Both are optional
|
|
54
|
-
* gh uses the repository of the clone at the client's working directory
|
|
55
|
-
*
|
|
53
|
+
* The repository and host a verb talks to. Both are optional. With no `repo`,
|
|
54
|
+
* gh uses the repository of the clone at the client's working directory. With
|
|
55
|
+
* no `hostname`, it uses gh's default host.
|
|
56
56
|
*/
|
|
57
57
|
export interface GhTarget {
|
|
58
58
|
/** `owner/name`. */
|
|
59
59
|
repo?: string | undefined;
|
|
60
60
|
/**
|
|
61
61
|
* A GitHub host: `github.com`, a GitHub Enterprise Server host such as
|
|
62
|
-
* `github.acme.com`, or a `<tenant>.ghe.com` host. Other forges are
|
|
63
|
-
*
|
|
62
|
+
* `github.acme.com`, or a `<tenant>.ghe.com` host. Other forges are not
|
|
63
|
+
* supported, because gh supports only GitHub's API. `''` means the same as
|
|
64
|
+
* `undefined`, so a value read from config can be passed as it is.
|
|
64
65
|
*/
|
|
65
66
|
hostname?: string | undefined;
|
|
66
67
|
}
|
|
@@ -71,35 +72,35 @@ export interface GhTarget {
|
|
|
71
72
|
*/
|
|
72
73
|
export declare function checkTarget(target: GhTarget | undefined): void;
|
|
73
74
|
/**
|
|
74
|
-
* The
|
|
75
|
+
* The smallest useful set: enough to identify a PR and nothing more.
|
|
75
76
|
*
|
|
76
|
-
*
|
|
77
|
-
* `
|
|
78
|
-
*
|
|
79
|
-
*
|
|
77
|
+
* Use it when the question is "which PR is this branch?". `mergeable` and
|
|
78
|
+
* `mergeStateStatus` are left out on purpose. GitHub computes them per PR
|
|
79
|
+
* when asked, so asking for them across many branches can hit the rate
|
|
80
|
+
* limit.
|
|
80
81
|
*/
|
|
81
82
|
export declare const PR_REF_FIELDS: readonly ["number", "state", "headRefName", "url"];
|
|
82
83
|
/**
|
|
83
|
-
* The
|
|
84
|
-
*
|
|
84
|
+
* The smaller field set for triage: enough to decide what to do with a PR,
|
|
85
|
+
* without its body, comments, reviews, or check rollup.
|
|
85
86
|
*
|
|
86
|
-
* `mergeable` and `mergeStateStatus` are the
|
|
87
|
-
* them
|
|
88
|
-
* PRs
|
|
87
|
+
* `mergeable` and `mergeStateStatus` are the costly pair. GitHub computes
|
|
88
|
+
* them only when asked and answers `UNKNOWN` until it has. So a first query
|
|
89
|
+
* over many PRs often needs a retry. `prViewSettled` on the clients does it.
|
|
89
90
|
*/
|
|
90
91
|
export declare const PR_LIST_FIELDS: readonly ["number", "state", "title", "url", "isDraft", "baseRefName", "headRefName", "headRefOid", "isCrossRepository", "mergeable", "mergeStateStatus", "reviewDecision", "author", "labels", "mergedAt", "createdAt", "updatedAt"];
|
|
91
|
-
/** {@link PR_LIST_FIELDS} plus the
|
|
92
|
+
/** {@link PR_LIST_FIELDS} plus the costly fields, for a single PR. */
|
|
92
93
|
export declare const PR_VIEW_FIELDS: readonly ["number", "state", "title", "url", "isDraft", "baseRefName", "headRefName", "headRefOid", "isCrossRepository", "mergeable", "mergeStateStatus", "reviewDecision", "author", "labels", "mergedAt", "createdAt", "updatedAt", "body", "comments", "reviews", "statusCheckRollup"];
|
|
93
94
|
/**
|
|
94
95
|
* A list query's answer: the rows, and whether `limit` cut the list short.
|
|
95
|
-
* The verb asks gh for one row more than `limit
|
|
96
|
+
* The verb asks gh for one row more than `limit`. `truncated` is true when
|
|
96
97
|
* that row came back, and `rows` holds at most `limit`.
|
|
97
98
|
*/
|
|
98
99
|
export interface ListResult<T> {
|
|
99
100
|
rows: T[];
|
|
100
101
|
truncated: boolean;
|
|
101
102
|
}
|
|
102
|
-
/** What to narrow a listing to. Every filter is optional
|
|
103
|
+
/** What to narrow a listing to. Every filter is optional. None means "all open". */
|
|
103
104
|
export interface PrListOptions {
|
|
104
105
|
/**
|
|
105
106
|
* `owner/name` to list from, instead of the repository at the client's cwd.
|
|
@@ -112,7 +113,7 @@ export interface PrListOptions {
|
|
|
112
113
|
/**
|
|
113
114
|
* Head branch filter, exact: `task/foo` does not match `task/foo-2`. Passed
|
|
114
115
|
* as gh's `--head`, and the rows are filtered again on `headRefName`. Two
|
|
115
|
-
* forks can share a branch name
|
|
116
|
+
* forks can share a branch name. Ask for `headRepositoryOwner` to tell them
|
|
116
117
|
* apart.
|
|
117
118
|
*/
|
|
118
119
|
head?: string | undefined;
|
|
@@ -120,13 +121,13 @@ export interface PrListOptions {
|
|
|
120
121
|
search?: string | undefined;
|
|
121
122
|
author?: string | undefined;
|
|
122
123
|
limit?: number | undefined;
|
|
123
|
-
/** Field subset
|
|
124
|
+
/** Field subset. Defaults to {@link PR_LIST_FIELDS}. `number` is always requested. */
|
|
124
125
|
fields?: readonly string[] | undefined;
|
|
125
126
|
}
|
|
126
|
-
/** `gh pr list
|
|
127
|
+
/** `gh pr list …`: open PRs by default. `opts.repo` overrides the target's repo. */
|
|
127
128
|
export declare function prList(opts?: PrListOptions, target?: GhTarget): GhVerb<ListResult<PullRequest> | null>;
|
|
128
129
|
/**
|
|
129
|
-
* `gh pr view <number|branch|url> --json
|
|
130
|
+
* `gh pr view <number|branch|url> --json …`: one PR, with the full field set
|
|
130
131
|
* by default.
|
|
131
132
|
*
|
|
132
133
|
* A branch is the PR whose head is that branch, as gh picks it. A URL names
|
|
@@ -137,13 +138,13 @@ export declare function prView(ref: number | string, fields?: readonly string[],
|
|
|
137
138
|
/**
|
|
138
139
|
* Open PRs whose head is exactly `branch`.
|
|
139
140
|
*
|
|
140
|
-
* The
|
|
141
|
-
*
|
|
141
|
+
* The usual way to ask "which PR is this branch?". It uses the smallest field
|
|
142
|
+
* set and a small limit. More than one row comes back only when forks
|
|
142
143
|
* share the branch name.
|
|
143
144
|
*/
|
|
144
145
|
export declare function openPrsForBranch(branch: string, limit?: number, target?: GhTarget): GhVerb<ListResult<PullRequest> | null>;
|
|
145
146
|
/**
|
|
146
|
-
* `gh pr view <n> --json body -q .body
|
|
147
|
+
* `gh pr view <n> --json body -q .body`: just the PR body. Null when gh
|
|
147
148
|
* failed. gh's `-q` output ends with a newline that is not part of the body,
|
|
148
149
|
* so every trailing `\r` and `\n` is trimmed (including any that were part of
|
|
149
150
|
* the body, such as the `\r\n` of a body saved with CRLF line endings).
|
|
@@ -153,13 +154,15 @@ export declare function prBody(number: number, target?: GhTarget): GhVerb<string
|
|
|
153
154
|
export interface ApiResponse {
|
|
154
155
|
/** True iff gh exited 0 and the status is below 400 (2xx, or a 304 on a conditional GET). */
|
|
155
156
|
ok: boolean;
|
|
156
|
-
/** HTTP status
|
|
157
|
+
/** HTTP status, read only when headers were requested (`etag` or `includeHeaders`, which pass `-i`). Without them it is made up from the exit code (200 on exit 0, 0 on failure). */
|
|
157
158
|
status: number;
|
|
158
159
|
/** The response `ETag`, when headers were requested and one came back. */
|
|
159
160
|
etag: string | null;
|
|
160
|
-
/** The decoded JSON body
|
|
161
|
+
/** The decoded JSON body, whatever gh's exit code (on failure, GitHub's error object). Null when empty (such as a 304) or not valid JSON. */
|
|
161
162
|
body: unknown;
|
|
162
|
-
/**
|
|
163
|
+
/** `body.message` when the body is an object with a string `message` (GitHub's error text), else null. */
|
|
164
|
+
message: string | null;
|
|
165
|
+
/** True when a non-empty body arrived but was not valid JSON (`body` is then null). This includes a failed call with a non-JSON body. */
|
|
163
166
|
malformed: boolean;
|
|
164
167
|
/** gh's stderr, trimmed. */
|
|
165
168
|
stderr: string;
|
|
@@ -167,7 +170,7 @@ export interface ApiResponse {
|
|
|
167
170
|
error?: string | undefined;
|
|
168
171
|
}
|
|
169
172
|
/**
|
|
170
|
-
* Options for {@link api}.
|
|
173
|
+
* Options for {@link api}. All are optional. With none, the call is a plain
|
|
171
174
|
* `gh api <endpoint>` and the response carries no status or ETag.
|
|
172
175
|
*/
|
|
173
176
|
export interface ApiOptions {
|
|
@@ -178,21 +181,22 @@ export interface ApiOptions {
|
|
|
178
181
|
/**
|
|
179
182
|
* Fetch every page (`--paginate --slurp`). `body` is then the pages joined
|
|
180
183
|
* into one array when every page is an array, else the list of pages.
|
|
181
|
-
* Cannot be combined with `etag` or `includeHeaders
|
|
182
|
-
* a header block per page. `status` is
|
|
184
|
+
* Cannot be combined with `etag` or `includeHeaders`, because with `-i` gh
|
|
185
|
+
* prints a header block per page. `status` is made up from the exit code, as
|
|
186
|
+
* without `-i`.
|
|
183
187
|
*/
|
|
184
188
|
paginate?: boolean | undefined;
|
|
185
189
|
}
|
|
186
190
|
/**
|
|
187
|
-
* `gh api [-i] [-H If-None-Match: …] <endpoint
|
|
191
|
+
* `gh api [-i] [-H If-None-Match: …] <endpoint>`: a GET against the REST API. `{owner}` and
|
|
188
192
|
* `{repo}` placeholders in the endpoint are filled from the target's repo, or by gh from the
|
|
189
193
|
* cwd's repo when the target names none.
|
|
190
|
-
* Unchecked
|
|
194
|
+
* Unchecked. Failure is a value (`ok: false`), so a caller can tell a 304
|
|
191
195
|
* from an outage.
|
|
192
196
|
*/
|
|
193
197
|
export declare function api(endpoint: string, opts?: ApiOptions, target?: GhTarget): GhVerb<ApiResponse>;
|
|
194
198
|
/**
|
|
195
|
-
* A GraphQL variable
|
|
199
|
+
* A GraphQL variable. gh sends a string with `-f` and the rest with `-F`.
|
|
196
200
|
*
|
|
197
201
|
* @experimental
|
|
198
202
|
*/
|
|
@@ -206,35 +210,35 @@ export interface GraphqlOptions {
|
|
|
206
210
|
/**
|
|
207
211
|
* Follow every page (`--paginate --slurp`). The query must take
|
|
208
212
|
* `$endCursor: String` and select `pageInfo { hasNextPage endCursor }` on
|
|
209
|
-
* the one connection it pages through
|
|
213
|
+
* the one connection it pages through. gh follows only that connection.
|
|
210
214
|
*/
|
|
211
215
|
paginate?: boolean | undefined;
|
|
212
216
|
}
|
|
213
217
|
/**
|
|
214
|
-
* `gh api graphql -f query=… [--paginate --slurp]
|
|
218
|
+
* `gh api graphql -f query=… [--paginate --slurp]`: a GraphQL query.
|
|
215
219
|
*
|
|
216
|
-
* Returns each page's `data`, one entry per page (one without `paginate`)
|
|
217
|
-
*
|
|
218
|
-
* carries `errors` or lacks `data
|
|
220
|
+
* Returns each page's `data`, one entry per page (one without `paginate`).
|
|
221
|
+
* Returns null when the call failed, the output did not parse, or any page
|
|
222
|
+
* carries `errors` or lacks `data`. A partial answer counts as a failure. Read one
|
|
219
223
|
* connection across the pages with {@link nodesAt}.
|
|
220
224
|
*
|
|
221
225
|
* A string variable of exactly `{owner}` or `{repo}` is filled from the
|
|
222
226
|
* target's repo, or by gh from the clone. A mutation document throws
|
|
223
|
-
* `RangeError
|
|
227
|
+
* `RangeError`. This is a read, and changes go through `raw`.
|
|
224
228
|
*
|
|
225
229
|
* @experimental
|
|
226
230
|
*/
|
|
227
231
|
export declare function graphql(query: string, variables?: Record<string, GraphqlVariable>, opts?: GraphqlOptions, target?: GhTarget): GhVerb<unknown[] | null>;
|
|
228
232
|
/**
|
|
229
|
-
* The `nodes` of one connection, joined across {@link graphql} pages
|
|
230
|
-
* `path` into each page and
|
|
233
|
+
* The `nodes` of one connection, joined across {@link graphql} pages. It
|
|
234
|
+
* follows `path` into each page and takes its `nodes` array. Null when `pages` is
|
|
231
235
|
* null, or any page lacks the path or a `nodes` array, so a page that came
|
|
232
236
|
* back short is never read as fewer rows.
|
|
233
237
|
*
|
|
234
238
|
* @experimental
|
|
235
239
|
*/
|
|
236
240
|
export declare function nodesAt(pages: unknown[] | null, path: readonly string[]): unknown[] | null;
|
|
237
|
-
/** `gh --version
|
|
241
|
+
/** `gh --version`: checks that `gh` is installed. True when `gh` runs. */
|
|
238
242
|
export declare function installed(): GhVerb<boolean>;
|
|
239
243
|
/**
|
|
240
244
|
* What `gh auth status` said: whether it passed, and its output (stderr, else the runner's
|
|
@@ -244,11 +248,11 @@ export interface AuthStatus {
|
|
|
244
248
|
ok: boolean;
|
|
245
249
|
detail: string;
|
|
246
250
|
}
|
|
247
|
-
/** `gh auth status [--hostname <host>]
|
|
251
|
+
/** `gh auth status [--hostname <host>]`: checks credentials, for one host when the target names it. */
|
|
248
252
|
export declare function authStatus(target?: GhTarget): GhVerb<AuthStatus>;
|
|
249
253
|
/**
|
|
250
|
-
* `gh label list --json name,color,description
|
|
251
|
-
* up to `limit` (default 1000
|
|
254
|
+
* `gh label list --json name,color,description`: every label on the repo,
|
|
255
|
+
* up to `limit` (default 1000. `gh`'s own default is 30).
|
|
252
256
|
*/
|
|
253
257
|
export declare function labelList(opts?: {
|
|
254
258
|
limit?: number | undefined;
|
|
@@ -260,9 +264,9 @@ export interface IssueListOptions {
|
|
|
260
264
|
/** The most issues to return. Defaults to 200. */
|
|
261
265
|
limit?: number | undefined;
|
|
262
266
|
}
|
|
263
|
-
/** `gh issue list --json
|
|
267
|
+
/** `gh issue list --json …`: open issues, optionally by label. */
|
|
264
268
|
export declare function issueList(opts?: IssueListOptions, target?: GhTarget): GhVerb<ListResult<IssueRow> | null>;
|
|
265
|
-
/** `gh issue view <n> --json
|
|
269
|
+
/** `gh issue view <n> --json …`: one issue, same field set as {@link issueList}. */
|
|
266
270
|
export declare function issueView(number: number, target?: GhTarget): GhVerb<IssueRow | null>;
|
|
267
271
|
/** The `gh repo list`/`view --json` fields a {@link Repository} reads. */
|
|
268
272
|
export declare const REPO_FIELDS: readonly ["nameWithOwner", "description", "defaultBranchRef", "visibility", "isArchived", "url"];
|
|
@@ -270,21 +274,21 @@ export declare const REPO_FIELDS: readonly ["nameWithOwner", "description", "def
|
|
|
270
274
|
export declare const SEARCH_PR_FIELDS: readonly ["number", "title", "state", "url", "isDraft", "repository", "author", "labels", "createdAt", "updatedAt", "closedAt"];
|
|
271
275
|
/** What to narrow a repository listing to. Every filter is optional. */
|
|
272
276
|
export interface RepoListOptions {
|
|
273
|
-
/** True for archived repositories only, false to leave them out
|
|
277
|
+
/** True for archived repositories only, false to leave them out. Both when absent. */
|
|
274
278
|
archived?: boolean | undefined;
|
|
275
279
|
visibility?: 'public' | 'private' | 'internal' | undefined;
|
|
276
280
|
/** The most repositories to return. Defaults to 100. */
|
|
277
281
|
limit?: number | undefined;
|
|
278
|
-
/** Field subset
|
|
282
|
+
/** Field subset. Defaults to {@link REPO_FIELDS}. `nameWithOwner` is always asked for. */
|
|
279
283
|
fields?: readonly string[] | undefined;
|
|
280
284
|
}
|
|
281
285
|
/**
|
|
282
|
-
* `gh repo list <owner> --json
|
|
283
|
-
* from the target (`GH_HOST`)
|
|
286
|
+
* `gh repo list <owner> --json …`: an owner's repositories. The host comes
|
|
287
|
+
* from the target (`GH_HOST`). The target's repo is not used.
|
|
284
288
|
*/
|
|
285
289
|
export declare function repoList(owner: string, opts?: RepoListOptions, target?: GhTarget): GhVerb<ListResult<Repository> | null>;
|
|
286
290
|
/**
|
|
287
|
-
* `gh repo view [<[host/]owner/name>] --json
|
|
291
|
+
* `gh repo view [<[host/]owner/name>] --json …`: one repository. That is `repo`,
|
|
288
292
|
* else the target's repo, else the clone at the client's cwd.
|
|
289
293
|
*/
|
|
290
294
|
export declare function repoView(repo?: string | undefined, fields?: readonly string[], target?: GhTarget): GhVerb<Repository | null>;
|
|
@@ -294,17 +298,17 @@ export interface SearchPrsOptions {
|
|
|
294
298
|
owner?: string | undefined;
|
|
295
299
|
/** Only this `owner/name` repository. */
|
|
296
300
|
repo?: string | undefined;
|
|
297
|
-
/** `merged` is `--merged
|
|
301
|
+
/** `merged` is `--merged`. `open` and `closed` are `--state`. */
|
|
298
302
|
state?: 'open' | 'closed' | 'merged' | undefined;
|
|
299
303
|
/** The most hits to return. Defaults to 100. */
|
|
300
304
|
limit?: number | undefined;
|
|
301
|
-
/** Field subset
|
|
305
|
+
/** Field subset. Defaults to {@link SEARCH_PR_FIELDS}. `number` is always asked for. */
|
|
302
306
|
fields?: readonly string[] | undefined;
|
|
303
307
|
}
|
|
304
308
|
/**
|
|
305
|
-
* `gh search prs [flags] -- <query
|
|
309
|
+
* `gh search prs [flags] -- <query>`: pull requests across repositories,
|
|
306
310
|
* with GitHub's search syntax in `query` (it may start with `-`, as in
|
|
307
|
-
* `-label:bug`). The host comes from the target (`GH_HOST`)
|
|
311
|
+
* `-label:bug`). The host comes from the target (`GH_HOST`). The target's
|
|
308
312
|
* repo is not used, so pass `opts.repo` or `opts.owner` to narrow.
|
|
309
313
|
*/
|
|
310
314
|
export declare function searchPrs(query: string, opts?: SearchPrsOptions, target?: GhTarget): GhVerb<ListResult<PrSearchHit> | null>;
|
|
@@ -325,25 +329,25 @@ export interface CreatePrOptions {
|
|
|
325
329
|
* {@link prComment} does. A line after the URL, such as a tip, is skipped.
|
|
326
330
|
*/
|
|
327
331
|
export declare function createPr(opts: CreatePrOptions, target?: GhTarget): GhVerb<string>;
|
|
328
|
-
/** `gh pr edit <n
|
|
332
|
+
/** `gh pr edit <n>`: change the title or the body. */
|
|
329
333
|
export declare function editPr(number: number, opts: {
|
|
330
334
|
title?: string | undefined;
|
|
331
335
|
body?: string | undefined;
|
|
332
336
|
}, target?: GhTarget): GhVerb<void>;
|
|
333
|
-
/** `gh pr edit <n> --body
|
|
337
|
+
/** `gh pr edit <n> --body`: rewrite just the body. */
|
|
334
338
|
export declare function editPrBody(number: number, body: string, target?: GhTarget): GhVerb<void>;
|
|
335
|
-
/** `gh pr update-branch <n> [--rebase]
|
|
339
|
+
/** `gh pr update-branch <n> [--rebase]`: bring the head up to date with its base. */
|
|
336
340
|
export declare function prUpdateBranch(number: number, style?: 'merge' | 'rebase', target?: GhTarget): GhVerb<void>;
|
|
337
|
-
/** `gh pr ready <n> [--undo]
|
|
341
|
+
/** `gh pr ready <n> [--undo]`: mark a draft PR ready for review, or (with `draft`) convert it back to a draft. */
|
|
338
342
|
export declare function prSetDraft(number: number, draft: boolean, target?: GhTarget): GhVerb<void>;
|
|
339
343
|
/**
|
|
340
|
-
* `gh api -X PATCH repos/{owner}/{repo}/issues/comments/<id> -f body
|
|
344
|
+
* `gh api -X PATCH repos/{owner}/{repo}/issues/comments/<id> -f body=…`: rewrite one
|
|
341
345
|
* conversation comment.
|
|
342
346
|
*
|
|
343
|
-
* `commentId` is the comment's numeric REST id, as text
|
|
347
|
+
* `commentId` is the comment's numeric REST id, as text. That is the `id` that
|
|
344
348
|
* `gh api repos/{owner}/{repo}/issues/<n>/comments` returns. It is not the
|
|
345
349
|
* GraphQL node id (such as `IC_kw…`) that `gh pr view --json comments` gives
|
|
346
|
-
* in `Comment.id
|
|
350
|
+
* in `Comment.id`. The REST path answers 404 for a node id.
|
|
347
351
|
*
|
|
348
352
|
* Throws `RangeError` when `commentId` is not all digits, so a node id fails
|
|
349
353
|
* at once and no text can change which endpoint the PATCH reaches.
|
|
@@ -355,10 +359,10 @@ export declare function issueCommentEdit(commentId: string, body: string, target
|
|
|
355
359
|
export type PrMergeMethod = 'squash' | 'merge' | 'rebase';
|
|
356
360
|
/**
|
|
357
361
|
* `gh pr merge <n> --<method> --match-head-commit <sha>`. The head sha is
|
|
358
|
-
* required
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
+
* required. GitHub refuses the merge when the PR head moved since the caller
|
|
363
|
+
* checked it. So a push that lands between the check and the merge cannot be
|
|
364
|
+
* merged without review. The branch is left alone (no `--delete-branch`).
|
|
365
|
+
* Deleting it is the caller's job.
|
|
362
366
|
*/
|
|
363
367
|
export declare function prMerge(number: number, opts: {
|
|
364
368
|
method: PrMergeMethod;
|
|
@@ -368,15 +372,14 @@ export declare function prMerge(number: number, opts: {
|
|
|
368
372
|
export interface ReviewThread {
|
|
369
373
|
isResolved: boolean;
|
|
370
374
|
isOutdated: boolean;
|
|
371
|
-
/** Login of the thread's newest comment
|
|
375
|
+
/** Login of the author of the thread's newest comment. Null when the account is gone. */
|
|
372
376
|
lastCommentAuthor: string | null;
|
|
373
377
|
}
|
|
374
378
|
/**
|
|
375
379
|
* A PR's review threads over GraphQL (`gh pr view --json` has no thread
|
|
376
|
-
* field). Null
|
|
377
|
-
* expected shape, or more than 100 threads exist
|
|
378
|
-
* PR is clear to merge must
|
|
379
|
-
* threads".
|
|
380
|
+
* field). Null, never `[]`, when the call failed, the payload was not the
|
|
381
|
+
* expected shape, or more than 100 threads exist. A caller deciding whether a
|
|
382
|
+
* PR is clear to merge must tell "could not tell" from "no threads".
|
|
380
383
|
*/
|
|
381
384
|
export declare function prReviewThreads(number: number, target?: GhTarget): GhVerb<ReviewThread[] | null>;
|
|
382
385
|
/** A label to create. `color` is hex digits such as `d73a4a`. */
|
|
@@ -387,36 +390,33 @@ export interface CreateLabelOptions {
|
|
|
387
390
|
}
|
|
388
391
|
/**
|
|
389
392
|
* `gh label create <name> --color <hex> --description <text> --force`.
|
|
390
|
-
* `--force` makes it safe to repeat
|
|
393
|
+
* `--force` makes it safe to repeat. When the label already exists, its color
|
|
391
394
|
* and description are set to these instead of failing.
|
|
392
395
|
*/
|
|
393
396
|
export declare function createLabel(opts: CreateLabelOptions, target?: GhTarget): GhVerb<void>;
|
|
394
|
-
/** `gh label edit <name
|
|
397
|
+
/** `gh label edit <name>`: change the color or description. A flag not given is left out. */
|
|
395
398
|
export declare function editLabel(name: string, opts: {
|
|
396
399
|
color?: string | undefined;
|
|
397
400
|
description?: string | undefined;
|
|
398
401
|
}, target?: GhTarget): GhVerb<void>;
|
|
399
402
|
/**
|
|
400
|
-
* `gh issue edit <n> [--remove-label <current>] --add-label <new
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
* label immediately before calling this. `currentLabel` is `null` when the
|
|
413
|
-
* issue carries no prior label to remove — the `--remove-label` flag is then
|
|
414
|
-
* omitted rather than passed empty.
|
|
403
|
+
* `gh issue edit <n> [--remove-label <current>] --add-label <new>`: swap one
|
|
404
|
+
* label for another on an issue in one call. The issue is never left with
|
|
405
|
+
* neither label or both labels between the remove and the add.
|
|
406
|
+
*
|
|
407
|
+
* That covers only the call itself. `currentLabel` is whatever the caller
|
|
408
|
+
* read earlier, perhaps from a `gh issue list` minutes before. It is not read
|
|
409
|
+
* again here. If someone relabeled the issue since then, `--remove-label
|
|
410
|
+
* <currentLabel>` names a label the issue no longer has. `gh` skips that
|
|
411
|
+
* removal with no error and still adds `newLabel`. The issue then has both
|
|
412
|
+
* its current label and `newLabel`. A caller that cares reads the label again
|
|
413
|
+
* just before calling this. Pass `null` for `currentLabel` when there is no
|
|
414
|
+
* label to remove. The `--remove-label` flag is then left out.
|
|
415
415
|
*/
|
|
416
416
|
export declare function setIssueLabel(number: number, currentLabel: string | null, newLabel: string, target?: GhTarget): GhVerb<void>;
|
|
417
|
-
/** `gh pr diff <n
|
|
417
|
+
/** `gh pr diff <n>`: the PR's unified diff, as text. Checked, so an empty diff is a value and a failed call throws. */
|
|
418
418
|
export declare function prDiff(number: number, target?: GhTarget): GhVerb<string>;
|
|
419
|
-
/** `gh pr comment <n> --body <body
|
|
419
|
+
/** `gh pr comment <n> --body <body>`: post a conversation comment, returning the URL gh prints ('' if none). */
|
|
420
420
|
export declare function prComment(number: number, body: string, target?: GhTarget): GhVerb<string>;
|
|
421
421
|
/**
|
|
422
422
|
* One inline comment of a review: a line on the right (new) side of the diff.
|
|
@@ -435,7 +435,7 @@ export interface ReviewComment {
|
|
|
435
435
|
* @experimental
|
|
436
436
|
*/
|
|
437
437
|
export interface CreateReviewOptions {
|
|
438
|
-
/** The commit the review is
|
|
438
|
+
/** The commit the review is on. Line numbers refer to the diff at this sha. */
|
|
439
439
|
commitId: string;
|
|
440
440
|
/** The review summary. GitHub rejects a review whose body and comments are both empty. */
|
|
441
441
|
body: string;
|
|
@@ -443,10 +443,10 @@ export interface CreateReviewOptions {
|
|
|
443
443
|
}
|
|
444
444
|
/**
|
|
445
445
|
* Create a PR review with inline comments, returning the review's URL (empty
|
|
446
|
-
* when GitHub's reply carried none). The event is always `COMMENT
|
|
447
|
-
* library does not offer a way to approve or request changes.
|
|
446
|
+
* when GitHub's reply carried none). The event is always `COMMENT`. This
|
|
447
|
+
* library does not offer a way to approve or request changes. It goes through
|
|
448
448
|
* `gh api` with the payload on stdin, because `gh pr review` cannot attach
|
|
449
|
-
*
|
|
449
|
+
* comments to lines. `{owner}`/`{repo}` come from the target's repo, or
|
|
450
450
|
* are filled in by `gh` from the client's working directory.
|
|
451
451
|
*
|
|
452
452
|
* @experimental
|
|
@@ -471,9 +471,9 @@ export declare function branchPrFields(fields: readonly string[]): string[];
|
|
|
471
471
|
/**
|
|
472
472
|
* True when GitHub has not finished computing this PR's mergeability.
|
|
473
473
|
*
|
|
474
|
-
* The answer
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
474
|
+
* The first answer may not be final. GitHub starts the merge computation when
|
|
475
|
+
* asked and answers `UNKNOWN` until it finishes. A caller that treats the
|
|
476
|
+
* first `UNKNOWN` as final misjudges a PR whose computation is slow. So ask a
|
|
477
|
+
* few times before trusting it.
|
|
478
478
|
*/
|
|
479
479
|
export declare function needsMergeStateRetry(pr: PullRequest): boolean;
|