Skip to content

Commit cdae0bb

Browse files
committed
Merge branch 'trunk' into speed-extension-list
2 parents bf34147 + 6fbe6d9 commit cdae0bb

File tree

121 files changed

+9223
-973
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+9223
-973
lines changed

.devcontainer/devcontainer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extensions": [
3+
"golang.go"
4+
]
5+
}

.github/workflows/codeql.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ on:
1010
schedule:
1111
- cron: "0 0 * * 0"
1212

13+
permissions:
14+
actions: read # for github/codeql-action/init to get workflow details
15+
contents: read # for actions/checkout to fetch code
16+
security-events: write # for github/codeql-action/analyze to upload SARIF results
17+
1318
jobs:
1419
CodeQL-Build:
1520
runs-on: ubuntu-latest

.github/workflows/go.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Tests
22
on: [push, pull_request]
3+
4+
permissions:
5+
contents: read
6+
37
jobs:
48
build:
59
strategy:
@@ -17,14 +21,13 @@ jobs:
1721
- name: Check out code
1822
uses: actions/checkout@v3
1923

20-
- name: Cache Go modules
21-
uses: actions/cache@v2
24+
- name: Restore Go modules cache
25+
uses: actions/cache@v3
2226
with:
23-
path: ~/go
24-
key: ${{ runner.os }}-build-${{ hashFiles('go.mod') }}
27+
path: ~/go/pkg/mod
28+
key: go-${{ runner.os }}-${{ hashFiles('go.mod') }}
2529
restore-keys: |
26-
${{ runner.os }}-build-
27-
${{ runner.os }}-
30+
go-${{ runner.os }}-
2831
2932
- name: Download dependencies
3033
run: go mod download

.github/workflows/issueauto.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@ name: Issue Automation
22
on:
33
issues:
44
types: [opened]
5+
6+
permissions:
7+
contents: none
8+
issues: write
9+
510
jobs:
611
issue-auto:
712
runs-on: ubuntu-latest
813
steps:
914
- name: label incoming issue
1015
env:
11-
GH_REPO: ${{ github.repository }}
12-
GH_TOKEN: ${{ secrets.AUTOMATION_TOKEN }}
13-
ISSUENUM: ${{ github.event.issue.number }}
14-
ISSUEAUTHOR: ${{ github.event.issue.user.login }}
16+
GH_REPO: ${{ github.repository }}
17+
GH_TOKEN: ${{ secrets.AUTOMATION_TOKEN }}
18+
ISSUENUM: ${{ github.event.issue.number }}
19+
ISSUEAUTHOR: ${{ github.event.issue.user.login }}
1520
run: |
1621
if ! gh api orgs/cli/public_members/$ISSUEAUTHOR --silent 2>/dev/null
1722
then

.github/workflows/lint.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
- go.mod
1212
- go.sum
1313

14+
permissions:
15+
contents: read
16+
1417
jobs:
1518
lint:
1619
runs-on: ubuntu-latest
@@ -24,12 +27,20 @@ jobs:
2427
- name: Check out code
2528
uses: actions/checkout@v3
2629

30+
- name: Restore Go modules cache
31+
uses: actions/cache@v3
32+
with:
33+
path: ~/go/pkg/mod
34+
key: go-${{ runner.os }}-${{ hashFiles('go.mod') }}
35+
restore-keys: |
36+
go-${{ runner.os }}-
37+
2738
- name: Verify dependencies
2839
run: |
2940
go mod verify
3041
go mod download
3142
32-
LINT_VERSION=1.39.0
43+
LINT_VERSION=1.44.2
3344
curl -fsSL https://github.com/golangci/golangci-lint/releases/download/v${LINT_VERSION}/golangci-lint-${LINT_VERSION}-linux-amd64.tar.gz | \
3445
tar xz --strip-components 1 --wildcards \*/golangci-lint
3546
mkdir -p bin && mv golangci-lint bin/

.github/workflows/prauto.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ name: PR Automation
22
on:
33
pull_request_target:
44
types: [ready_for_review, opened, reopened]
5+
6+
permissions:
7+
contents: none
8+
issues: write
9+
pull-requests: write
10+
511
jobs:
612
pr-auto:
713
runs-on: ubuntu-latest

.github/workflows/releases.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
tags:
66
- "v*"
77

8+
permissions:
9+
contents: write # publishing releases
10+
repository-projects: write # move cards between columns
11+
812
jobs:
913
goreleaser:
1014
runs-on: ubuntu-latest

api/client.go

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,41 +316,55 @@ func graphQLClient(h *http.Client, hostname string) *graphql.Client {
316316

317317
// REST performs a REST request and parses the response.
318318
func (c Client) REST(hostname string, method string, p string, body io.Reader, data interface{}) error {
319+
_, err := c.RESTWithNext(hostname, method, p, body, data)
320+
return err
321+
}
322+
323+
func (c Client) RESTWithNext(hostname string, method string, p string, body io.Reader, data interface{}) (string, error) {
319324
req, err := http.NewRequest(method, restURL(hostname, p), body)
320325
if err != nil {
321-
return err
326+
return "", err
322327
}
323328

324329
req.Header.Set("Content-Type", "application/json; charset=utf-8")
325330

326331
resp, err := c.http.Do(req)
327332
if err != nil {
328-
return err
333+
return "", err
329334
}
330335
defer resp.Body.Close()
331336

332337
success := resp.StatusCode >= 200 && resp.StatusCode < 300
333338
if !success {
334-
return HandleHTTPError(resp)
339+
return "", HandleHTTPError(resp)
335340
}
336341

337342
if resp.StatusCode == http.StatusNoContent {
338-
return nil
343+
return "", nil
339344
}
340345

341346
b, err := ioutil.ReadAll(resp.Body)
342347
if err != nil {
343-
return err
348+
return "", err
344349
}
345350

346351
err = json.Unmarshal(b, &data)
347352
if err != nil {
348-
return err
353+
return "", err
349354
}
350355

351-
return nil
356+
var next string
357+
for _, m := range linkRE.FindAllStringSubmatch(resp.Header.Get("Link"), -1) {
358+
if len(m) > 2 && m[2] == "next" {
359+
next = m[1]
360+
}
361+
}
362+
363+
return next, nil
352364
}
353365

366+
var linkRE = regexp.MustCompile(`<([^>]+)>;\s*rel="([^"]+)"`)
367+
354368
func restURL(hostname string, pathOrURL string) string {
355369
if strings.HasPrefix(pathOrURL, "https://") || strings.HasPrefix(pathOrURL, "http://") {
356370
return pathOrURL

api/queries_repo.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type Repository struct {
4646
MergeCommitAllowed bool
4747
SquashMergeAllowed bool
4848
RebaseMergeAllowed bool
49+
AutoMergeAllowed bool
4950

5051
ForkCount int
5152
StargazerCount int
@@ -68,6 +69,7 @@ type Repository struct {
6869
IsArchived bool
6970
IsEmpty bool
7071
IsFork bool
72+
ForkingAllowed bool
7173
IsInOrganization bool
7274
IsMirror bool
7375
IsPrivate bool
@@ -81,6 +83,7 @@ type Repository struct {
8183
ViewerPermission string
8284
ViewerPossibleCommitEmails []string
8385
ViewerSubscription string
86+
Visibility string
8487

8588
RepositoryTopics struct {
8689
Nodes []struct {

cmd/gh/main.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func mainRun() exitCode {
5858
updateMessageChan <- rel
5959
}()
6060

61-
hasDebug := os.Getenv("DEBUG") != ""
61+
hasDebug, _ := utils.IsDebugEnabled()
6262

6363
cmdFactory := factory.New(buildVersion)
6464
stderr := cmdFactory.IOStreams.ErrOut
@@ -327,8 +327,10 @@ func checkForUpdate(currentVersion string) (*update.ReleaseInfo, error) {
327327
// does not depend on user configuration
328328
func basicClient(currentVersion string) (*api.Client, error) {
329329
var opts []api.ClientOption
330-
if verbose := os.Getenv("DEBUG"); verbose != "" {
331-
opts = append(opts, apiVerboseLog())
330+
if isVerbose, debugValue := utils.IsDebugEnabled(); isVerbose {
331+
colorize := utils.IsTerminal(os.Stderr)
332+
logTraffic := strings.Contains(debugValue, "api")
333+
opts = append(opts, api.VerboseLog(colorable.NewColorable(os.Stderr), logTraffic, colorize))
332334
}
333335
opts = append(opts, api.AddHeader("User-Agent", fmt.Sprintf("GitHub CLI %s", currentVersion)))
334336

@@ -344,12 +346,6 @@ func basicClient(currentVersion string) (*api.Client, error) {
344346
return api.NewClient(opts...), nil
345347
}
346348

347-
func apiVerboseLog() api.ClientOption {
348-
logTraffic := strings.Contains(os.Getenv("DEBUG"), "api")
349-
colorize := utils.IsTerminal(os.Stderr)
350-
return api.VerboseLog(colorable.NewColorable(os.Stderr), logTraffic, colorize)
351-
}
352-
353349
func isRecentRelease(publishedAt time.Time) bool {
354350
return !publishedAt.IsZero() && time.Since(publishedAt) < time.Hour*24
355351
}

0 commit comments

Comments
 (0)