Merge remote-tracking branch 'upstream/trunk' into trunk
This commit is contained in:
parent
5526dfdd23
commit
4f503a65bd
7 changed files with 49 additions and 15 deletions
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
|
|
@ -29,7 +29,7 @@ jobs:
|
|||
go mod verify
|
||||
go mod download
|
||||
|
||||
LINT_VERSION=1.26.0
|
||||
LINT_VERSION=1.27.0
|
||||
curl -fsSL https://github.com/golangci/golangci-lint/releases/download/v${LINT_VERSION}/golangci-lint-${LINT_VERSION}-linux-amd64.tar.gz | \
|
||||
tar xz --strip-components 1 --wildcards \*/golangci-lint
|
||||
mkdir -p bin && mv golangci-lint bin/
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ brews:
|
|||
folder: Formula
|
||||
custom_block: |
|
||||
head do
|
||||
url "https://github.com/cli/cli.git"
|
||||
url "https://github.com/cli/cli.git", :branch => "trunk"
|
||||
depends_on "go"
|
||||
end
|
||||
install: |
|
||||
|
|
|
|||
|
|
@ -257,8 +257,8 @@ var ensureScopes = func(ctx context.Context, client *api.Client, wantedScopes ..
|
|||
}
|
||||
return reloadedClient, nil
|
||||
} else {
|
||||
fmt.Fprintln(os.Stderr, fmt.Sprintf("Warning: gh now requires %s OAuth scopes.", wantedScopes))
|
||||
fmt.Fprintln(os.Stderr, fmt.Sprintf("Visit https://github.com/settings/tokens and edit your token to enable %s", wantedScopes))
|
||||
fmt.Fprintf(os.Stderr, "Warning: gh now requires %s OAuth scopes.\n", wantedScopes)
|
||||
fmt.Fprintf(os.Stderr, "Visit https://github.com/settings/tokens and edit your token to enable %s\n", wantedScopes)
|
||||
if tokenFromEnv {
|
||||
fmt.Fprintln(os.Stderr, "or generate a new token for the GITHUB_TOKEN environment variable")
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -138,7 +138,11 @@ func migrateConfig(filename string) error {
|
|||
func ParseConfig(filename string) (Config, error) {
|
||||
_, root, err := parseConfigFile(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if os.IsNotExist(err) {
|
||||
root = NewBlankRoot()
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if isLegacy(root) {
|
||||
|
|
|
|||
|
|
@ -110,14 +110,36 @@ github.com:
|
|||
}
|
||||
|
||||
func Test_parseConfigFile(t *testing.T) {
|
||||
fileContents := []string{"", " ", "\n"}
|
||||
for _, contents := range fileContents {
|
||||
t.Run(fmt.Sprintf("contents: %q", contents), func(t *testing.T) {
|
||||
defer StubConfig(contents, "")()
|
||||
tests := []struct {
|
||||
contents string
|
||||
wantsErr bool
|
||||
}{
|
||||
{
|
||||
contents: "",
|
||||
wantsErr: true,
|
||||
},
|
||||
{
|
||||
contents: " ",
|
||||
wantsErr: false,
|
||||
},
|
||||
{
|
||||
contents: "\n",
|
||||
wantsErr: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(fmt.Sprintf("contents: %q", tt.contents), func(t *testing.T) {
|
||||
defer StubConfig(tt.contents, "")()
|
||||
_, yamlRoot, err := parseConfigFile("config.yml")
|
||||
eq(t, err, nil)
|
||||
eq(t, yamlRoot.Content[0].Kind, yaml.MappingNode)
|
||||
eq(t, len(yamlRoot.Content[0].Content), 0)
|
||||
if tt.wantsErr != (err != nil) {
|
||||
t.Fatalf("got error: %v", err)
|
||||
}
|
||||
if tt.wantsErr {
|
||||
return
|
||||
}
|
||||
assert.Equal(t, yaml.MappingNode, yamlRoot.Content[0].Kind)
|
||||
assert.Equal(t, 0, len(yamlRoot.Content[0].Content))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,11 @@ func NewConfig(root *yaml.Node) Config {
|
|||
}
|
||||
|
||||
func NewBlankConfig() Config {
|
||||
return NewConfig(&yaml.Node{
|
||||
return NewConfig(NewBlankRoot())
|
||||
}
|
||||
|
||||
func NewBlankRoot() *yaml.Node {
|
||||
return &yaml.Node{
|
||||
Kind: yaml.DocumentNode,
|
||||
Content: []*yaml.Node{
|
||||
{
|
||||
|
|
@ -168,7 +172,7 @@ func NewBlankConfig() Config {
|
|||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// This type implements a Config interface and represents a config file on disk.
|
||||
|
|
|
|||
|
|
@ -42,7 +42,11 @@ func StubConfig(main, hosts string) func() {
|
|||
ReadConfigFile = func(fn string) ([]byte, error) {
|
||||
switch path.Base(fn) {
|
||||
case "config.yml":
|
||||
return []byte(main), nil
|
||||
if main == "" {
|
||||
return []byte(nil), os.ErrNotExist
|
||||
} else {
|
||||
return []byte(main), nil
|
||||
}
|
||||
case "hosts.yml":
|
||||
if hosts == "" {
|
||||
return []byte(nil), os.ErrNotExist
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue