Fix linting issues: canonicalheader, embeddedstructfieldcheck, iotamixing, makezero, testableexamples, wastedassign, usetesting, tparallel, unconvert, intrange, iface
- canonicalheader: fix cacheTTL header value to canonical form - embeddedstructfieldcheck: move embedded fields before regular fields in 4 structs - iotamixing: split const blocks mixing iota with non-iota constants - makezero: use make([]T, 0, n) instead of make([]T, n) before appending - testableexamples: add missing Output: comment to ExampleOption_UnwrapOrZero - wastedassign: remove wasted initial assignments in 4 locations - usetesting: replace os.MkdirTemp/os.Setenv with t.TempDir/t.Setenv in tests - tparallel: add t.Parallel() to 8 top-level test functions - unconvert: remove 16 unnecessary type conversions - intrange: convert 3 for loops to use integer range syntax - iface: consolidate identical EditPrompter and Prompt interfaces via type alias Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
6c11ecd9ab
commit
dca59d52b6
113 changed files with 222 additions and 287 deletions
|
|
@ -71,7 +71,7 @@ func (ct *capiTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||
req.Header.Add("Copilot-Integration-Id", "copilot-4-cli")
|
||||
|
||||
// Ensure we are not using GitHub API versions while targeting CAPI.
|
||||
req.Header.Set("X-GitHub-Api-Version", "2026-01-09")
|
||||
req.Header.Set("X-Github-Api-Version", "2026-01-09")
|
||||
}
|
||||
return ct.rp.RoundTrip(req)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ func createRun(opts *CreateOptions) error {
|
|||
return err
|
||||
}
|
||||
|
||||
trimmed := strings.TrimSpace(string(desc))
|
||||
trimmed := strings.TrimSpace(desc)
|
||||
if trimmed == "" {
|
||||
return errors.New("a task description is required")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ func addPerPage(p string, perPage int, params map[string]interface{}) string {
|
|||
// JSON array in order to apply pagination context between multiple API requests.
|
||||
type paginatedArrayReader struct {
|
||||
io.Reader
|
||||
|
||||
isFirstPage bool
|
||||
isLastPage bool
|
||||
|
||||
|
|
@ -153,6 +154,7 @@ func (r *paginatedArrayReader) Read(p []byte) (int, error) {
|
|||
// and objects. Call Close to write the end of the array.
|
||||
type jsonArrayWriter struct {
|
||||
io.Writer
|
||||
|
||||
started bool
|
||||
color bool
|
||||
}
|
||||
|
|
|
|||
|
|
@ -265,6 +265,7 @@ func TestJsonArrayWriter_Copy(t *testing.T) {
|
|||
|
||||
type noWriteToReader struct {
|
||||
io.Reader
|
||||
|
||||
limit int
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@ func FilterAttestations(predicateType string, attestations []*Attestation) ([]*A
|
|||
for _, each := range attestations {
|
||||
dsseEnvelope := each.Bundle.GetDsseEnvelope()
|
||||
if dsseEnvelope != nil {
|
||||
if dsseEnvelope.PayloadType != "application/vnd.in-toto+json" {
|
||||
if dsseEnvelope.GetPayloadType() != "application/vnd.in-toto+json" {
|
||||
// Don't fail just because an entry isn't intoto
|
||||
continue
|
||||
}
|
||||
var intotoStatement IntotoStatement
|
||||
if err := json.Unmarshal([]byte(dsseEnvelope.Payload), &intotoStatement); err != nil {
|
||||
if err := json.Unmarshal(dsseEnvelope.GetPayload(), &intotoStatement); err != nil {
|
||||
// Don't fail just because a single entry can't be unmarshalled
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -332,7 +332,6 @@ func TestGetTrustDomain(t *testing.T) {
|
|||
td, err := c.GetTrustDomain()
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, "foo", td)
|
||||
|
||||
})
|
||||
|
||||
t.Run("with error", func(t *testing.T) {
|
||||
|
|
@ -346,7 +345,6 @@ func TestGetTrustDomain(t *testing.T) {
|
|||
require.Equal(t, "", td)
|
||||
require.ErrorContains(t, err, "test error")
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func TestGetAttestationsRetries(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ func (m mockAPIClient) REST(hostname, method, p string, body io.Reader, data int
|
|||
|
||||
type mockDataGenerator struct {
|
||||
mock.Mock
|
||||
|
||||
NumUserAttestations int
|
||||
NumGitHubAttestations int
|
||||
}
|
||||
|
|
@ -78,7 +79,7 @@ func (m *mockDataGenerator) OnREST500ErrorHandler() func(hostname, method, p str
|
|||
|
||||
func (m *mockDataGenerator) OnRESTWithNextSuccessHelper(hostname, method, p string, body io.Reader, data interface{}, hasNext bool) (string, error) {
|
||||
atts := make([]*Attestation, m.NumUserAttestations+m.NumGitHubAttestations)
|
||||
for j := 0; j < m.NumUserAttestations; j++ {
|
||||
for j := range m.NumUserAttestations {
|
||||
att := makeTestAttestation()
|
||||
atts[j] = &att
|
||||
}
|
||||
|
|
@ -148,7 +149,6 @@ func (m mockMetaGenerator) OnREST(hostname, method, p string, body io.Reader, da
|
|||
`
|
||||
var jsonString = fmt.Sprintf(template, m.TrustDomain)
|
||||
return json.Unmarshal([]byte(jsonString), &data)
|
||||
|
||||
}
|
||||
|
||||
func (m mockMetaGenerator) OnRESTError(hostname, method, p string, body io.Reader, data interface{}) error {
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ func (m *reqFailHttpClient) Get(url string) (*http.Response, error) {
|
|||
|
||||
type failAfterNCallsHttpClient struct {
|
||||
mock.Mock
|
||||
|
||||
mu sync.Mutex
|
||||
FailOnCallN int
|
||||
FailOnAllSubsequentCalls bool
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ func (s *LiveStore) createMetadataFile(artifactDigest string, attestationsResp [
|
|||
}
|
||||
|
||||
withNewline := fmt.Sprintf("%s\n", attBytes)
|
||||
_, err = f.Write([]byte(withNewline))
|
||||
_, err = f.WriteString(withNewline)
|
||||
if err != nil {
|
||||
if err = f.Close(); err != nil {
|
||||
return "", errors.Join(ErrAttestationFileCreation, fmt.Errorf("failed to close file while handling write error: %v", err))
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ func getAttestationDetail(tenant string, attr api.Attestation) (AttestationDetai
|
|||
}
|
||||
|
||||
var predicate Predicate
|
||||
predicateJson, err := json.Marshal(statement.Predicate)
|
||||
predicateJson, err := json.Marshal(statement.GetPredicate())
|
||||
if err != nil {
|
||||
return AttestationDetail{}, fmt.Errorf("failed to marshal predicate: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@ type BundleInspection struct {
|
|||
|
||||
type CertificateInspection struct {
|
||||
certificate.Summary
|
||||
|
||||
NotBefore time.Time `json:"notBefore"`
|
||||
NotAfter time.Time `json:"notAfter"`
|
||||
}
|
||||
|
|
@ -188,7 +189,6 @@ func runInspect(opts *Options) error {
|
|||
|
||||
// summarize cert if present
|
||||
if leafCert := verificationContent.Certificate(); leafCert != nil {
|
||||
|
||||
certSummary, err := certificate.SummarizeCertificate(leafCert)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to summarize certificate: %w", err)
|
||||
|
|
@ -199,7 +199,6 @@ func runInspect(opts *Options) error {
|
|||
NotBefore: leafCert.NotBefore,
|
||||
NotAfter: leafCert.NotAfter,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// parse the sig content and pop the statement
|
||||
|
|
|
|||
|
|
@ -62,6 +62,6 @@ func TestJSONOutput(t *testing.T) {
|
|||
err := json.Unmarshal(out.Bytes(), &target)
|
||||
|
||||
assert.Equal(t, "https://github.com/sigstore/sigstore-js", target.InspectedBundles[0].Certificate.SourceRepositoryURI)
|
||||
assert.Equal(t, "https://slsa.dev/provenance/v1", target.InspectedBundles[0].Statement.PredicateType)
|
||||
assert.Equal(t, "https://slsa.dev/provenance/v1", target.InspectedBundles[0].Statement.GetPredicateType())
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,11 +194,11 @@ func TestGetTrustedRoot(t *testing.T) {
|
|||
require.Error(t, err)
|
||||
require.ErrorContains(t, err, "failed to read root file")
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
type stubAuthConfig struct {
|
||||
config.AuthConfig
|
||||
|
||||
hasActiveToken bool
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ func TestLoadBundlesFromJSONLinesFile(t *testing.T) {
|
|||
|
||||
func TestLoadBundlesFromJSONLinesFile_RejectEmptyJSONLFile(t *testing.T) {
|
||||
// Create a temporary file
|
||||
emptyJSONL, err := os.CreateTemp("", "empty.jsonl")
|
||||
emptyJSONL, err := os.CreateTemp(t.TempDir(), "empty.jsonl")
|
||||
require.NoError(t, err)
|
||||
err = emptyJSONL.Close()
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package verification
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
|
|
@ -11,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
func TestGitHubTUFOptionsNoMetadataDir(t *testing.T) {
|
||||
os.Setenv("CODESPACES", "true")
|
||||
t.Setenv("CODESPACES", "true")
|
||||
opts := GitHubTUFOptions(o.None[string](), nil)
|
||||
|
||||
require.Equal(t, GitHubTUFMirror, opts.RepositoryBaseURL)
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ func Test_logoutRun_tty(t *testing.T) {
|
|||
for _, hostUsers := range tt.cfgHosts {
|
||||
for _, user := range hostUsers.users {
|
||||
_, _ = cfg.Authentication().Login(
|
||||
string(hostUsers.host),
|
||||
hostUsers.host,
|
||||
user.name,
|
||||
user.token, "ssh", tt.secureStorage,
|
||||
)
|
||||
|
|
@ -511,7 +511,7 @@ func Test_logoutRun_nontty(t *testing.T) {
|
|||
for _, hostUsers := range tt.cfgHosts {
|
||||
for _, user := range hostUsers.users {
|
||||
_, _ = cfg.Authentication().Login(
|
||||
string(hostUsers.host),
|
||||
hostUsers.host,
|
||||
user.name,
|
||||
user.token, "ssh", tt.secureStorage,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ func TestGitCredentialsSetup_setOurs_GH(t *testing.T) {
|
|||
if err := f.Setup("github.com", "monalisa", "PASSWD"); err != nil {
|
||||
t.Errorf("Setup() error = %v", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestSetup_setOurs_nonGH(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func Test_HasMinimumScopes(t *testing.T) {
|
|||
|
||||
var gotAuthorization string
|
||||
fakehttp.Register(httpmock.REST("GET", ""), func(req *http.Request) (*http.Response, error) {
|
||||
gotAuthorization = req.Header.Get("authorization")
|
||||
gotAuthorization = req.Header.Get("Authorization")
|
||||
return &http.Response{
|
||||
Request: req,
|
||||
StatusCode: 200,
|
||||
|
|
@ -96,7 +96,6 @@ func Test_HeaderHasMinimumScopes(t *testing.T) {
|
|||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
err := HeaderHasMinimumScopes(tt.header)
|
||||
if tt.wantErr != "" {
|
||||
assert.EqualError(t, err, tt.wantErr)
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ func TestNewCmdSwitch(t *testing.T) {
|
|||
require.Equal(t, &tt.expectedOpts, gotOpts)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestSwitchRun(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -237,7 +237,6 @@ func (a *App) Create(ctx context.Context, opts createOptions) error {
|
|||
}
|
||||
|
||||
if len(devcontainers) > 0 {
|
||||
|
||||
// if there is only one devcontainer.json file and it is one of the default paths we can auto-select it
|
||||
if len(devcontainers) == 1 && stringInSlice(devcontainers[0].Path, DEFAULT_DEVCONTAINER_DEFINITIONS) {
|
||||
devContainerPath = devcontainers[0].Path
|
||||
|
|
@ -527,7 +526,7 @@ func getMachineName(ctx context.Context, apiClient apiClient, prompter SurveyPro
|
|||
}
|
||||
|
||||
availableMachines := make([]string, len(machines))
|
||||
for i := 0; i < len(machines); i++ {
|
||||
for i := range machines {
|
||||
availableMachines[i] = machines[i].Name
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -268,7 +268,6 @@ func (a *App) UpdatePortVisibility(ctx context.Context, selector *CodespaceSelec
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ func TestApp_Select(t *testing.T) {
|
|||
opts := selectOptions{}
|
||||
|
||||
if tt.outputToFile {
|
||||
file, err := os.CreateTemp("", "codespace-selection-test")
|
||||
file, err := os.CreateTemp(t.TempDir(), "codespace-selection-test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ func selectSSHKeys(
|
|||
opts sshOptions,
|
||||
) (*ssh.KeyPair, bool, error) {
|
||||
customConfigPath := ""
|
||||
for i := 0; i < len(args); i += 1 {
|
||||
for i := range args {
|
||||
arg := args[i]
|
||||
|
||||
if arg == "-i" {
|
||||
|
|
@ -703,6 +703,7 @@ func automaticPrivateKeyPath(sshContext ssh.Context) (string, error) {
|
|||
|
||||
type cpOptions struct {
|
||||
sshOptions
|
||||
|
||||
recursive bool // -r
|
||||
expand bool // -e
|
||||
}
|
||||
|
|
@ -778,7 +779,6 @@ func (a *App) Copy(ctx context.Context, args []string, opts cpOptions) error {
|
|||
if !opts.expand {
|
||||
arg = `remote:'` + strings.Replace(rest, `'`, `'\''`, -1) + `'`
|
||||
}
|
||||
|
||||
} else if !filepath.IsAbs(arg) {
|
||||
// scp treats a colon in the first path segment as a host identifier.
|
||||
// Escape it by prepending "./".
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ func (e *Extension) URL() string {
|
|||
}
|
||||
case GitKind:
|
||||
if remoteURL, err := e.gitClient.Config("remote.origin.url"); err == nil {
|
||||
url = strings.TrimSpace(string(remoteURL))
|
||||
url = strings.TrimSpace(remoteURL)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ func (e *Extension) Owner() string {
|
|||
}
|
||||
case GitKind:
|
||||
if remoteURL, err := e.gitClient.Config("remote.origin.url"); err == nil {
|
||||
if url, err := git.ParseURL(strings.TrimSpace(string(remoteURL))); err == nil {
|
||||
if url, err := git.ParseURL(strings.TrimSpace(remoteURL)); err == nil {
|
||||
if repo, err := ghrepo.FromURL(url); err == nil {
|
||||
owner = repo.RepoOwner()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ func TestManager_UpgradeExtensions(t *testing.T) {
|
|||
exts, err := m.list(false)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 3, len(exts))
|
||||
for i := 0; i < 3; i++ {
|
||||
for i := range 3 {
|
||||
exts[i].currentVersion = "old version"
|
||||
exts[i].latestVersion = "new version"
|
||||
}
|
||||
|
|
@ -300,7 +300,7 @@ func TestManager_UpgradeExtensions_DryRun(t *testing.T) {
|
|||
exts, err := m.list(false)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 3, len(exts))
|
||||
for i := 0; i < 3; i++ {
|
||||
for i := range 3 {
|
||||
exts[i].currentVersion = fmt.Sprintf("%d", i)
|
||||
exts[i].latestVersion = fmt.Sprintf("%d", i+1)
|
||||
}
|
||||
|
|
@ -1010,7 +1010,6 @@ func TestManager_Install_binary_pinned(t *testing.T) {
|
|||
|
||||
assert.Equal(t, "", stdout.String())
|
||||
assert.Equal(t, "", stderr.String())
|
||||
|
||||
}
|
||||
|
||||
func TestManager_Install_binary_unsupported(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -675,7 +675,7 @@ func TestSSOURL(t *testing.T) {
|
|||
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if sso := r.URL.Query().Get("sso"); sso != "" {
|
||||
w.Header().Set("X-GitHub-SSO", sso)
|
||||
w.Header().Set("X-Github-Sso", sso)
|
||||
}
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}))
|
||||
|
|
@ -734,7 +734,7 @@ func TestPlainHttpClient(t *testing.T) {
|
|||
|
||||
assert.Equal(t, 204, res.StatusCode)
|
||||
assert.Equal(t, []string{"GitHub CLI v1.2.3"}, receivedHeaders.Values("User-Agent"))
|
||||
assert.Equal(t, []string{"2022-11-28"}, receivedHeaders.Values("X-GitHub-Api-Version"))
|
||||
assert.Equal(t, []string{"2022-11-28"}, receivedHeaders.Values("X-Github-Api-Version"))
|
||||
assert.Nil(t, receivedHeaders.Values("Authorization"))
|
||||
assert.Nil(t, receivedHeaders.Values("Content-Type"))
|
||||
assert.Nil(t, receivedHeaders.Values("Accept"))
|
||||
|
|
|
|||
|
|
@ -105,7 +105,6 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co
|
|||
}
|
||||
|
||||
func createRun(opts *CreateOptions) error {
|
||||
|
||||
readFromStdInArg, filenames := cmdutil.Partition(opts.Filenames, func(f string) bool {
|
||||
return f == "-"
|
||||
})
|
||||
|
|
|
|||
|
|
@ -292,7 +292,6 @@ func Test_deleteRun(t *testing.T) {
|
|||
return 0, nil
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tt.opts.Prompter = pm
|
||||
|
|
|
|||
|
|
@ -335,12 +335,11 @@ func editRun(opts *EditOptions) error {
|
|||
break
|
||||
}
|
||||
|
||||
choice := ""
|
||||
result, err := opts.Prompter.Select("What next?", "", editNextOptions)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not prompt: %w", err)
|
||||
}
|
||||
choice = editNextOptions[result]
|
||||
choice := editNextOptions[result]
|
||||
|
||||
stop := false
|
||||
|
||||
|
|
|
|||
|
|
@ -1255,7 +1255,6 @@ func TestIssueCreate_projectsV2(t *testing.T) {
|
|||
// TODO projectsV1Deprecation
|
||||
// Remove this test.
|
||||
func TestProjectsV1Deprecation(t *testing.T) {
|
||||
|
||||
t.Run("non-interactive submission", func(t *testing.T) {
|
||||
t.Run("when projects v1 is supported, queries for it", func(t *testing.T) {
|
||||
ios, _, _, _ := iostreams.Test()
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ import (
|
|||
)
|
||||
|
||||
type EditOptions struct {
|
||||
prShared.Editable
|
||||
|
||||
HttpClient func() (*http.Client, error)
|
||||
IO *iostreams.IOStreams
|
||||
BaseRepo func() (ghrepo.Interface, error)
|
||||
|
|
@ -34,8 +36,6 @@ type EditOptions struct {
|
|||
|
||||
IssueNumbers []int
|
||||
Interactive bool
|
||||
|
||||
prShared.Editable
|
||||
}
|
||||
|
||||
func NewCmdEdit(f *cmdutil.Factory, runF func(*EditOptions) error) *cobra.Command {
|
||||
|
|
|
|||
|
|
@ -327,7 +327,6 @@ func lockLockable(httpClient *http.Client, repo ghrepo.Interface, lockable *api.
|
|||
|
||||
// unlockLockable will unlock an issue or pull request
|
||||
func unlockLockable(httpClient *http.Client, repo ghrepo.Interface, lockable *api.Issue) error {
|
||||
|
||||
var mutation struct {
|
||||
UnlockLockable struct {
|
||||
UnlockedRecord struct {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ func TestParseIssuesFromArgs(t *testing.T) {
|
|||
assert.Equal(t, tc.expectedRepo, repo)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestFindIssuesOrPRs(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ func cloneLabels(client *http.Client, destination ghrepo.Interface, opts *cloneO
|
|||
toCreate := make(chan createOptions)
|
||||
|
||||
wg, ctx := errgroup.WithContext(context.Background())
|
||||
for i := 0; i < workers; i++ {
|
||||
for range workers {
|
||||
wg.Go(func() error {
|
||||
for {
|
||||
select {
|
||||
|
|
|
|||
|
|
@ -363,6 +363,7 @@ func Test_checkoutRun(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSpecificPRResolver(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("when the PR Finder returns results, those are returned", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
|
@ -398,6 +399,7 @@ func TestSpecificPRResolver(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPromptingPRResolver(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("when the PR Lister has results, then we prompt for a choice", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
|
|
|||
|
|
@ -540,7 +540,6 @@ func createRun(opts *CreateOptions) error {
|
|||
return err
|
||||
}
|
||||
} else {
|
||||
|
||||
if !opts.TitleProvided {
|
||||
err = shared.TitleSurvey(opts.Prompter, opts.IO, state)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -2632,7 +2632,6 @@ func mockRetrieveProjects(_ *testing.T, reg *httpmock.Registry) {
|
|||
// TODO projectsV1Deprecation
|
||||
// Remove this test.
|
||||
func TestProjectsV1Deprecation(t *testing.T) {
|
||||
|
||||
t.Run("non-interactive submission", func(t *testing.T) {
|
||||
t.Run("when projects v1 is supported, queries for it", func(t *testing.T) {
|
||||
ios, _, _, _ := iostreams.Test()
|
||||
|
|
|
|||
|
|
@ -341,7 +341,9 @@ type sanitizer struct{ transform.NopResetter }
|
|||
|
||||
// Transform implements transform.Transformer.
|
||||
func (t sanitizer) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
|
||||
for r, size := rune(0), 0; nSrc < len(src); {
|
||||
var r rune
|
||||
var size int
|
||||
for nSrc < len(src) {
|
||||
if r = rune(src[nSrc]); r < utf8.RuneSelf {
|
||||
size = 1
|
||||
} else if r, size = utf8.DecodeRune(src[nSrc:]); size == 1 && !atEOF && !utf8.FullRune(src[nSrc:]) {
|
||||
|
|
@ -355,7 +357,7 @@ func (t sanitizer) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err e
|
|||
err = transform.ErrShortDst
|
||||
break
|
||||
}
|
||||
for i := 0; i < size; i++ {
|
||||
for range size {
|
||||
dst[nDst] = src[nSrc]
|
||||
nDst++
|
||||
nSrc++
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ import (
|
|||
)
|
||||
|
||||
type EditOptions struct {
|
||||
shared.Editable
|
||||
|
||||
HttpClient func() (*http.Client, error)
|
||||
IO *iostreams.IOStreams
|
||||
|
||||
|
|
@ -35,8 +37,6 @@ type EditOptions struct {
|
|||
|
||||
SelectorArg string
|
||||
Interactive bool
|
||||
|
||||
shared.Editable
|
||||
}
|
||||
|
||||
func NewCmdEdit(f *cmdutil.Factory, runF func(*EditOptions) error) *cobra.Command {
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ func TestPRRevert_acceptedIdentifierFormats(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
http := &httpmock.Registry{}
|
||||
defer http.Verify(t)
|
||||
|
||||
|
|
|
|||
|
|
@ -164,5 +164,4 @@ func TestPrCheckStatusSummaryWithColor(t *testing.T) {
|
|||
out := PrCheckStatusSummaryWithColor(cs, testCase.args)
|
||||
assert.Equal(t, testCase.want, out)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ type EditableSlice struct {
|
|||
// It contains a flag to indicate whether the assignees are actors or not.
|
||||
type EditableAssignees struct {
|
||||
EditableSlice
|
||||
|
||||
ActorAssignees bool
|
||||
DefaultLogins []string // For disambiguating actors from display names
|
||||
}
|
||||
|
|
@ -52,6 +53,7 @@ type EditableAssignees struct {
|
|||
// EditableReviewers is a special case of EditableSlice.
|
||||
type EditableReviewers struct {
|
||||
EditableSlice
|
||||
|
||||
DefaultLogins []string // For disambiguating actors from display names
|
||||
}
|
||||
|
||||
|
|
@ -59,6 +61,7 @@ type EditableReviewers struct {
|
|||
// Keep that map along with standard EditableSlice data.
|
||||
type EditableProjects struct {
|
||||
EditableSlice
|
||||
|
||||
ProjectItems map[string]string
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -484,7 +484,6 @@ func TestTryDetermineDefaultPRHead(t *testing.T) {
|
|||
require.Equal(t, "feature-branch", defaultPRHead.BranchName)
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func dummyRemotesFn() (ghContext.Remotes, error) {
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import (
|
|||
var _ GitConfigClient = &CachedBranchConfigGitConfigClient{}
|
||||
|
||||
type CachedBranchConfigGitConfigClient struct {
|
||||
CachedBranchConfig git.BranchConfig
|
||||
GitConfigClient
|
||||
CachedBranchConfig git.BranchConfig
|
||||
}
|
||||
|
||||
func (c CachedBranchConfigGitConfigClient) ReadBranchConfig(ctx context.Context, branchName string) (git.BranchConfig, error) {
|
||||
|
|
|
|||
|
|
@ -167,7 +167,6 @@ func (m *mockLister) List(opt ListOptions) (*api.PullRequestAndTotalCount, error
|
|||
}
|
||||
|
||||
if m.expectFields != nil {
|
||||
|
||||
if !isEqualSet(m.expectFields, opt.Fields) {
|
||||
return nil, fmt.Errorf("unexpected fields: %v", opt.Fields)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ const (
|
|||
EditCommitMessageAction
|
||||
EditCommitSubjectAction
|
||||
SubmitDraftAction
|
||||
)
|
||||
|
||||
const (
|
||||
noMilestone = "(none)"
|
||||
|
||||
submitLabel = "Submit"
|
||||
|
|
@ -35,14 +37,7 @@ const (
|
|||
cancelLabel = "Cancel"
|
||||
)
|
||||
|
||||
type Prompt interface {
|
||||
Input(prompt string, defaultValue string) (string, error)
|
||||
Select(prompt string, defaultValue string, options []string) (int, error)
|
||||
MarkdownEditor(prompt string, defaultValue string, blankAllowed bool) (string, error)
|
||||
Confirm(prompt string, defaultValue bool) (bool, error)
|
||||
MultiSelect(prompt string, defaults []string, options []string) ([]int, error)
|
||||
MultiSelectWithSearch(prompt, searchPrompt string, defaults []string, persistentOptions []string, searchFunc func(string) prompter.MultiSelectSearchResult) ([]string, error)
|
||||
}
|
||||
type Prompt = EditPrompter
|
||||
|
||||
func ConfirmIssueSubmission(p Prompt, allowPreview bool, allowMetadata bool) (Action, error) {
|
||||
return confirmSubmission(p, allowPreview, allowMetadata, false, false)
|
||||
|
|
|
|||
|
|
@ -189,9 +189,9 @@ func (m *templateManager) Choose() (Template, error) {
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
names := make([]string, len(m.templates))
|
||||
for i, t := range m.templates {
|
||||
names[i] = t.Name()
|
||||
names := make([]string, 0, len(m.templates))
|
||||
for _, t := range m.templates {
|
||||
names = append(names, t.Name())
|
||||
}
|
||||
|
||||
blankOption := "Open a blank issue"
|
||||
|
|
|
|||
|
|
@ -298,7 +298,6 @@ func printPrs(io *iostreams.IOStreams, totalCount int, prs ...api.PullRequest) {
|
|||
if pr.AutoMergeRequest != nil {
|
||||
fmt.Fprintf(w, " %s", cs.Green("✓ Auto-merge enabled"))
|
||||
}
|
||||
|
||||
} else {
|
||||
fmt.Fprintf(w, " - %s", shared.StateTitleWithColor(cs, pr))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,6 @@ func runDelete(config deleteConfig) error {
|
|||
}
|
||||
|
||||
return printResults(config, query.DeleteProject.Project)
|
||||
|
||||
}
|
||||
|
||||
func deleteItemArgs(config deleteConfig) (*deleteProjectMutation, map[string]interface{}) {
|
||||
|
|
|
|||
|
|
@ -111,7 +111,6 @@ func runAddItem(config addItemConfig) error {
|
|||
}
|
||||
|
||||
return printResults(config, query.CreateProjectItem.ProjectV2Item)
|
||||
|
||||
}
|
||||
|
||||
func addItemArgs(config addItemConfig) (*addProjectItemMutation, map[string]interface{}) {
|
||||
|
|
|
|||
|
|
@ -104,7 +104,6 @@ func runDeleteItem(config deleteItemConfig) error {
|
|||
}
|
||||
|
||||
return printResults(config)
|
||||
|
||||
}
|
||||
|
||||
func deleteItemArgs(config deleteItemConfig) (*deleteProjectItemMutation, map[string]interface{}) {
|
||||
|
|
|
|||
|
|
@ -110,7 +110,6 @@ func NewCmdLink(f *cmdutil.Factory, runF func(config linkConfig) error) *cobra.C
|
|||
}
|
||||
|
||||
func validateRepoOrTeamFlag(opts *linkOpts) error {
|
||||
|
||||
linkedTarget := ""
|
||||
if opts.repo != "" {
|
||||
linkedTarget = opts.repo
|
||||
|
|
|
|||
|
|
@ -111,7 +111,6 @@ func runMarkTemplate(config markTemplateConfig) error {
|
|||
}
|
||||
|
||||
return printResults(config, query.TemplateProject.Project)
|
||||
|
||||
}
|
||||
query, variables := markTemplateArgs(config)
|
||||
err = config.client.Mutate("MarkProjectTemplate", query, variables)
|
||||
|
|
|
|||
|
|
@ -324,7 +324,6 @@ func TestJSONProjectItem_DraftIssue_ProjectV2ItemFieldIterationValue(t *testing.
|
|||
t,
|
||||
`{"items":[{"sprint":{"title":"Iteration Title","startDate":"","duration":0,"iterationId":"iterationId"},"content":{"type":"DraftIssue","body":"a body","title":"Pull Request title","id":"draftIssueId"},"id":"draftIssueId"}],"totalCount":5}`,
|
||||
string(out))
|
||||
|
||||
}
|
||||
|
||||
func TestJSONProjectItem_DraftIssue_ProjectV2ItemFieldMilestoneValue(t *testing.T) {
|
||||
|
|
@ -363,5 +362,4 @@ func TestJSONProjectItem_DraftIssue_ProjectV2ItemFieldMilestoneValue(t *testing.
|
|||
t,
|
||||
`{"items":[{"milestone":{"title":"Milestone Title","dueOn":"","description":""},"content":{"type":"DraftIssue","body":"a body","title":"Pull Request title","id":"draftIssueId"},"id":"draftIssueId"}],"totalCount":5}`,
|
||||
string(out))
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ type iprompter interface {
|
|||
|
||||
type hostScopedClient struct {
|
||||
*api.Client
|
||||
|
||||
hostname string
|
||||
}
|
||||
|
||||
|
|
@ -207,6 +208,7 @@ type projectQueryBase struct {
|
|||
|
||||
type projectQueryWithQueryableItems struct {
|
||||
projectQueryBase
|
||||
|
||||
Items struct {
|
||||
PageInfo PageInfo
|
||||
TotalCount int
|
||||
|
|
@ -216,6 +218,7 @@ type projectQueryWithQueryableItems struct {
|
|||
|
||||
type projectQueryWithoutQueryableItems struct {
|
||||
projectQueryBase
|
||||
|
||||
Items struct {
|
||||
PageInfo PageInfo
|
||||
TotalCount int
|
||||
|
|
@ -1753,7 +1756,6 @@ func projectFieldValueData(v FieldValueNodes) interface{} {
|
|||
}
|
||||
}
|
||||
return names
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -408,7 +408,6 @@ func TestProjects_ViewerQueryDoesNotUseQueryItems(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestProjectFields_LowerLimit(t *testing.T) {
|
||||
|
||||
defer gock.Off()
|
||||
gock.Observe(gock.DumpRequest)
|
||||
|
||||
|
|
@ -605,7 +604,6 @@ func TestNewOwner_nonTTY(t *testing.T) {
|
|||
client := NewTestClient()
|
||||
_, err := client.NewOwner(false, "")
|
||||
assert.EqualError(t, err, "owner is required when not running interactively")
|
||||
|
||||
}
|
||||
|
||||
func TestProjectItems_FieldTitle(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -110,7 +110,6 @@ func NewCmdUnlink(f *cmdutil.Factory, runF func(config unlinkConfig) error) *cob
|
|||
}
|
||||
|
||||
func validateRepoOrTeamFlag(opts *unlinkOpts) error {
|
||||
|
||||
unlinkedTarget := ""
|
||||
if opts.repo != "" {
|
||||
unlinkedTarget = opts.repo
|
||||
|
|
|
|||
|
|
@ -160,7 +160,6 @@ func TestRunView_User(t *testing.T) {
|
|||
|
||||
err := runView(config)
|
||||
assert.NoError(t, err)
|
||||
|
||||
}
|
||||
|
||||
func TestRunView_Viewer(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -253,9 +253,9 @@ func createRun(opts *CreateOptions) error {
|
|||
}
|
||||
|
||||
if len(tags) != 0 {
|
||||
options := make([]string, len(tags))
|
||||
for i, tag := range tags {
|
||||
options[i] = tag.Name
|
||||
options := make([]string, 0, len(tags)+1)
|
||||
for _, tag := range tags {
|
||||
options = append(options, tag.Name)
|
||||
}
|
||||
createNewTagOption := "Create a new tag"
|
||||
options = append(options, createNewTagOption)
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ func downloadAssets(dest *destinationWriter, httpClient *http.Client, toDownload
|
|||
close(jobs)
|
||||
|
||||
var downloadError error
|
||||
for i := 0; i < len(toDownload); i++ {
|
||||
for range toDownload {
|
||||
if err := <-results; err != nil && !errors.Is(err, errSkipped) {
|
||||
downloadError = err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,13 +58,13 @@ func (v *AttestationVerifier) VerifyAttestation(art *artifact.DigestedArtifact,
|
|||
func FilterAttestationsByTag(attestations []*api.Attestation, tagName string) ([]*api.Attestation, error) {
|
||||
var filtered []*api.Attestation
|
||||
for _, att := range attestations {
|
||||
statement := att.Bundle.Bundle.GetDsseEnvelope().Payload
|
||||
statement := att.Bundle.Bundle.GetDsseEnvelope().GetPayload()
|
||||
var statementData v1.Statement
|
||||
err := protojson.Unmarshal([]byte(statement), &statementData)
|
||||
err := protojson.Unmarshal(statement, &statementData)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal statement: %w", err)
|
||||
}
|
||||
tagValue := statementData.Predicate.GetFields()["tag"].GetStringValue()
|
||||
tagValue := statementData.GetPredicate().GetFields()["tag"].GetStringValue()
|
||||
|
||||
if tagValue == tagName {
|
||||
filtered = append(filtered, att)
|
||||
|
|
@ -76,14 +76,14 @@ func FilterAttestationsByTag(attestations []*api.Attestation, tagName string) ([
|
|||
func FilterAttestationsByFileDigest(attestations []*api.Attestation, fileDigest string) ([]*api.Attestation, error) {
|
||||
var filtered []*api.Attestation
|
||||
for _, att := range attestations {
|
||||
statement := att.Bundle.Bundle.GetDsseEnvelope().Payload
|
||||
statement := att.Bundle.Bundle.GetDsseEnvelope().GetPayload()
|
||||
var statementData v1.Statement
|
||||
err := protojson.Unmarshal([]byte(statement), &statementData)
|
||||
err := protojson.Unmarshal(statement, &statementData)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal statement: %w", err)
|
||||
}
|
||||
subjects := statementData.Subject
|
||||
subjects := statementData.GetSubject()
|
||||
for _, subject := range subjects {
|
||||
digestMap := subject.GetDigest()
|
||||
alg := "sha256"
|
||||
|
|
@ -93,7 +93,6 @@ func FilterAttestationsByFileDigest(attestations []*api.Attestation, fileDigest
|
|||
filtered = append(filtered, att)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return filtered, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,25 +192,25 @@ func printVerifiedSubjects(io *iostreams.IOStreams, att *verification.Attestatio
|
|||
cs := io.ColorScheme()
|
||||
w := io.Out
|
||||
|
||||
statement := att.Attestation.Bundle.GetDsseEnvelope().Payload
|
||||
statement := att.Attestation.Bundle.GetDsseEnvelope().GetPayload()
|
||||
var statementData v1.Statement
|
||||
|
||||
err := protojson.Unmarshal([]byte(statement), &statementData)
|
||||
err := protojson.Unmarshal(statement, &statementData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// If there aren't at least two subjects, there are no assets to display
|
||||
if len(statementData.Subject) < 2 {
|
||||
if len(statementData.GetSubject()) < 2 {
|
||||
return nil
|
||||
}
|
||||
|
||||
fmt.Fprintln(w, cs.Bold("Assets"))
|
||||
table := tableprinter.New(io, tableprinter.WithHeader("Name", "Digest"))
|
||||
|
||||
for _, s := range statementData.Subject {
|
||||
name := s.Name
|
||||
digest := s.Digest
|
||||
for _, s := range statementData.GetSubject() {
|
||||
name := s.GetName()
|
||||
digest := s.GetDigest()
|
||||
|
||||
if name != "" {
|
||||
digestStr := ""
|
||||
|
|
|
|||
|
|
@ -158,7 +158,6 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co
|
|||
if opts.Name == "" && !opts.Interactive {
|
||||
return cmdutil.FlagErrorf("name argument required to create new remote repository")
|
||||
}
|
||||
|
||||
} else if opts.Clone || opts.GitIgnoreTemplate != "" || opts.LicenseTemplate != "" || opts.Template != "" {
|
||||
return cmdutil.FlagErrorf("the `--source` option is not supported with `--clone`, `--template`, `--license`, or `--gitignore`")
|
||||
}
|
||||
|
|
@ -428,7 +427,6 @@ func createFromScratch(opts *CreateOptions) error {
|
|||
} else if err := cloneWithRetry(opts, remoteURL, templateRepoMainBranch); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -762,7 +760,7 @@ func hasCommits(gitClient *git.Client) (bool, error) {
|
|||
|
||||
var execError *exec.ExitError
|
||||
if errors.As(err, &execError) {
|
||||
exitCode := int(execError.ExitCode())
|
||||
exitCode := execError.ExitCode()
|
||||
if exitCode == 128 {
|
||||
return false, nil
|
||||
}
|
||||
|
|
@ -784,7 +782,7 @@ func localRepoType(gitClient *git.Client) (repoType, error) {
|
|||
if projectDirErr != nil {
|
||||
var execError errWithExitCode
|
||||
if errors.As(projectDirErr, &execError) {
|
||||
if exitCode := int(execError.ExitCode()); exitCode == 128 {
|
||||
if exitCode := execError.ExitCode(); exitCode == 128 {
|
||||
return unknown, nil
|
||||
}
|
||||
return unknown, projectDirErr
|
||||
|
|
|
|||
|
|
@ -258,7 +258,6 @@ func Test_createRun(t *testing.T) {
|
|||
reg.Register(
|
||||
httpmock.REST("POST", "user/repos"),
|
||||
httpmock.StringResponse(`{"name":"REPO", "owner":{"login": "OWNER"}, "html_url":"https://github.com/OWNER/REPO"}`))
|
||||
|
||||
},
|
||||
execStubs: func(cs *run.CommandStubber) {
|
||||
cs.Register(`git clone https://github.com/OWNER/REPO.git`, 0, "")
|
||||
|
|
|
|||
|
|
@ -198,12 +198,12 @@ func creditsRun(opts *CreditsOptions) error {
|
|||
margin := termWidth / 3
|
||||
|
||||
starLinesLeft := []string{}
|
||||
for x := 0; x < len(lines); x++ {
|
||||
for range lines {
|
||||
starLinesLeft = append(starLinesLeft, starLine(r, margin))
|
||||
}
|
||||
|
||||
starLinesRight := []string{}
|
||||
for x := 0; x < len(lines); x++ {
|
||||
for x := range lines {
|
||||
lineWidth := termWidth - (margin + len(lines[x]))
|
||||
starLinesRight = append(starLinesRight, starLine(r, lineWidth))
|
||||
}
|
||||
|
|
@ -248,7 +248,7 @@ func creditsRun(opts *CreditsOptions) error {
|
|||
func starLine(r *rand.Rand, width int) string {
|
||||
line := ""
|
||||
starChance := 0.1
|
||||
for y := 0; y < width; y++ {
|
||||
for range width {
|
||||
chance := r.Float64()
|
||||
if chance <= starChance {
|
||||
charRoll := r.Float64()
|
||||
|
|
|
|||
|
|
@ -607,7 +607,7 @@ func setTopics(ctx context.Context, httpClient *http.Client, repo ghrepo.Interfa
|
|||
return err
|
||||
}
|
||||
|
||||
req.Header.Set("Content-type", "application/json")
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
// "mercy-preview" is still needed for some GitHub Enterprise versions
|
||||
req.Header.Set("Accept", "application/vnd.github.mercy-preview+json")
|
||||
res, err := httpClient.Do(req)
|
||||
|
|
|
|||
|
|
@ -170,7 +170,6 @@ func forkRun(opts *ForkOptions) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("did not understand argument: %w", err)
|
||||
}
|
||||
|
||||
} else if strings.HasPrefix(repoArg, "git@") {
|
||||
parsedURL, err := git.ParseURL(repoArg)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ func gardenRun(opts *GardenOptions) error {
|
|||
sl := statusLine(garden, player, opts.IO)
|
||||
|
||||
fmt.Fprint(out, "\033[;H") // move to top left
|
||||
for y := 0; y < player.Geo.Height-1; y++ {
|
||||
for range player.Geo.Height - 1 {
|
||||
fmt.Fprint(out, "\033[B")
|
||||
}
|
||||
fmt.Fprintln(out)
|
||||
|
|
@ -342,12 +342,12 @@ func plantGarden(r *rand.Rand, commits []*Commit, geo *Geometry) [][]*Cell {
|
|||
streamIx--
|
||||
}
|
||||
tint := 0
|
||||
for y := 0; y < geo.Height; y++ {
|
||||
for y := range geo.Height {
|
||||
if cellIx == len(commits)-1 {
|
||||
break
|
||||
}
|
||||
garden = append(garden, []*Cell{})
|
||||
for x := 0; x < geo.Width; x++ {
|
||||
for x := range geo.Width {
|
||||
if (y > 0 && (x == 0 || x == geo.Width-1)) || y == geo.Height-1 {
|
||||
garden[y] = append(garden[y], &Cell{
|
||||
Char: RGB(0, 150, 0, "^"),
|
||||
|
|
@ -417,7 +417,7 @@ func drawGarden(io *iostreams.IOStreams, garden [][]*Cell, player *Player) {
|
|||
sl := ""
|
||||
for y, gardenRow := range garden {
|
||||
for x, gardenCell := range gardenRow {
|
||||
char := ""
|
||||
var char string
|
||||
underPlayer := (player.X == x && player.Y == y)
|
||||
if underPlayer {
|
||||
sl = gardenCell.StatusLine
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman
|
|||
Aliases: []string{"ls"},
|
||||
Args: cobra.ExactArgs(0),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
||||
if runF != nil {
|
||||
return runF(opts)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman
|
|||
Aliases: []string{"ls"},
|
||||
Args: cobra.ExactArgs(0),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
||||
if runF != nil {
|
||||
return runF(opts)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ func listRun(opts *ListOptions) error {
|
|||
tp.AddField(run.Title(), tableprinter.WithColor(cs.Bold))
|
||||
tp.AddField(run.WorkflowName())
|
||||
tp.AddField(run.HeadBranch, tableprinter.WithColor(cs.Bold))
|
||||
tp.AddField(string(run.Event))
|
||||
tp.AddField(run.Event)
|
||||
tp.AddField(fmt.Sprintf("%d", run.ID), tableprinter.WithColor(cs.Cyan))
|
||||
tp.AddField(run.Duration(opts.now).String())
|
||||
tp.AddTimeField(opts.now, run.StartedTime(), cs.Muted)
|
||||
|
|
|
|||
|
|
@ -160,7 +160,6 @@ func TestNewCmdRerun(t *testing.T) {
|
|||
assert.Equal(t, tt.wants.Prompt, gotOpts.Prompt)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestRerun(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ func (c RunLogCache) Create(key string, content io.Reader) error {
|
|||
|
||||
if _, err := io.Copy(out, content); err != nil {
|
||||
return fmt.Errorf("writing cache entry: %v", err)
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -349,7 +348,7 @@ func runView(opts *ViewOptions) error {
|
|||
|
||||
var artifacts []shared.Artifact
|
||||
if selectedJob == nil {
|
||||
artifacts, err = shared.ListArtifacts(httpClient, repo, strconv.FormatInt(int64(run.ID), 10))
|
||||
artifacts, err = shared.ListArtifacts(httpClient, repo, strconv.FormatInt(run.ID, 10))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get artifacts: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,9 @@ const (
|
|||
// Limitation of GitHub search see:
|
||||
// https://docs.github.com/en/rest/reference/search
|
||||
SearchMaxResults = 1000
|
||||
)
|
||||
|
||||
const (
|
||||
Both EntityType = iota
|
||||
Issues
|
||||
PullRequests
|
||||
|
|
|
|||
|
|
@ -171,7 +171,6 @@ func NewCmdSet(f *cmdutil.Factory, runF func(*SetOptions) error) *cobra.Command
|
|||
if opts.Visibility == shared.Selected && (len(opts.RepositoryNames) == 0 && !noRepositoriesSelected) {
|
||||
return cmdutil.FlagErrorf("`--repos` or `--no-repos-selected` required with `--visibility=selected`")
|
||||
}
|
||||
|
||||
} else {
|
||||
if len(opts.RepositoryNames) > 0 || noRepositoriesSelected {
|
||||
opts.Visibility = shared.Selected
|
||||
|
|
@ -297,7 +296,7 @@ func setRun(opts *SetOptions) error {
|
|||
|
||||
var errs []error
|
||||
cs := opts.IO.ColorScheme()
|
||||
for i := 0; i < len(secrets); i++ {
|
||||
for range len(secrets) {
|
||||
result := <-setc
|
||||
if result.err != nil {
|
||||
errs = append(errs, result.err)
|
||||
|
|
|
|||
|
|
@ -805,7 +805,7 @@ func Test_getBodyPrompt(t *testing.T) {
|
|||
|
||||
func Test_getSecretsFromOptions(t *testing.T) {
|
||||
genFile := func(s string) string {
|
||||
f, err := os.CreateTemp("", "gh-env.*")
|
||||
f, err := os.CreateTemp(t.TempDir(), "gh-env.*")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
return ""
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ func UserKeys(httpClient *http.Client, host, userHandle string) ([]sshKey, error
|
|||
return nil, err
|
||||
}
|
||||
|
||||
for i := 0; i < len(keys); i++ {
|
||||
for i := range keys {
|
||||
keys[i].Type = AuthenticationKey
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ func UserSigningKeys(httpClient *http.Client, host, userHandle string) ([]sshKey
|
|||
return nil, err
|
||||
}
|
||||
|
||||
for i := 0; i < len(keys); i++ {
|
||||
for i := range keys {
|
||||
keys[i].Type = SigningKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ func (s *StatusGetter) LoadNotifications() error {
|
|||
fetched := make(chan StatusItem)
|
||||
|
||||
wg := new(errgroup.Group)
|
||||
for i := 0; i < fetchWorkers; i++ {
|
||||
for range fetchWorkers {
|
||||
wg.Go(func() error {
|
||||
for {
|
||||
select {
|
||||
|
|
@ -337,7 +337,7 @@ func (s *StatusGetter) LoadNotifications() error {
|
|||
// not work with PATs right now.
|
||||
nIndex := 0
|
||||
p := fmt.Sprintf("notifications?%s", query.Encode())
|
||||
for pages := 0; pages < 3; pages++ {
|
||||
for range 3 {
|
||||
var resp []Notification
|
||||
next, err := c.RESTWithNext(s.hostname(), "GET", p, nil, &resp)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ func setRun(opts *SetOptions) error {
|
|||
|
||||
var errs []error
|
||||
cs := opts.IO.ColorScheme()
|
||||
for i := 0; i < len(variables); i++ {
|
||||
for range len(variables) {
|
||||
result := <-setc
|
||||
if result.Err != nil {
|
||||
errs = append(errs, result.Err)
|
||||
|
|
|
|||
|
|
@ -477,7 +477,7 @@ func Test_getBody(t *testing.T) {
|
|||
|
||||
func Test_getVariablesFromOptions(t *testing.T) {
|
||||
genFile := func(s string) string {
|
||||
f, err := os.CreateTemp("", "gh-env.*")
|
||||
f, err := os.CreateTemp(t.TempDir(), "gh-env.*")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
return ""
|
||||
|
|
|
|||
|
|
@ -315,7 +315,6 @@ jobs:
|
|||
assert.Equal(t, tt.wantOut, result)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestRun(t *testing.T) {
|
||||
|
|
@ -994,7 +993,6 @@ jobs:
|
|||
pm.RegisterSelect("name", []string{"monalisa", "cschleiden"}, func(_, _ string, opts []string) (int, error) {
|
||||
return 0, nil
|
||||
})
|
||||
|
||||
},
|
||||
wantBody: map[string]interface{}{
|
||||
"inputs": map[string]interface{}{
|
||||
|
|
@ -1052,7 +1050,6 @@ jobs:
|
|||
pm.RegisterSelect("name", []string{"monalisa", "cschleiden"}, func(_, _ string, opts []string) (int, error) {
|
||||
return 0, nil
|
||||
})
|
||||
|
||||
},
|
||||
wantBody: map[string]interface{}{
|
||||
"inputs": map[string]interface{}{
|
||||
|
|
|
|||
|
|
@ -412,7 +412,7 @@ func TestGetWorkflows(t *testing.T) {
|
|||
func generateWorkflows(t *testing.T, workflowCount int, pageNum int) []Workflow {
|
||||
t.Helper()
|
||||
workflows := []Workflow{}
|
||||
for i := 0; i < workflowCount; i++ {
|
||||
for i := range workflowCount {
|
||||
workflows = append(workflows, Workflow{
|
||||
Name: fmt.Sprintf("Workflow-%d-%d", pageNum, i),
|
||||
ID: int64(i) + int64(pageNum-1)*100,
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ func viewWorkflowInfo(opts *ViewOptions, client *api.Client, repo ghrepo.Interfa
|
|||
|
||||
tp.AddField(run.WorkflowName())
|
||||
tp.AddField(run.HeadBranch, tableprinter.WithColor(cs.Bold))
|
||||
tp.AddField(string(run.Event))
|
||||
tp.AddField(run.Event)
|
||||
|
||||
if opts.Raw {
|
||||
tp.AddField(run.Duration(opts.now).String())
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ func addTemplateFlag(f *pflag.FlagSet, shorthand string) {
|
|||
}
|
||||
|
||||
func setupJsonFlags(cmd *cobra.Command, exportTarget *Exporter, fields []string) {
|
||||
|
||||
_ = cmd.RegisterFlagCompletionFunc("json", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
var results []string
|
||||
var prefix string
|
||||
|
|
@ -264,7 +263,7 @@ func (e *jsonExporter) exportData(v reflect.Value) interface{} {
|
|||
}
|
||||
case reflect.Slice:
|
||||
a := make([]interface{}, v.Len())
|
||||
for i := 0; i < v.Len(); i++ {
|
||||
for i := range v.Len() {
|
||||
a[i] = e.exportData(v.Index(i))
|
||||
}
|
||||
return a
|
||||
|
|
|
|||
|
|
@ -142,7 +142,6 @@ func TestAddJSONFlagsWithoutShorthand(t *testing.T) {
|
|||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
cmd := &cobra.Command{Run: func(*cobra.Command, []string) {}}
|
||||
tt.setFlags(cmd)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,19 +8,10 @@ import (
|
|||
)
|
||||
|
||||
func TestFindNonLegacy(t *testing.T) {
|
||||
tmpdir, err := os.MkdirTemp("", "gh-cli")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
type args struct {
|
||||
rootDir string
|
||||
name string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
prepare []string
|
||||
args args
|
||||
argName string
|
||||
want []string
|
||||
}{
|
||||
{
|
||||
|
|
@ -34,11 +25,8 @@ func TestFindNonLegacy(t *testing.T) {
|
|||
".github/issue_template.md",
|
||||
"docs/issue_template.md",
|
||||
},
|
||||
args: args{
|
||||
rootDir: tmpdir,
|
||||
name: "ISSUE_TEMPLATE",
|
||||
},
|
||||
want: []string{},
|
||||
argName: "ISSUE_TEMPLATE",
|
||||
want: []string{},
|
||||
},
|
||||
{
|
||||
name: "Template folder in .github takes precedence",
|
||||
|
|
@ -48,13 +36,8 @@ func TestFindNonLegacy(t *testing.T) {
|
|||
"ISSUE_TEMPLATE/abc.md",
|
||||
".github/ISSUE_TEMPLATE/abc.md",
|
||||
},
|
||||
args: args{
|
||||
rootDir: tmpdir,
|
||||
name: "ISSUE_TEMPLATE",
|
||||
},
|
||||
want: []string{
|
||||
path.Join(tmpdir, ".github/ISSUE_TEMPLATE/abc.md"),
|
||||
},
|
||||
argName: "ISSUE_TEMPLATE",
|
||||
want: []string{".github/ISSUE_TEMPLATE/abc.md"},
|
||||
},
|
||||
{
|
||||
name: "Template folder in root",
|
||||
|
|
@ -63,13 +46,8 @@ func TestFindNonLegacy(t *testing.T) {
|
|||
"docs/ISSUE_TEMPLATE/abc.md",
|
||||
"ISSUE_TEMPLATE/abc.md",
|
||||
},
|
||||
args: args{
|
||||
rootDir: tmpdir,
|
||||
name: "ISSUE_TEMPLATE",
|
||||
},
|
||||
want: []string{
|
||||
path.Join(tmpdir, "ISSUE_TEMPLATE/abc.md"),
|
||||
},
|
||||
argName: "ISSUE_TEMPLATE",
|
||||
want: []string{"ISSUE_TEMPLATE/abc.md"},
|
||||
},
|
||||
{
|
||||
name: "Template folder in docs",
|
||||
|
|
@ -77,13 +55,8 @@ func TestFindNonLegacy(t *testing.T) {
|
|||
"ISSUE_TEMPLATE.md",
|
||||
"docs/ISSUE_TEMPLATE/abc.md",
|
||||
},
|
||||
args: args{
|
||||
rootDir: tmpdir,
|
||||
name: "ISSUE_TEMPLATE",
|
||||
},
|
||||
want: []string{
|
||||
path.Join(tmpdir, "docs/ISSUE_TEMPLATE/abc.md"),
|
||||
},
|
||||
argName: "ISSUE_TEMPLATE",
|
||||
want: []string{"docs/ISSUE_TEMPLATE/abc.md"},
|
||||
},
|
||||
{
|
||||
name: "Multiple templates in template folder",
|
||||
|
|
@ -95,14 +68,11 @@ func TestFindNonLegacy(t *testing.T) {
|
|||
".github/PULL_REQUEST_TEMPLATE/three.md",
|
||||
"docs/pull_request_template.md",
|
||||
},
|
||||
args: args{
|
||||
rootDir: tmpdir,
|
||||
name: "PuLl_ReQuEsT_TeMpLaTe",
|
||||
},
|
||||
argName: "PuLl_ReQuEsT_TeMpLaTe",
|
||||
want: []string{
|
||||
path.Join(tmpdir, ".github/PULL_REQUEST_TEMPLATE/one.md"),
|
||||
path.Join(tmpdir, ".github/PULL_REQUEST_TEMPLATE/three.md"),
|
||||
path.Join(tmpdir, ".github/PULL_REQUEST_TEMPLATE/two.md"),
|
||||
".github/PULL_REQUEST_TEMPLATE/one.md",
|
||||
".github/PULL_REQUEST_TEMPLATE/three.md",
|
||||
".github/PULL_REQUEST_TEMPLATE/two.md",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -112,15 +82,13 @@ func TestFindNonLegacy(t *testing.T) {
|
|||
".docs/ISSUE_TEMPLATE/.keep",
|
||||
"ISSUE_TEMPLATE/.keep",
|
||||
},
|
||||
args: args{
|
||||
rootDir: tmpdir,
|
||||
name: "ISSUE_TEMPLATE",
|
||||
},
|
||||
want: []string{},
|
||||
argName: "ISSUE_TEMPLATE",
|
||||
want: []string{},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tmpdir := t.TempDir()
|
||||
for _, p := range tt.prepare {
|
||||
fp := path.Join(tmpdir, p)
|
||||
_ = os.MkdirAll(path.Dir(fp), 0700)
|
||||
|
|
@ -131,28 +99,22 @@ func TestFindNonLegacy(t *testing.T) {
|
|||
file.Close()
|
||||
}
|
||||
|
||||
if got := FindNonLegacy(tt.args.rootDir, tt.args.name); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("Find() = %v, want %v", got, tt.want)
|
||||
want := make([]string, len(tt.want))
|
||||
for i, w := range tt.want {
|
||||
want[i] = path.Join(tmpdir, w)
|
||||
}
|
||||
if got := FindNonLegacy(tmpdir, tt.argName); !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("Find() = %v, want %v", got, want)
|
||||
}
|
||||
})
|
||||
os.RemoveAll(tmpdir)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindLegacy(t *testing.T) {
|
||||
tmpdir, err := os.MkdirTemp("", "gh-cli")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
type args struct {
|
||||
rootDir string
|
||||
name string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
prepare []string
|
||||
args args
|
||||
argName string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
|
|
@ -164,11 +126,8 @@ func TestFindLegacy(t *testing.T) {
|
|||
"pull_request_template.md",
|
||||
"docs/issue_template.md",
|
||||
},
|
||||
args: args{
|
||||
rootDir: tmpdir,
|
||||
name: "ISSUE_TEMPLATE",
|
||||
},
|
||||
want: path.Join(tmpdir, "issue_template.md"),
|
||||
argName: "ISSUE_TEMPLATE",
|
||||
want: "issue_template.md",
|
||||
},
|
||||
{
|
||||
name: "No extension",
|
||||
|
|
@ -177,11 +136,8 @@ func TestFindLegacy(t *testing.T) {
|
|||
"issue_template",
|
||||
"docs/issue_template.md",
|
||||
},
|
||||
args: args{
|
||||
rootDir: tmpdir,
|
||||
name: "ISSUE_TEMPLATE",
|
||||
},
|
||||
want: path.Join(tmpdir, "issue_template"),
|
||||
argName: "ISSUE_TEMPLATE",
|
||||
want: "issue_template",
|
||||
},
|
||||
{
|
||||
name: "Dash instead of underscore",
|
||||
|
|
@ -190,11 +146,8 @@ func TestFindLegacy(t *testing.T) {
|
|||
"issue-template.txt",
|
||||
"docs/issue_template.md",
|
||||
},
|
||||
args: args{
|
||||
rootDir: tmpdir,
|
||||
name: "ISSUE_TEMPLATE",
|
||||
},
|
||||
want: path.Join(tmpdir, "issue-template.txt"),
|
||||
argName: "ISSUE_TEMPLATE",
|
||||
want: "issue-template.txt",
|
||||
},
|
||||
{
|
||||
name: "Template in .github takes precedence",
|
||||
|
|
@ -203,11 +156,8 @@ func TestFindLegacy(t *testing.T) {
|
|||
".github/issue_template.md",
|
||||
"docs/issue_template.md",
|
||||
},
|
||||
args: args{
|
||||
rootDir: tmpdir,
|
||||
name: "ISSUE_TEMPLATE",
|
||||
},
|
||||
want: path.Join(tmpdir, ".github/issue_template.md"),
|
||||
argName: "ISSUE_TEMPLATE",
|
||||
want: ".github/issue_template.md",
|
||||
},
|
||||
{
|
||||
name: "Template in docs",
|
||||
|
|
@ -215,11 +165,8 @@ func TestFindLegacy(t *testing.T) {
|
|||
"README.md",
|
||||
"docs/issue_template.md",
|
||||
},
|
||||
args: args{
|
||||
rootDir: tmpdir,
|
||||
name: "ISSUE_TEMPLATE",
|
||||
},
|
||||
want: path.Join(tmpdir, "docs/issue_template.md"),
|
||||
argName: "ISSUE_TEMPLATE",
|
||||
want: "docs/issue_template.md",
|
||||
},
|
||||
{
|
||||
name: "Non legacy templates ignored",
|
||||
|
|
@ -229,15 +176,13 @@ func TestFindLegacy(t *testing.T) {
|
|||
"docs/PULL_REQUEST_TEMPLATE/abc.md",
|
||||
".github/PULL_REQUEST_TEMPLATE.md",
|
||||
},
|
||||
args: args{
|
||||
rootDir: tmpdir,
|
||||
name: "PuLl_ReQuEsT_TeMpLaTe",
|
||||
},
|
||||
want: path.Join(tmpdir, ".github/PULL_REQUEST_TEMPLATE.md"),
|
||||
argName: "PuLl_ReQuEsT_TeMpLaTe",
|
||||
want: ".github/PULL_REQUEST_TEMPLATE.md",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tmpdir := t.TempDir()
|
||||
for _, p := range tt.prepare {
|
||||
fp := path.Join(tmpdir, p)
|
||||
_ = os.MkdirAll(path.Dir(fp), 0700)
|
||||
|
|
@ -248,14 +193,14 @@ func TestFindLegacy(t *testing.T) {
|
|||
file.Close()
|
||||
}
|
||||
|
||||
got := FindLegacy(tt.args.rootDir, tt.args.name)
|
||||
want := path.Join(tmpdir, tt.want)
|
||||
got := FindLegacy(tmpdir, tt.argName)
|
||||
if got == "" {
|
||||
t.Errorf("FindLegacy() = nil, want %v", tt.want)
|
||||
} else if got != tt.want {
|
||||
t.Errorf("FindLegacy() = %v, want %v", got, tt.want)
|
||||
t.Errorf("FindLegacy() = nil, want %v", want)
|
||||
} else if got != want {
|
||||
t.Errorf("FindLegacy() = %v, want %v", got, want)
|
||||
}
|
||||
})
|
||||
os.RemoveAll(tmpdir)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -582,6 +582,7 @@ func (w *pagerWriter) Write(d []byte) (int, error) {
|
|||
// fdWriter represents a wrapped stdout Writer that preserves the original file descriptor
|
||||
type fdWriter struct {
|
||||
io.Writer
|
||||
|
||||
fd uintptr
|
||||
}
|
||||
|
||||
|
|
@ -592,6 +593,7 @@ func (w *fdWriter) Fd() uintptr {
|
|||
// fdWriteCloser represents a wrapped stdout Writer that preserves the original file descriptor
|
||||
type fdWriteCloser struct {
|
||||
io.WriteCloser
|
||||
|
||||
fd uintptr
|
||||
}
|
||||
|
||||
|
|
@ -602,6 +604,7 @@ func (w *fdWriteCloser) Fd() uintptr {
|
|||
// fdReader represents a wrapped stdin ReadCloser that preserves the original file descriptor
|
||||
type fdReader struct {
|
||||
io.ReadCloser
|
||||
|
||||
fd uintptr
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ func ExampleOption_UnwrapOrZero() {
|
|||
fmt.Println(o.Some(4).UnwrapOrZero())
|
||||
fmt.Println(o.None[int]().UnwrapOrZero())
|
||||
|
||||
// Output
|
||||
// Output:
|
||||
// 4
|
||||
// 0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ func (q Qualifiers) Map() map[string][]string {
|
|||
m := map[string][]string{}
|
||||
v := reflect.ValueOf(q)
|
||||
t := reflect.TypeOf(q)
|
||||
for i := 0; i < v.NumField(); i++ {
|
||||
for i := range v.NumField() {
|
||||
fieldName := t.Field(i).Name
|
||||
key := camelToKebab(fieldName)
|
||||
typ := v.FieldByName(fieldName).Kind()
|
||||
|
|
@ -255,7 +255,7 @@ func (q Qualifiers) Map() map[string][]string {
|
|||
continue
|
||||
}
|
||||
s := []string{}
|
||||
for i := 0; i < value.Len(); i++ {
|
||||
for i := range value.Len() {
|
||||
if value.Index(i).IsZero() {
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ func init() {
|
|||
// EXTENDED to enable different prompting behavior
|
||||
type GhEditor struct {
|
||||
*survey.Editor
|
||||
|
||||
EditorCommand string
|
||||
BlankAllowed bool
|
||||
|
||||
|
|
@ -56,6 +57,7 @@ var EditorQuestionTemplate = `
|
|||
// EXTENDED to pass editor name (to use in prompt)
|
||||
type EditorTemplateData struct {
|
||||
survey.Editor
|
||||
|
||||
EditorCommand string
|
||||
BlankAllowed bool
|
||||
Answer string
|
||||
|
|
|
|||
|
|
@ -252,6 +252,7 @@ func (t *testTerminal) Stdio() terminal.Stdio {
|
|||
// teeWriter is a writer that duplicates all writes to a file into a buffer
|
||||
type teeWriter struct {
|
||||
*os.File
|
||||
|
||||
buf bytes.Buffer
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue