Skip to content

Commit 0ab9c70

Browse files
committed
Merge remote-tracking branch 'origin' into improve-automerge
2 parents bec0a10 + 1ca49a8 commit 0ab9c70

File tree

97 files changed

+6242
-1211
lines changed

Some content is hidden

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

97 files changed

+6242
-1211
lines changed

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Run the new binary as:
3636

3737
Run tests with: `go test ./...`
3838

39-
See [project layout documentation](../project-layout.md) for information on where to find specific source files.
39+
See [project layout documentation](../docs/project-layout.md) for information on where to find specific source files.
4040

4141
## Submitting a pull request
4242

.github/workflows/releases.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Run GoReleaser
2424
uses: goreleaser/goreleaser-action@v2
2525
with:
26-
version: latest
26+
version: v0.172.1 # pinning to prevent breaking on latest
2727
args: release --release-notes=CHANGELOG.md
2828
env:
2929
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -197,3 +197,18 @@ jobs:
197197
GIT_AUTHOR_NAME: cli automation
198198
GIT_COMMITTER_EMAIL: noreply@github.com
199199
GIT_AUTHOR_EMAIL: noreply@github.com
200+
- name: Bump Winget manifest
201+
shell: pwsh
202+
env:
203+
WINGETCREATE_VERSION: v0.2.0.29-preview
204+
GITHUB_TOKEN: ${{ secrets.UPLOAD_GITHUB_TOKEN }}
205+
run: |
206+
$tagname = $env:GITHUB_REF.Replace("refs/tags/", "")
207+
$version = $tagname.Replace("v", "")
208+
$url = "https://github.com/cli/cli/releases/download/${tagname}/gh_${version}_windows_amd64.msi"
209+
iwr https://github.com/microsoft/winget-create/releases/download/${env:WINGETCREATE_VERSION}/wingetcreate.exe -OutFile wingetcreate.exe
210+
211+
.\wingetcreate.exe update GitHub.cli --url $url --version $version
212+
if ($version -notmatch "-") {
213+
.\wingetcreate.exe submit .\manifests\g\GitHub\cli\${version}\ --token $env:GITHUB_TOKEN
214+
}

.goreleaser.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,6 @@ nfpms:
6464
formats:
6565
- deb
6666
- rpm
67-
files:
68-
"./share/man/man1/gh*.1": "/usr/share/man/man1"
67+
contents:
68+
- src: "/share/man/man1/gh*.1"
69+
dst: "/usr/share/man/man1"

README.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ GitHub CLI is available for repositories hosted on GitHub.com and GitHub Enterpr
1414

1515
If anything feels off, or if you feel that some functionality is missing, please check out the [contributing page][contributing]. There you will find instructions for sharing your feedback, building the tool locally, and submitting pull requests to the project.
1616

17-
1817
<!-- this anchor is linked to from elsewhere, so avoid renaming it -->
1918
## Installation
2019

2120
### macOS
2221

23-
`gh` is available via [Homebrew][], [MacPorts][], and as a downloadable binary from the [releases page][].
22+
`gh` is available via [Homebrew][], [MacPorts][], [Conda][], and as a downloadable binary from the [releases page][].
2423

2524
#### Homebrew
2625

@@ -34,24 +33,29 @@ If anything feels off, or if you feel that some functionality is missing, please
3433
| ---------------------- | ---------------------------------------------- |
3534
| `sudo port install gh` | `sudo port selfupdate && sudo port upgrade gh` |
3635

36+
#### Conda
37+
38+
| Install: | Upgrade: |
39+
|------------------------------------------|-----------------------------------------|
40+
| `conda install gh --channel conda-forge` | `conda update gh --channel conda-forge` |
41+
42+
Additional Conda installation options available on the [gh-feedstock page](https://github.com/conda-forge/gh-feedstock#installing-gh).
43+
3744
### Linux
3845

39-
`gh` is available via [Homebrew](#homebrew), and as downloadable binaries from the [releases page][].
46+
`gh` is available via [Homebrew](#homebrew), [Conda](#Conda), and as downloadable binaries from the [releases page][].
4047

4148
For more information and distro-specific instructions, see the [Linux installation docs](./docs/install_linux.md).
4249

4350
### Windows
4451

45-
`gh` is available via [WinGet][], [scoop][], [Chocolatey][], and as downloadable MSI.
46-
52+
`gh` is available via [WinGet][], [scoop][], [Chocolatey][], [Conda](#Conda), and as downloadable MSI.
4753

4854
#### WinGet
4955

5056
| Install: | Upgrade: |
5157
| ------------------- | --------------------|
52-
| `winget install gh` | `winget install gh` |
53-
54-
<i>WinGet does not have a specialized `upgrade` command yet, but the `install` command should work for upgrading to a newer version of GitHub CLI.</i>
58+
| `winget install gh` | `winget upgrade gh` |
5559

5660
#### scoop
5761

@@ -69,9 +73,9 @@ For more information and distro-specific instructions, see the [Linux installati
6973

7074
MSI installers are available for download on the [releases page][].
7175

72-
### Github Actions
76+
### GitHub Actions
7377

74-
GitHub CLI comes pre-installed in all [Github-Hosted Runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners).
78+
GitHub CLI comes pre-installed in all [GitHub-Hosted Runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners).
7579

7680
### Other platforms
7781

@@ -88,13 +92,13 @@ what an official GitHub CLI tool can look like with a fundamentally different de
8892
tools bring GitHub to the terminal, `hub` behaves as a proxy to `git`, and `gh` is a standalone
8993
tool. Check out our [more detailed explanation][gh-vs-hub] to learn more.
9094

91-
9295
[manual]: https://cli.github.com/manual/
9396
[Homebrew]: https://brew.sh
9497
[MacPorts]: https://www.macports.org
9598
[winget]: https://github.com/microsoft/winget-cli
9699
[scoop]: https://scoop.sh
97100
[Chocolatey]: https://chocolatey.org
101+
[Conda]: https://docs.conda.io/en/latest/
98102
[releases page]: https://github.com/cli/cli/releases/latest
99103
[hub]: https://github.com/github/hub
100104
[contributing]: ./.github/CONTRIBUTING.md

api/client.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ func (c Client) REST(hostname string, method string, p string, body io.Reader, d
220220
if err != nil {
221221
return err
222222
}
223-
224223
err = json.Unmarshal(b, &data)
225224
if err != nil {
226225
return err

api/export_pr.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,20 @@ func (pr *PullRequest) ExportData(fields []string) *map[string]interface{} {
8080
case "reviewRequests":
8181
requests := make([]interface{}, 0, len(pr.ReviewRequests.Nodes))
8282
for _, req := range pr.ReviewRequests.Nodes {
83-
if req.RequestedReviewer.TypeName == "" {
84-
continue
83+
r := req.RequestedReviewer
84+
switch r.TypeName {
85+
case "User":
86+
requests = append(requests, map[string]string{
87+
"__typename": r.TypeName,
88+
"login": r.Login,
89+
})
90+
case "Team":
91+
requests = append(requests, map[string]string{
92+
"__typename": r.TypeName,
93+
"name": r.Name,
94+
"slug": r.LoginOrSlug(),
95+
})
8596
}
86-
requests = append(requests, req.RequestedReviewer)
8797
}
8898
data[f] = &requests
8999
default:

api/queries_pr.go

Lines changed: 40 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,33 @@ type PullRequestFile struct {
150150

151151
type ReviewRequests struct {
152152
Nodes []struct {
153-
RequestedReviewer struct {
154-
TypeName string `json:"__typename"`
155-
Login string `json:"login"`
156-
Name string `json:"name"`
157-
}
153+
RequestedReviewer RequestedReviewer
154+
}
155+
}
156+
157+
type RequestedReviewer struct {
158+
TypeName string `json:"__typename"`
159+
Login string `json:"login"`
160+
Name string `json:"name"`
161+
Slug string `json:"slug"`
162+
Organization struct {
163+
Login string `json:"login"`
164+
} `json:"organization"`
165+
}
166+
167+
func (r RequestedReviewer) LoginOrSlug() string {
168+
if r.TypeName == teamTypeName {
169+
return fmt.Sprintf("%s/%s", r.Organization.Login, r.Slug)
158170
}
171+
return r.Login
159172
}
160173

174+
const teamTypeName = "Team"
175+
161176
func (r ReviewRequests) Logins() []string {
162177
logins := make([]string, len(r.Nodes))
163-
for i, a := range r.Nodes {
164-
logins[i] = a.RequestedReviewer.Login
178+
for i, r := range r.Nodes {
179+
logins[i] = r.RequestedReviewer.LoginOrSlug()
165180
}
166181
return logins
167182
}
@@ -381,7 +396,7 @@ func PullRequestStatus(client *Client, repo ghrepo.Interface, options StatusOpti
381396
// these are always necessary to find the PR for the current branch
382397
fields.AddValues([]string{"isCrossRepository", "headRepositoryOwner", "headRefName"})
383398
gr := PullRequestGraphQL(fields.ToSlice())
384-
fragments = fmt.Sprintf("fragment pr on PullRequest{%[1]s}fragment prWithReviews on PullRequest{%[1]s}", gr)
399+
fragments = fmt.Sprintf("fragment pr on PullRequest{%s}fragment prWithReviews on PullRequest{...pr}", gr)
385400
} else {
386401
var err error
387402
fragments, err = pullRequestFragment(client.http, repo.RepoHost())
@@ -393,8 +408,8 @@ func PullRequestStatus(client *Client, repo ghrepo.Interface, options StatusOpti
393408
queryPrefix := `
394409
query PullRequestStatus($owner: String!, $repo: String!, $headRefName: String!, $viewerQuery: String!, $reviewerQuery: String!, $per_page: Int = 10) {
395410
repository(owner: $owner, name: $repo) {
396-
defaultBranchRef {
397-
name
411+
defaultBranchRef {
412+
name
398413
}
399414
pullRequests(headRefName: $headRefName, first: $per_page, orderBy: { field: CREATED_AT, direction: DESC }) {
400415
totalCount
@@ -410,8 +425,8 @@ func PullRequestStatus(client *Client, repo ghrepo.Interface, options StatusOpti
410425
queryPrefix = `
411426
query PullRequestStatus($owner: String!, $repo: String!, $number: Int!, $viewerQuery: String!, $reviewerQuery: String!, $per_page: Int = 10) {
412427
repository(owner: $owner, name: $repo) {
413-
defaultBranchRef {
414-
name
428+
defaultBranchRef {
429+
name
415430
}
416431
pullRequest(number: $number) {
417432
...prWithReviews
@@ -516,67 +531,26 @@ func pullRequestFragment(httpClient *http.Client, hostname string) (string, erro
516531
return "", err
517532
}
518533

519-
var reviewsFragment string
520-
if prFeatures.HasReviewDecision {
521-
reviewsFragment = "reviewDecision"
534+
fields := []string{
535+
"number", "title", "state", "url", "isDraft", "isCrossRepository",
536+
"headRefName", "headRepositoryOwner", "mergeStateStatus",
522537
}
523-
524-
var statusesFragment string
525538
if prFeatures.HasStatusCheckRollup {
526-
statusesFragment = `
527-
commits(last: 1) {
528-
nodes {
529-
commit {
530-
statusCheckRollup {
531-
contexts(last: 100) {
532-
nodes {
533-
...on StatusContext {
534-
state
535-
}
536-
...on CheckRun {
537-
conclusion
538-
status
539-
}
540-
}
541-
}
542-
}
543-
}
544-
}
545-
}
546-
`
539+
fields = append(fields, "statusCheckRollup")
547540
}
548-
549-
var requiresStrictStatusChecks string
550541
if prFeatures.HasBranchProtectionRule {
551-
requiresStrictStatusChecks = `
552-
baseRef {
553-
branchProtectionRule {
554-
requiresStrictStatusChecks
555-
}
556-
}`
542+
fields = append(fields, "requiresStrictStatusChecks")
557543
}
558544

559-
fragments := fmt.Sprintf(`
560-
fragment pr on PullRequest {
561-
number
562-
title
563-
state
564-
url
565-
headRefName
566-
mergeStateStatus
567-
headRepositoryOwner {
568-
login
569-
}
570-
%s
571-
isCrossRepository
572-
isDraft
573-
%s
574-
}
575-
fragment prWithReviews on PullRequest {
576-
...pr
577-
%s
545+
var reviewFields []string
546+
if prFeatures.HasReviewDecision {
547+
reviewFields = append(reviewFields, "reviewDecision")
578548
}
579-
`, requiresStrictStatusChecks, statusesFragment, reviewsFragment)
549+
550+
fragments := fmt.Sprintf(`
551+
fragment pr on PullRequest {%s}
552+
fragment prWithReviews on PullRequest {...pr,%s}
553+
`, PullRequestGraphQL(fields), PullRequestGraphQL(reviewFields))
580554
return fragments, nil
581555
}
582556

0 commit comments

Comments
 (0)