Skip to content

Commit b75bccd

Browse files
committed
Merge remote-tracking branch 'origin' into git-push-mocks
2 parents 33a3641 + 4d20aa7 commit b75bccd

File tree

152 files changed

+6650
-4261
lines changed

Some content is hidden

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

152 files changed

+6650
-4261
lines changed

.github/CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Run the new binary as:
3636

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

39+
See [project layout documentation](../docs/project-layout.md) for information on where to find specific source files.
40+
3941
## Submitting a pull request
4042

4143
1. Create a new branch: `git checkout -b my-branch-name`

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!--
2+
Thank you for contributing to GitHub CLI!
3+
To reference an open issue, please write this in your description: `Fixes #NUMBER`
4+
-->

.github/PULL_REQUEST_TEMPLATE/bug_fix.md

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/releases.yml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
popd
8181
- name: Run reprepro
8282
env:
83-
RELEASES: "cosmic eoan disco groovy focal stable oldstable testing unstable buster bullseye stretch jessie bionic trusty precise xenial"
83+
RELEASES: "cosmic eoan disco groovy focal stable oldstable testing sid unstable buster bullseye stretch jessie bionic trusty precise xenial hirsute impish kali-rolling"
8484
run: |
8585
mkdir -p upload
8686
for release in $RELEASES; do
@@ -133,9 +133,11 @@ jobs:
133133
- name: Build MSI
134134
id: buildmsi
135135
shell: bash
136+
env:
137+
ZIP_FILE: ${{ steps.download_exe.outputs.zip }}
136138
run: |
137139
mkdir -p build
138-
msi="$(basename "${{ steps.download_exe.outputs.zip }}" ".zip").msi"
140+
msi="$(basename "$ZIP_FILE" ".zip").msi"
139141
printf "::set-output name=msi::%s\n" "$msi"
140142
go-msi make --msi "$PWD/$msi" --out "$PWD/build" --version "${GITHUB_REF#refs/tags/}"
141143
- name: Obtain signing cert
@@ -145,14 +147,24 @@ jobs:
145147
run: .\script\setup-windows-certificate.ps1
146148
- name: Sign MSI
147149
env:
150+
CERT_FILE: ${{ steps.obtain_cert.outputs.cert-file }}
151+
EXE_FILE: ${{ steps.buildmsi.outputs.msi }}
148152
GITHUB_CERT_PASSWORD: ${{ secrets.GITHUB_CERT_PASSWORD }}
149-
run: |
150-
.\script\sign.ps1 -Certificate "${{ steps.obtain_cert.outputs.cert-file }}" `
151-
-Executable "${{ steps.buildmsi.outputs.msi }}"
153+
run: .\script\sign.ps1 -Certificate $env:CERT_FILE -Executable $env:EXE_FILE
152154
- name: Upload MSI
153155
shell: bash
154-
run: hub release edit "${GITHUB_REF#refs/tags/}" -m "" --draft=false -a "${{ steps.buildmsi.outputs.msi }}"
156+
run: |
157+
tag_name="${GITHUB_REF#refs/tags/}"
158+
hub release edit "$tag_name" -m "" -a "$MSI_FILE"
159+
release_url="$(gh api repos/:owner/:repo/releases -q ".[]|select(.tag_name==\"${tag_name}\")|.url")"
160+
publish_args=( -F draft=false )
161+
if [[ $GITHUB_REF != *-* ]]; then
162+
publish_args+=( -f discussion_category_name="$DISCUSSION_CATEGORY" )
163+
fi
164+
gh api -X PATCH "$release_url" "${publish_args[@]}"
155165
env:
166+
MSI_FILE: ${{ steps.buildmsi.outputs.msi }}
167+
DISCUSSION_CATEGORY: General
156168
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
157169
- name: Bump homebrew-core formula
158170
uses: mislav/bump-homebrew-formula-action@v1
@@ -185,3 +197,18 @@ jobs:
185197
GIT_AUTHOR_NAME: cli automation
186198
GIT_COMMITTER_EMAIL: noreply@github.com
187199
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+
}

README.md

Lines changed: 17 additions & 9 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,6 +73,10 @@ For more information and distro-specific instructions, see the [Linux installati
6973

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

76+
### GitHub Actions
77+
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).
79+
7280
### Other platforms
7381

7482
Download packaged binaries from the [releases page][].
@@ -84,13 +92,13 @@ what an official GitHub CLI tool can look like with a fundamentally different de
8492
tools bring GitHub to the terminal, `hub` behaves as a proxy to `git`, and `gh` is a standalone
8593
tool. Check out our [more detailed explanation][gh-vs-hub] to learn more.
8694

87-
8895
[manual]: https://cli.github.com/manual/
8996
[Homebrew]: https://brew.sh
9097
[MacPorts]: https://www.macports.org
9198
[winget]: https://github.com/microsoft/winget-cli
9299
[scoop]: https://scoop.sh
93100
[Chocolatey]: https://chocolatey.org
101+
[Conda]: https://docs.conda.io/en/latest/
94102
[releases page]: https://github.com/cli/cli/releases/latest
95103
[hub]: https://github.com/github/hub
96104
[contributing]: ./.github/CONTRIBUTING.md

api/export_pr.go

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ func (issue *Issue) ExportData(fields []string) *map[string]interface{} {
1111

1212
for _, f := range fields {
1313
switch f {
14-
case "milestone":
15-
if issue.Milestone.Title != "" {
16-
data[f] = &issue.Milestone
17-
} else {
18-
data[f] = nil
19-
}
2014
case "comments":
2115
data[f] = issue.Comments.Nodes
2216
case "assignees":
@@ -41,19 +35,36 @@ func (pr *PullRequest) ExportData(fields []string) *map[string]interface{} {
4135
for _, f := range fields {
4236
switch f {
4337
case "headRepository":
44-
data[f] = map[string]string{"name": pr.HeadRepository.Name}
45-
case "milestone":
46-
if pr.Milestone.Title != "" {
47-
data[f] = &pr.Milestone
48-
} else {
49-
data[f] = nil
50-
}
38+
data[f] = pr.HeadRepository
5139
case "statusCheckRollup":
52-
if n := pr.Commits.Nodes; len(n) > 0 {
40+
if n := pr.StatusCheckRollup.Nodes; len(n) > 0 {
5341
data[f] = n[0].Commit.StatusCheckRollup.Contexts.Nodes
5442
} else {
5543
data[f] = nil
5644
}
45+
case "commits":
46+
commits := make([]interface{}, 0, len(pr.Commits.Nodes))
47+
for _, c := range pr.Commits.Nodes {
48+
commit := c.Commit
49+
authors := make([]interface{}, 0, len(commit.Authors.Nodes))
50+
for _, author := range commit.Authors.Nodes {
51+
authors = append(authors, map[string]interface{}{
52+
"name": author.Name,
53+
"email": author.Email,
54+
"id": author.User.ID,
55+
"login": author.User.Login,
56+
})
57+
}
58+
commits = append(commits, map[string]interface{}{
59+
"oid": commit.OID,
60+
"messageHeadline": commit.MessageHeadline,
61+
"messageBody": commit.MessageBody,
62+
"committedDate": commit.CommittedDate,
63+
"authoredDate": commit.AuthoredDate,
64+
"authors": authors,
65+
})
66+
}
67+
data[f] = commits
5768
case "comments":
5869
data[f] = pr.Comments.Nodes
5970
case "assignees":
@@ -69,10 +80,20 @@ func (pr *PullRequest) ExportData(fields []string) *map[string]interface{} {
6980
case "reviewRequests":
7081
requests := make([]interface{}, 0, len(pr.ReviewRequests.Nodes))
7182
for _, req := range pr.ReviewRequests.Nodes {
72-
if req.RequestedReviewer.TypeName == "" {
73-
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+
})
7496
}
75-
requests = append(requests, req.RequestedReviewer)
7697
}
7798
data[f] = &requests
7899
default:
@@ -84,22 +105,6 @@ func (pr *PullRequest) ExportData(fields []string) *map[string]interface{} {
84105
return &data
85106
}
86107

87-
func ExportIssues(issues []Issue, fields []string) *[]interface{} {
88-
data := make([]interface{}, len(issues))
89-
for i, issue := range issues {
90-
data[i] = issue.ExportData(fields)
91-
}
92-
return &data
93-
}
94-
95-
func ExportPRs(prs []PullRequest, fields []string) *[]interface{} {
96-
data := make([]interface{}, len(prs))
97-
for i, pr := range prs {
98-
data[i] = pr.ExportData(fields)
99-
}
100-
return &data
101-
}
102-
103108
func fieldByName(v reflect.Value, field string) reflect.Value {
104109
return v.FieldByNameFunc(func(s string) bool {
105110
return strings.EqualFold(field, s)

api/export_pr_test.go

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,24 @@ func TestIssue_ExportData(t *testing.T) {
3131
}
3232
`),
3333
},
34+
{
35+
name: "milestone",
36+
fields: []string{"number", "milestone"},
37+
inputJSON: heredoc.Doc(`
38+
{ "number": 2345, "milestone": {"title": "The next big thing"} }
39+
`),
40+
outputJSON: heredoc.Doc(`
41+
{
42+
"milestone": {
43+
"number": 0,
44+
"title": "The next big thing",
45+
"description": "",
46+
"dueOn": null
47+
},
48+
"number": 2345
49+
}
50+
`),
51+
},
3452
{
3553
name: "project cards",
3654
fields: []string{"projectCards"},
@@ -95,11 +113,29 @@ func TestPullRequest_ExportData(t *testing.T) {
95113
}
96114
`),
97115
},
116+
{
117+
name: "milestone",
118+
fields: []string{"number", "milestone"},
119+
inputJSON: heredoc.Doc(`
120+
{ "number": 2345, "milestone": {"title": "The next big thing"} }
121+
`),
122+
outputJSON: heredoc.Doc(`
123+
{
124+
"milestone": {
125+
"number": 0,
126+
"title": "The next big thing",
127+
"description": "",
128+
"dueOn": null
129+
},
130+
"number": 2345
131+
}
132+
`),
133+
},
98134
{
99135
name: "status checks",
100136
fields: []string{"statusCheckRollup"},
101137
inputJSON: heredoc.Doc(`
102-
{ "commits": { "nodes": [
138+
{ "statusCheckRollup": { "nodes": [
103139
{ "commit": { "statusCheckRollup": { "contexts": { "nodes": [
104140
{
105141
"__typename": "CheckRun",

api/export_repo.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package api
2+
3+
import (
4+
"reflect"
5+
)
6+
7+
func (repo *Repository) ExportData(fields []string) *map[string]interface{} {
8+
v := reflect.ValueOf(repo).Elem()
9+
data := map[string]interface{}{}
10+
11+
for _, f := range fields {
12+
switch f {
13+
case "parent":
14+
data[f] = miniRepoExport(repo.Parent)
15+
case "templateRepository":
16+
data[f] = miniRepoExport(repo.TemplateRepository)
17+
case "languages":
18+
data[f] = repo.Languages.Edges
19+
case "labels":
20+
data[f] = repo.Labels.Nodes
21+
case "assignableUsers":
22+
data[f] = repo.AssignableUsers.Nodes
23+
case "mentionableUsers":
24+
data[f] = repo.MentionableUsers.Nodes
25+
case "milestones":
26+
data[f] = repo.Milestones.Nodes
27+
case "projects":
28+
data[f] = repo.Projects.Nodes
29+
case "repositoryTopics":
30+
var topics []RepositoryTopic
31+
for _, n := range repo.RepositoryTopics.Nodes {
32+
topics = append(topics, n.Topic)
33+
}
34+
data[f] = topics
35+
default:
36+
sf := fieldByName(v, f)
37+
data[f] = sf.Interface()
38+
}
39+
}
40+
41+
return &data
42+
}
43+
44+
func miniRepoExport(r *Repository) map[string]interface{} {
45+
if r == nil {
46+
return nil
47+
}
48+
return map[string]interface{}{
49+
"id": r.ID,
50+
"name": r.Name,
51+
"owner": r.Owner,
52+
}
53+
}

0 commit comments

Comments
 (0)