Skip to content

Commit 2e3400a

Browse files
authored
Merge branch 'trunk' into jg/event-handling
2 parents c70e2a3 + bb4fc52 commit 2e3400a

File tree

110 files changed

+4602
-997
lines changed

Some content is hidden

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

110 files changed

+4602
-997
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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@ 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
1621

1722
steps:
1823
- name: Check out code
19-
uses: actions/checkout@v2
24+
uses: actions/checkout@v3
2025

2126
- name: Initialize CodeQL
2227
uses: github/codeql-action/init@v1

.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:
@@ -15,16 +19,15 @@ jobs:
1519
go-version: 1.16
1620

1721
- name: Check out code
18-
uses: actions/checkout@v2
22+
uses: actions/checkout@v3
1923

20-
- name: Cache Go modules
24+
- name: Restore Go modules cache
2125
uses: actions/cache@v2
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: 13 additions & 2 deletions
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
@@ -22,14 +25,22 @@ jobs:
2225
go-version: 1.16
2326

2427
- name: Check out code
25-
uses: actions/checkout@v2
28+
uses: actions/checkout@v3
29+
30+
- name: Restore Go modules cache
31+
uses: actions/cache@v2
32+
with:
33+
path: ~/go/pkg/mod
34+
key: go-${{ runner.os }}-${{ hashFiles('go.mod') }}
35+
restore-keys: |
36+
go-${{ runner.os }}-
2637
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: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ 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
1115
steps:
1216
- name: Checkout
13-
uses: actions/checkout@v2
17+
uses: actions/checkout@v3
1418
- name: Set up Go 1.16
1519
uses: actions/setup-go@v2
1620
with:
@@ -27,6 +31,13 @@ jobs:
2731
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
2832
- name: Install osslsigncode
2933
run: sudo apt-get install -y osslsigncode
34+
- name: Obtain signing cert
35+
run: |
36+
cert="$(mktemp -t cert.XXX)"
37+
base64 -d <<<"$CERT_CONTENTS" > "$cert"
38+
echo "CERT_FILE=$cert" >> $GITHUB_ENV
39+
env:
40+
CERT_CONTENTS: ${{ secrets.WINDOWS_CERT_PFX }}
3041
- name: Run GoReleaser
3142
uses: goreleaser/goreleaser-action@v2
3243
with:
@@ -35,10 +46,9 @@ jobs:
3546
env:
3647
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
3748
GORELEASER_CURRENT_TAG: ${{steps.changelog.outputs.tag-name}}
38-
GITHUB_CERT_PASSWORD: ${{secrets.GITHUB_CERT_PASSWORD}}
39-
DESKTOP_CERT_TOKEN: ${{secrets.DESKTOP_CERT_TOKEN}}
49+
CERT_PASSWORD: ${{secrets.WINDOWS_CERT_PASSWORD}}
4050
- name: Checkout documentation site
41-
uses: actions/checkout@v2
51+
uses: actions/checkout@v3
4252
with:
4353
repository: github/cli.github.com
4454
path: site
@@ -122,7 +132,7 @@ jobs:
122132
runs-on: windows-latest
123133
steps:
124134
- name: Checkout
125-
uses: actions/checkout@v2
135+
uses: actions/checkout@v3
126136
- name: Download gh.exe
127137
id: download_exe
128138
shell: bash
@@ -147,15 +157,18 @@ jobs:
147157
"${MSBUILD_PATH}\MSBuild.exe" ./build/windows/gh.wixproj -p:SourceDir="$PWD" -p:OutputPath="$PWD" -p:OutputName="$name" -p:ProductVersion="$version"
148158
- name: Obtain signing cert
149159
id: obtain_cert
160+
shell: bash
161+
run: |
162+
base64 -d <<<"$CERT_CONTENTS" > ./cert.pfx
163+
printf "::set-output name=cert-file::%s\n" ".\\cert.pfx"
150164
env:
151-
DESKTOP_CERT_TOKEN: ${{ secrets.DESKTOP_CERT_TOKEN }}
152-
run: .\script\setup-windows-certificate.ps1
165+
CERT_CONTENTS: ${{ secrets.WINDOWS_CERT_PFX }}
153166
- name: Sign MSI
154167
env:
155168
CERT_FILE: ${{ steps.obtain_cert.outputs.cert-file }}
156169
EXE_FILE: ${{ steps.buildmsi.outputs.msi }}
157-
GITHUB_CERT_PASSWORD: ${{ secrets.GITHUB_CERT_PASSWORD }}
158-
run: .\script\sign.ps1 -Certificate $env:CERT_FILE -Executable $env:EXE_FILE
170+
CERT_PASSWORD: ${{ secrets.WINDOWS_CERT_PASSWORD }}
171+
run: .\script\signtool sign /d "GitHub CLI" /f $env:CERT_FILE /p $env:CERT_PASSWORD /fd sha256 /tr http://timestamp.digicert.com /v $env:EXE_FILE
159172
- name: Upload MSI
160173
shell: bash
161174
run: |
@@ -179,7 +192,7 @@ jobs:
179192
env:
180193
COMMITTER_TOKEN: ${{ secrets.UPLOAD_GITHUB_TOKEN }}
181194
- name: Checkout scoop bucket
182-
uses: actions/checkout@v2
195+
uses: actions/checkout@v3
183196
with:
184197
repository: cli/scoop-gh
185198
path: scoop-gh

.goreleaser.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ before:
99
hooks:
1010
- go mod tidy
1111
- make manpages GH_VERSION={{.Version}}
12-
- ./script/prepare-windows-cert.sh '{{ if index .Env "GITHUB_CERT_PASSWORD" }}{{ .Env.GITHUB_CERT_PASSWORD}}{{ end }}' '{{ if index .Env "DESKTOP_CERT_TOKEN" }}{{ .Env.DESKTOP_CERT_TOKEN}}{{ end }}'
1312

1413
builds:
1514
- <<: &build_defaults

api/client.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,23 @@ func ScopesSuggestion(resp *http.Response) string {
236236
for _, s := range strings.Split(tokenHasScopes, ",") {
237237
s = strings.TrimSpace(s)
238238
gotScopes[s] = struct{}{}
239-
if strings.HasPrefix(s, "admin:") {
239+
240+
// Certain scopes may be grouped under a single "top-level" scope. The following branch
241+
// statements include these grouped/implied scopes when the top-level scope is encountered.
242+
// See https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps.
243+
if s == "repo" {
244+
gotScopes["repo:status"] = struct{}{}
245+
gotScopes["repo_deployment"] = struct{}{}
246+
gotScopes["public_repo"] = struct{}{}
247+
gotScopes["repo:invite"] = struct{}{}
248+
gotScopes["security_events"] = struct{}{}
249+
} else if s == "user" {
250+
gotScopes["read:user"] = struct{}{}
251+
gotScopes["user:email"] = struct{}{}
252+
gotScopes["user:follow"] = struct{}{}
253+
} else if s == "codespace" {
254+
gotScopes["codespace:secrets"] = struct{}{}
255+
} else if strings.HasPrefix(s, "admin:") {
240256
gotScopes["read:"+strings.TrimPrefix(s, "admin:")] = struct{}{}
241257
gotScopes["write:"+strings.TrimPrefix(s, "admin:")] = struct{}{}
242258
} else if strings.HasPrefix(s, "write:") {

api/queries_repo.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import (
55
"context"
66
"encoding/json"
77
"fmt"
8-
"github.com/cli/cli/v2/internal/ghinstance"
98
"io"
109
"net/http"
1110
"sort"
1211
"strings"
1312
"time"
1413

14+
"github.com/cli/cli/v2/internal/ghinstance"
15+
1516
"github.com/cli/cli/v2/internal/ghrepo"
1617
"github.com/shurcooL/githubv4"
1718
)
@@ -45,6 +46,7 @@ type Repository struct {
4546
MergeCommitAllowed bool
4647
SquashMergeAllowed bool
4748
RebaseMergeAllowed bool
49+
AutoMergeAllowed bool
4850

4951
ForkCount int
5052
StargazerCount int
@@ -67,6 +69,7 @@ type Repository struct {
6769
IsArchived bool
6870
IsEmpty bool
6971
IsFork bool
72+
ForkingAllowed bool
7073
IsInOrganization bool
7174
IsMirror bool
7275
IsPrivate bool
@@ -80,6 +83,7 @@ type Repository struct {
8083
ViewerPermission string
8184
ViewerPossibleCommitEmails []string
8285
ViewerSubscription string
86+
Visibility string
8387

8488
RepositoryTopics struct {
8589
Nodes []struct {

0 commit comments

Comments
 (0)