Skip to content

Commit bc3bb97

Browse files
committed
Merge remote-tracking branch 'origin' into pr-lookup-refactor
2 parents c50d390 + 29908d7 commit bc3bb97

Some content is hidden

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

52 files changed

+1130
-387
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](../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: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

api/export_pr.go

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import (
66
)
77

88
func (issue *Issue) ExportData(fields []string) *map[string]interface{} {
9+
v := reflect.ValueOf(issue).Elem()
910
data := map[string]interface{}{}
1011

1112
for _, f := range fields {
1213
switch f {
1314
case "milestone":
1415
if issue.Milestone.Title != "" {
15-
data[f] = &issue.Milestone
16+
data[f] = map[string]string{"title": issue.Milestone.Title}
1617
} else {
1718
data[f] = nil
1819
}
@@ -25,7 +26,6 @@ func (issue *Issue) ExportData(fields []string) *map[string]interface{} {
2526
case "projectCards":
2627
data[f] = issue.ProjectCards.Nodes
2728
default:
28-
v := reflect.ValueOf(issue).Elem()
2929
sf := fieldByName(v, f)
3030
data[f] = sf.Interface()
3131
}
@@ -35,6 +35,7 @@ func (issue *Issue) ExportData(fields []string) *map[string]interface{} {
3535
}
3636

3737
func (pr *PullRequest) ExportData(fields []string) *map[string]interface{} {
38+
v := reflect.ValueOf(pr).Elem()
3839
data := map[string]interface{}{}
3940

4041
for _, f := range fields {
@@ -43,7 +44,7 @@ func (pr *PullRequest) ExportData(fields []string) *map[string]interface{} {
4344
data[f] = map[string]string{"name": pr.HeadRepository.Name}
4445
case "milestone":
4546
if pr.Milestone.Title != "" {
46-
data[f] = &pr.Milestone
47+
data[f] = map[string]string{"title": pr.Milestone.Title}
4748
} else {
4849
data[f] = nil
4950
}
@@ -75,7 +76,6 @@ func (pr *PullRequest) ExportData(fields []string) *map[string]interface{} {
7576
}
7677
data[f] = &requests
7778
default:
78-
v := reflect.ValueOf(pr).Elem()
7979
sf := fieldByName(v, f)
8080
data[f] = sf.Interface()
8181
}
@@ -84,22 +84,6 @@ func (pr *PullRequest) ExportData(fields []string) *map[string]interface{} {
8484
return &data
8585
}
8686

87-
func ExportIssues(issues []Issue, fields []string) *[]interface{} {
88-
data := make([]interface{}, len(issues))
89-
for i := range issues {
90-
data[i] = issues[i].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 := range prs {
98-
data[i] = prs[i].ExportData(fields)
99-
}
100-
return &data
101-
}
102-
10387
func fieldByName(v reflect.Value, field string) reflect.Value {
10488
return v.FieldByNameFunc(func(s string) bool {
10589
return strings.EqualFold(field, s)

api/export_pr_test.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -90,31 +90,6 @@ func TestIssue_ExportData(t *testing.T) {
9090
}
9191
}
9292

93-
func TestExportIssues(t *testing.T) {
94-
issues := []Issue{
95-
{Milestone: Milestone{Title: "hi"}},
96-
{},
97-
}
98-
exported := ExportIssues(issues, []string{"milestone"})
99-
100-
buf := bytes.Buffer{}
101-
enc := json.NewEncoder(&buf)
102-
enc.SetIndent("", "\t")
103-
require.NoError(t, enc.Encode(exported))
104-
assert.Equal(t, heredoc.Doc(`
105-
[
106-
{
107-
"milestone": {
108-
"title": "hi"
109-
}
110-
},
111-
{
112-
"milestone": null
113-
}
114-
]
115-
`), buf.String())
116-
}
117-
11893
func TestPullRequest_ExportData(t *testing.T) {
11994
tests := []struct {
12095
name string

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+
}

api/queries_issue.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ func (p ProjectCards) ProjectNames() []string {
9191
}
9292

9393
type Milestone struct {
94-
Title string `json:"title"`
94+
Number int `json:"number"`
95+
Title string `json:"title"`
96+
Description string `json:"description"`
97+
DueOn *time.Time `json:"dueOn"`
9598
}
9699

97100
type IssuesDisabledError struct {
@@ -241,7 +244,6 @@ func IssueByNumber(client *Client, repo ghrepo.Interface, number int) (*Issue, e
241244
id
242245
title
243246
state
244-
closed
245247
body
246248
author {
247249
login

0 commit comments

Comments
 (0)