chore: re-add linting/formatting job to ci

This commit is contained in:
Kai Armstrong 2022-11-17 18:36:09 +00:00 committed by Gary Holtz
parent 5ddf81ee69
commit 39e9e21313
146 changed files with 253 additions and 269 deletions

View File

@ -20,17 +20,20 @@ include:
- template: Security/SAST.gitlab-ci.yml
- template: Security/Dependency-Scanning.gitlab-ci.yml
- template: Security/Secret-Detection.gitlab-ci.yml
- local: .gitlab/ci/*.gitlab-ci.yml
# From: https://docs.gitlab.com/ee/ci/caching/#cache-go-dependencies
.go-cache:
variables:
GOPATH: $CI_PROJECT_DIR/.go
GOLANGCI_LINT_CACHE: $CI_PROJECT_DIR/.golangci-lint
before_script:
- mkdir -p .go
- mkdir -p .go .golangci-lint
cache:
paths:
- .go/pkg/mod/
- .golangci-lint/
.documentation:
stage: documentation

View File

@ -1,13 +1,14 @@
lint:
extends: .go-cache
image: registry.gitlab.com/gitlab-org/gitlab-build-images:golangci-lint-alpine
stage: test
script:
- golangci-lint --version
# Use default .golangci.yml file from the image if one is not present in the project root.
- '[ -e .golangci.yml ] || cp /golangci/.golangci.yml .'
# Write the code coverage report to gl-code-quality-report.json
# and print linting issues to stdout in the format: path/to/file:line description
# remove `--issues-exit-code 0` or set to non-zero to fail the job if linting issues are detected
- golangci-lint run --issues-exit-code 0 --out-format code-climate | tee gl-code-quality-report.json | jq -r '.[] | "\(.location.path):\(.location.lines.begin) \(.description)"'
- golangci-lint run --out-format colored-line-number:stdout,code-climate:gl-code-quality-report.json
artifacts:
reports:
codequality: gl-code-quality-report.json

View File

@ -1,7 +1,17 @@
linters:
enable:
- gofmt
run:
timeout: 5m
modules-download-mode: readonly
linters:
disable-all: true
enable:
- errcheck
- exportloopref
- gofumpt
- goimports
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused

View File

@ -1,3 +1,5 @@
# Contributing Guide
## Developer Certificate of Origin + License
Contributions to this repository are subject to the [Developer Certificate of Origin](https://docs.gitlab.com/ee/legal/developer_certificate_of_origin.html#developer-certificate-of-origin-version-11).
@ -16,26 +18,29 @@ Use your best judgement, and feel free to propose changes to this document in a
Please do:
* Check existing issues to verify that the bug or feature request has not already been submitted.
* Open an issue if things aren't working as expected.
* Open an issue to propose a significant change.
* Open an issue to propose a feature.
* Open a merge request to fix a bug.
* Open a merge request to fix documentation about a command.
* Open a merge request for an issue and leave a comment claiming it.
- Check existing issues to verify that the bug or feature request has not already been submitted.
- Open an issue if things aren't working as expected.
- Open an issue to propose a significant change.
- Open an issue to propose a feature.
- Open a merge request to fix a bug.
- Open a merge request to fix documentation about a command.
- Open a merge request for an issue and leave a comment claiming it.
Please avoid:
* Opening merge requests for issues marked `blocked`.
* Opening merge requests for documentation for a new command specifically. Manual pages are auto-generated from source after every release
- Opening merge requests for issues marked `blocked`.
- Opening merge requests for documentation for a new command specifically. Manual pages are auto-generated from source after every release
## Code of Conduct
We want to create a welcoming environment for everyone who is interested in contributing. Visit our [Code of Conduct page](https://about.gitlab.com/community/contribute/code-of-conduct/) to learn more about our commitment to an open and welcoming environment.
## Getting Started
### Building the project
Prerequisites:
- Go 1.16+
Build with: `make` or `go build -o bin/glab ./cmd/glab/main.go`
@ -59,6 +64,15 @@ on [GitLab.com](https://gitlab.com).
1. Make your change, add tests, and ensure tests pass
1. Submit a merge request
### Formatting your code
We use [`golangci-lint`](https://golangci-lint.run/) to lint and format
the code in this project. The linter configuration can be seen
[here](https://gitlab.com/gitlab-org/cli/-/blob/main/.golangci.yml).
Additional details about code style and format are in the
[go guide](https://docs.gitlab.com/ee/development/go_guide/#code-style-and-format).
## Commit Messages
### TL;DR: Your commit message should be semantic
@ -76,6 +90,7 @@ Any line of the commit message cannot be longer than 100 characters! This allows
```
### Message Header
Ideally, the commit message heading which contains the description, should not be more than 50 characters
The message header is a single line that contains a succinct description of the change containing a type, an optional scope, and a subject.
@ -100,9 +115,9 @@ Scope can be anything specifying the place of the commit change. For example eve
This is a very short description of the change
* `use imperative, present tense: “change” not “changed” nor “changes”`
* `don't capitalize the first letter`
* `no dot (.) at the end`
- `use imperative, present tense: “change” not “changed” nor “changes”`
- `don't capitalize the first letter`
- `no dot (.) at the end`
### Message Body
@ -137,4 +152,3 @@ fix(login): allow provided user preferences to override default preferences
Fixes #025
```

View File

@ -78,6 +78,7 @@ func GetClient() *Client {
// HTTPClient returns the httpClient instance used to initialise the gitlab api client
func HTTPClient() *http.Client { return apiClient.HTTPClient() }
func (c *Client) HTTPClient() *http.Client {
if c.httpClientOverride != nil {
return c.httpClientOverride
@ -90,12 +91,14 @@ func (c *Client) HTTPClient() *http.Client {
// OverrideHTTPClient overrides the default http client
func OverrideHTTPClient(client *http.Client) { apiClient.OverrideHTTPClient(client) }
func (c *Client) OverrideHTTPClient(client *http.Client) {
c.httpClientOverride = client
}
// Token returns the authentication token
func Token() string { return apiClient.Token() }
func (c *Client) Token() string {
return c.token
}

View File

@ -11,7 +11,7 @@ func Test_tlsConfig(t *testing.T) {
type args struct {
host string
}
var tests = []struct {
tests := []struct {
name string
args args
want []uint16
@ -38,7 +38,6 @@ func Test_tlsConfig(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
client := tlsConfig(tt.args.host)
assert.Equal(t, tt.want, client.CipherSuites)

View File

@ -166,7 +166,6 @@ var GetPipeline = func(client *gitlab.Client, pid int, l *gitlab.RequestOptionFu
}
pipe, _, err := client.Pipelines.GetPipeline(repo, pid)
if err != nil {
return nil, err
}
@ -185,7 +184,6 @@ var GetPipelineVariables = func(client *gitlab.Client, pid int, l *gitlab.Reques
projectID := pipe.ProjectID
pipelineVars, _, err := client.Pipelines.GetPipelineVariables(projectID, pid)
if err != nil {
return nil, err
}

View File

@ -12,7 +12,6 @@ var GetFile = func(client *gitlab.Client, projectID interface{}, path string, re
Ref: &ref,
}
file, _, err := client.RepositoryFiles.GetFile(projectID, path, fileOpts)
if err != nil {
return nil, err
}

View File

@ -55,7 +55,6 @@ var DeleteProjectVariable = func(client *gitlab.Client, projectID interface{}, k
},
}
_, err := client.ProjectVariables.RemoveVariable(projectID, key, reqOpts)
if err != nil {
return err
}
@ -68,7 +67,7 @@ var UpdateProjectVariable = func(client *gitlab.Client, projectID interface{}, k
client = apiClient.Lab()
}
var filter = func(request *retryablehttp.Request) error {
filter := func(request *retryablehttp.Request) error {
q := request.URL.Query()
q.Add("filter[environment_scope]", *opts.EnvironmentScope)
@ -127,7 +126,6 @@ var DeleteGroupVariable = func(client *gitlab.Client, groupID interface{}, key s
}
_, err := client.GroupVariables.RemoveVariable(groupID, key)
if err != nil {
return err
}

View File

@ -36,7 +36,7 @@ func main() {
}
os.Exit(1)
}
err := os.MkdirAll(*path, 0755)
err := os.MkdirAll(*path, 0o755)
if err != nil {
fatal(err)
}
@ -75,7 +75,7 @@ func genWebDocs(glabCli *cobra.Command, path string) error {
for _, cmd := range cmds {
fmt.Println("Generating docs for " + cmd.Name())
// create directories for parent commands
_ = os.MkdirAll(path+cmd.Name(), 0750)
_ = os.MkdirAll(path+cmd.Name(), 0o750)
// Generate parent command
out := new(bytes.Buffer)
@ -88,7 +88,7 @@ func genWebDocs(glabCli *cobra.Command, path string) error {
for _, cmdC := range cmd.Commands() {
if cmdC.HasAvailableSubCommands() {
fmt.Println("Generating subcommand docs for " + cmdC.Name())
_ = os.MkdirAll(path+cmd.Name()+"/"+cmdC.Name(), 0750)
_ = os.MkdirAll(path+cmd.Name()+"/"+cmdC.Name(), 0o750)
// Generate parent command
out := new(bytes.Buffer)
@ -97,7 +97,7 @@ func genWebDocs(glabCli *cobra.Command, path string) error {
return err
}
err = config.WriteFile(path+cmd.Name()+"/"+cmdC.Name()+"/index.md", out.Bytes(), 0755)
err = config.WriteFile(path+cmd.Name()+"/"+cmdC.Name()+"/index.md", out.Bytes(), 0o755)
if err != nil {
return err
}
@ -119,7 +119,7 @@ func genWebDocs(glabCli *cobra.Command, path string) error {
}
}
err = config.WriteFile(path+cmd.Name()+"/index.md", out.Bytes(), 0755)
err = config.WriteFile(path+cmd.Name()+"/index.md", out.Bytes(), 0o755)
if err != nil {
return err
}

View File

@ -10,7 +10,7 @@ import (
)
func NewCmdAlias(f *cmdutils.Factory) *cobra.Command {
var aliasCmd = &cobra.Command{
aliasCmd := &cobra.Command{
Use: "alias [command] [flags]",
Short: `Create, list and delete aliases`,
Long: ``,

View File

@ -23,7 +23,7 @@ func NewCmdDelete(f *cmdutils.Factory, runF func(*DeleteOptions) error) *cobra.C
IO: f.IO,
}
var aliasDeleteCmd = &cobra.Command{
aliasDeleteCmd := &cobra.Command{
Use: "delete <alias name> [flags]",
Short: `Delete an alias.`,
Long: ``,
@ -54,7 +54,6 @@ func deleteRun(cmd *cobra.Command, opts *DeleteOptions) error {
expansion, ok := aliasCfg.Get(opts.Name)
if !ok {
return fmt.Errorf("no such alias %s", opts.Name)
}
err = aliasCfg.Delete(opts.Name)
if err != nil {

View File

@ -25,7 +25,7 @@ func NewCmdList(f *cmdutils.Factory, runF func(*ListOptions) error) *cobra.Comma
IO: f.IO,
}
var aliasListCmd = &cobra.Command{
aliasListCmd := &cobra.Command{
Use: "list [flags]",
Short: `List the available aliases.`,
Long: ``,

View File

@ -28,7 +28,7 @@ func NewCmdSet(f *cmdutils.Factory, runF func(*SetOptions) error) *cobra.Command
Config: f.Config,
}
var aliasSetCmd = &cobra.Command{
aliasSetCmd := &cobra.Command{
Use: "set <alias name> '<command>' [flags]",
Short: `Set an alias.`,
Long: heredoc.Doc(`

View File

@ -83,7 +83,6 @@ func TestAliasSet_empty_aliases(t *testing.T) {
`))
output, err := runCommand(cfg, true, "co 'mr checkout'")
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
@ -135,13 +134,17 @@ func TestAliasSet_arg_processing(t *testing.T) {
{`iz 'issue list'`, "- Adding alias for.*iz.*issue list", "iz: issue list"},
{`ii 'issue list --author="$1" --label="$2"'`,
{
`ii 'issue list --author="$1" --label="$2"'`,
`- Adding alias for.*ii.*issue list --author="\$1" --label="\$2"`,
`ii: issue list --author="\$1" --label="\$2"`},
`ii: issue list --author="\$1" --label="\$2"`,
},
{`ix "issue list --author='\$1' --label='\$2'"`,
{
`ix "issue list --author='\$1' --label='\$2'"`,
`- Adding alias for.*ix.*issue list --author='\$1' --label='\$2'`,
`ix: issue list --author='\$1' --label='\$2'`},
`ix: issue list --author='\$1' --label='\$2'`,
},
}
for _, c := range cases {
@ -198,7 +201,6 @@ view: mr view
test.ExpectLines(t, output.Stderr(), "Adding alias for.*view.*mr view", "Added alias.")
assert.Equal(t, expected, mainBuf.String())
}
func TestAliasSet_invalid_command(t *testing.T) {

View File

@ -68,7 +68,6 @@ func httpRequest(client *api.Client, config config.Config, hostname string, meth
baseURL, _ = url.Parse(baseURLStr)
req, err := api.NewHTTPRequest(client, method, baseURL, body, headers, bodyIsJSON)
if err != nil {
return nil, err
}

View File

@ -100,7 +100,7 @@ hosts:
if envIsSet && originalEnvVarToken != "" {
_ = os.Setenv("GITLAB_TOKEN", "")
}
var client = &http.Client{}
client := &http.Client{}
client.Transport = roundTripFunc(func(req *http.Request) (*http.Response, error) {
t.Log("Tsti")
return &http.Response{

View File

@ -137,7 +137,6 @@ func loginRun() error {
"GitLab Self-hosted Instance",
},
}, &hostType)
if err != nil {
return fmt.Errorf("could not prompt: %w", err)
}

View File

@ -282,7 +282,6 @@ git_protocol: ssh
IO: io,
}
t.Run("no instance authenticated", func(t *testing.T) {
err := statusRun(opts)
assert.Equal(t, err, cmdutils.SilentError)
assert.Equal(t, stdout.String(), "")

View File

@ -15,7 +15,7 @@ import (
)
func NewCmdRun(f *cmdutils.Factory) *cobra.Command {
var jobArtifactCmd = &cobra.Command{
jobArtifactCmd := &cobra.Command{
Use: "artifact <refName> <jobName> [flags]",
Short: `Download all Artifacts from the last pipeline`,
Aliases: []string{"push"},
@ -26,7 +26,6 @@ func NewCmdRun(f *cmdutils.Factory) *cobra.Command {
Long: ``,
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
repo, err := f.BaseRepo()
if err != nil {
return err
@ -51,7 +50,7 @@ func NewCmdRun(f *cmdutils.Factory) *cobra.Command {
}
if !config.CheckPathExists(path) {
if err := os.Mkdir(path, 0755); err != nil {
if err := os.Mkdir(path, 0o755); err != nil {
return err
}
}

View File

@ -18,7 +18,7 @@ import (
)
func NewCmdCI(f *cmdutils.Factory) *cobra.Command {
var ciCmd = &cobra.Command{
ciCmd := &cobra.Command{
Use: "ci <command> [flags]",
Short: `Work with GitLab CI pipelines and jobs`,
Long: ``,

View File

@ -31,5 +31,4 @@ func TestPipelineCmd(t *testing.T) {
out := <-outC
assert.Contains(t, out, "Use \"ci [command] --help\" for more information about a command.\n")
}

View File

@ -15,7 +15,7 @@ import (
)
func NewCmdDelete(f *cmdutils.Factory) *cobra.Command {
var pipelineDeleteCmd = &cobra.Command{
pipelineDeleteCmd := &cobra.Command{
Use: "delete <id> [flags]",
Short: `Delete a CI pipeline`,
Example: heredoc.Doc(`
@ -25,7 +25,6 @@ func NewCmdDelete(f *cmdutils.Factory) *cobra.Command {
Long: ``,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
var err error
c := f.IO.Color()
apiClient, err := f.HttpClient()
@ -71,7 +70,6 @@ func NewCmdDelete(f *cmdutils.Factory) *cobra.Command {
}
return nil
},
}

View File

@ -22,7 +22,7 @@ type PipelineMergedResponse struct {
}
func NewCmdGet(f *cmdutils.Factory) *cobra.Command {
var pipelineGetCmd = &cobra.Command{
pipelineGetCmd := &cobra.Command{
Use: "get [flags]",
Short: `Get JSON of a running CI pipeline on current or other branch specified`,
Aliases: []string{"stats"},
@ -64,7 +64,14 @@ func NewCmdGet(f *cmdutils.Factory) *cobra.Command {
}
jobs, err := api.GetPipelineJobs(apiClient, pipelineId, repo.FullName())
if err != nil {
return err
}
variables, err := api.GetPipelineVariables(apiClient, pipelineId, nil, repo.FullName())
if err != nil {
return err
}
mergedPipelineObject := &PipelineMergedResponse{
Pipeline: pipeline,

View File

@ -14,7 +14,7 @@ import (
)
func NewCmdCI(f *cmdutils.Factory) *cobra.Command {
var pipelineCICmd = &cobra.Command{
pipelineCICmd := &cobra.Command{
Use: "ci <command> [flags]",
Short: `Work with GitLab CI pipelines and jobs`,
Example: heredoc.Doc(`

View File

@ -30,5 +30,4 @@ func TestNewCmdCI(t *testing.T) {
assert.Contains(t, stdout.String(), "Work with GitLab CI pipelines and jobs\n")
assert.Contains(t, stderr.String(), "")
assert.Contains(t, stdout.String(), "This command is deprecated. All the commands under it has been moved to `ci` or `pipeline` command. See https://gitlab.com/gitlab-org/cli/issues/372 for more info.\n")
}

View File

@ -17,7 +17,7 @@ import (
)
func NewCmdLint(f *cmdutils.Factory) *cobra.Command {
var pipelineCILintCmd = &cobra.Command{
pipelineCILintCmd := &cobra.Command{
Use: "lint",
Short: "Checks if your `.gitlab-ci.yml` file is valid.",
Args: cobra.MaximumNArgs(1),

View File

@ -14,7 +14,7 @@ import (
)
func NewCmdList(f *cmdutils.Factory) *cobra.Command {
var pipelineListCmd = &cobra.Command{
pipelineListCmd := &cobra.Command{
Use: "list [flags]",
Short: `Get the list of CI pipelines`,
Example: heredoc.Doc(`

View File

@ -12,7 +12,7 @@ import (
)
func NewCmdRetry(f *cmdutils.Factory) *cobra.Command {
var pipelineRetryCmd = &cobra.Command{
pipelineRetryCmd := &cobra.Command{
Use: "retry <job-id>",
Short: `Retry a CI job`,
Aliases: []string{},
@ -48,7 +48,6 @@ func NewCmdRetry(f *cmdutils.Factory) *cobra.Command {
fmt.Fprintln(f.IO.StdOut, "Retried job (id:", job.ID, "), status:", job.Status, ", ref:", job.Ref, ", weburl: ", job.WebURL, ")")
return nil
},
}

View File

@ -85,7 +85,7 @@ func extractFileVar(s string) (*gitlab.PipelineVariableOptions, error) {
}
func NewCmdRun(f *cmdutils.Factory) *cobra.Command {
var pipelineRunCmd = &cobra.Command{
pipelineRunCmd := &cobra.Command{
Use: "run [flags]",
Short: `Create or run a new CI pipeline`,
Aliases: []string{"create"},

View File

@ -17,7 +17,7 @@ import (
)
func NewCmdStatus(f *cmdutils.Factory) *cobra.Command {
var pipelineStatusCmd = &cobra.Command{
pipelineStatusCmd := &cobra.Command{
Use: "status [flags]",
Short: `View a running CI pipeline on current or other branch specified`,
Aliases: []string{"stats"},

View File

@ -37,7 +37,7 @@ func NewCmdTrace(f *cmdutils.Factory, runE func(traceOpts *TraceOpts) error) *co
opts := &TraceOpts{
IO: f.IO,
}
var pipelineCITraceCmd = &cobra.Command{
pipelineCITraceCmd := &cobra.Command{
Use: "trace [<job-id>] [flags]",
Short: `Trace a CI job log in real time`,
Example: heredoc.Doc(`

View File

@ -116,7 +116,6 @@ hosts:
assert.Equal(t, tt.wantOpts.IO, actualOpts.IO)
})
}
}
func TestTraceRun(t *testing.T) {
@ -182,5 +181,4 @@ func TestTraceRun(t *testing.T) {
tt.assertContains(t, stdout.String())
})
}
}

View File

@ -24,6 +24,9 @@ import (
"github.com/rivo/tview"
"github.com/spf13/cobra"
"github.com/xanzy/go-gitlab"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
type ViewOpts struct {
@ -38,7 +41,7 @@ type ViewOpts struct {
func NewCmdView(f *cmdutils.Factory) *cobra.Command {
opts := ViewOpts{}
var pipelineCIView = &cobra.Command{
pipelineCIView := &cobra.Command{
Use: "view [branch/tag]",
Short: "View, run, trace/logs, and cancel CI jobs current pipeline",
Long: heredoc.Doc(`Supports viewing, running, tracing, and canceling jobs.
@ -448,7 +451,8 @@ func jobsView(app *tview.Application, jobsCh chan []*gitlab.Job, inputCh chan st
x, y, w, h := boxX, maxY/6-4, maxTitle+2, 3
b := box(root, key, x, y, w, h)
b.SetText(strings.Title(j.Stage))
caser := cases.Title(language.English)
b.SetText(caser.String(j.Stage))
b.SetTextAlign(tview.AlignCenter)
}
@ -525,8 +529,8 @@ func jobsView(app *tview.Application, jobsCh chan []*gitlab.Job, inputCh chan st
}
root.SendToFront("jobs-" + curJob.Name)
}
func box(root *tview.Pages, key string, x, y, w, h int) *tview.TextView {
b, ok := boxes[key]
if !ok {

View File

@ -411,7 +411,6 @@ func Test_LinkJobsNegative(t *testing.T) {
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
assert.Error(t, linkJobs(screen, test.jobs, test.boxes))
})
}
}

View File

@ -465,7 +465,6 @@ func (ua *UserAssignments) UsersFromAddRemove(
apiClient *gitlab.Client,
actions []string,
) (*[]int, []string, error) {
var assignedIDs []int
var usernames []string

View File

@ -83,7 +83,6 @@ func Test_ParseAssignees(t *testing.T) {
assert.ElementsMatch(t, uaGot.ToReplace, tC.wantReplace)
})
}
}
func Test_VerifyAssignees(t *testing.T) {
@ -743,7 +742,6 @@ func Test_AssigneesPrompt(t *testing.T) {
assert.Equal(t, tC.expectedStdErr, outErr)
}
assert.ElementsMatch(t, got, tC.output)
})
}
@ -1114,8 +1112,8 @@ func Test_LabelsPromptPromptsFail(t *testing.T) {
assert.Nil(t, got)
assert.EqualError(t, err, "AskQuestionWithInput prompt failed")
})
}
func Test_LabelsPromptMultiSelect(t *testing.T) {
// mock glrepo.Remote object
repo := glrepo.New("foo", "bar")
@ -1380,5 +1378,4 @@ func TestListGitLabTemplates(t *testing.T) {
assert.EqualValues(t, test.wantTemplates, gotTemplates, "Templates got didn't match")
})
}
}

View File

@ -107,7 +107,6 @@ func HTTPClientFactory(f *Factory) {
}
func NewFactory() *Factory {
return &Factory{
Config: configFunc,
Remotes: remotesFunc,

View File

@ -17,7 +17,7 @@ func NewCmdCompletion(io *iostreams.IOStreams) *cobra.Command {
excludeDesc = false
)
var completionCmd = &cobra.Command{
completionCmd := &cobra.Command{
Use: "completion",
Short: "Generate shell completion scripts",
Long: heredoc.Docf(`

View File

@ -8,7 +8,7 @@ import (
)
func NewCmdBoard(f *cmdutils.Factory) *cobra.Command {
var issueCmd = &cobra.Command{
issueCmd := &cobra.Command{
Use: "board [command] [flags]",
Short: `Work with GitLab Issue Boards in the given project.`,
Long: ``,

View File

@ -14,7 +14,7 @@ import (
var boardName string
func NewCmdCreate(f *cmdutils.Factory) *cobra.Command {
var issueCmd = &cobra.Command{
issueCmd := &cobra.Command{
Use: "create [flags]",
Short: `Create a project issue board.`,
Long: ``,

View File

@ -76,7 +76,6 @@ func TestNewCmdCreate(t *testing.T) {
assert.Contains(t, out, tc.want)
assert.Contains(t, stderr.String(), "")
})
}
}

View File

@ -14,6 +14,9 @@ import (
"gitlab.com/gitlab-org/cli/api"
"gitlab.com/gitlab-org/cli/commands/cmdutils"
"gitlab.com/gitlab-org/cli/internal/glrepo"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
var (
@ -22,8 +25,10 @@ var (
repo glrepo.Interface
)
const closed string = "closed"
const opened string = "opened"
const (
closed string = "closed"
opened string = "opened"
)
type issueBoardViewOptions struct {
assignee string
@ -40,8 +45,8 @@ type boardMeta struct {
}
func NewCmdView(f *cmdutils.Factory) *cobra.Command {
var opts = &issueBoardViewOptions{}
var viewCmd = &cobra.Command{
opts := &issueBoardViewOptions{}
viewCmd := &cobra.Command{
Use: "view [flags]",
Short: `View project issue board.`,
Long: ``,
@ -149,16 +154,17 @@ func NewCmdView(f *cmdutils.Factory) *cobra.Command {
}
// format table title
caser := cases.Title(language.English)
var boardType, boardContext string
if selectedBoard.group != nil {
boardType = strings.Title("group")
boardType = caser.String("group")
boardContext = project.Namespace.Name
} else {
boardType = strings.Title("project")
boardType = caser.String("project")
boardContext = project.NameWithNamespace
}
root.SetBorderPadding(1, 1, 2, 2).SetBorder(true).SetTitle(
fmt.Sprintf(" %s • %s ", strings.Title(boardType+" issue board"), boardContext),
fmt.Sprintf(" %s • %s ", caser.String(boardType+" issue board"), boardContext),
)
screen, err := tcell.NewScreen()
@ -245,7 +251,7 @@ func buildLabelString(labelDetails []*gitlab.LabelDetails) string {
labels += fmt.Sprintf("[white:%s:-]%s[white:-:-] ", ld.Color, ld.Name)
}
if labels != "" {
labels = strings.TrimSpace(labels) + fmt.Sprintf("\n")
labels = strings.TrimSpace(labels) + "\n"
}
return labels
}
@ -269,7 +275,6 @@ func mapBoardData(
projectIssueBoards []*gitlab.IssueBoard,
projectGroupIssueBoards []*gitlab.GroupIssueBoard,
) ([]string, map[string]boardMeta) {
// find longest board name to base padding on
maxNameLength := 0
for _, board := range projectIssueBoards {

View File

@ -13,7 +13,7 @@ import (
)
func NewCmdClose(f *cmdutils.Factory) *cobra.Command {
var issueCloseCmd = &cobra.Command{
issueCloseCmd := &cobra.Command{
Use: "close <id>",
Short: `Close an issue`,
Long: ``,

View File

@ -60,7 +60,6 @@ func Test_issueClose(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.Name, func(t *testing.T) {
io, _, stdout, stderr := iostreams.Test()
f := cmdtest.StubFactory("https://gitlab.com/glab-cli/test")
f.IO = io

View File

@ -61,7 +61,7 @@ func NewCmdCreate(f *cmdutils.Factory) *cobra.Command {
Remotes: f.Remotes,
Config: f.Config,
}
var issueCreateCmd = &cobra.Command{
issueCreateCmd := &cobra.Command{
Use: "create [flags]",
Short: `Create an issue`,
Long: ``,

View File

@ -64,7 +64,8 @@ func Test_IssueCreate(t *testing.T) {
cmd := NewCmdCreate(f)
cmd.Flags().StringP("repo", "R", "", "")
cliStr := []string{"-t", "myissuetitle",
cliStr := []string{
"-t", "myissuetitle",
"-d", "myissuebody",
"-l", "test,bug",
"--weight", "1",

View File

@ -12,7 +12,7 @@ import (
)
func NewCmdDelete(f *cmdutils.Factory) *cobra.Command {
var issueDeleteCmd = &cobra.Command{
issueDeleteCmd := &cobra.Command{
Use: "delete <id>",
Short: `Delete an issue`,
Long: ``,

View File

@ -68,7 +68,6 @@ func TestNewCmdDelete(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
io, _, stdout, stderr := iostreams.Test()
f := cmdtest.StubFactory("")
f.IO = io

View File

@ -19,7 +19,7 @@ import (
)
func NewCmdIssue(f *cmdutils.Factory) *cobra.Command {
var issueCmd = &cobra.Command{
issueCmd := &cobra.Command{
Use: "issue [command] [flags]",
Short: `Work with GitLab issues`,
Long: ``,

View File

@ -100,7 +100,6 @@ func IssuesFromArgs(apiClient *gitlab.Client, baseRepoFn func() (glrepo.Interfac
return nil, nil, err
}
return issues, baseRepo, nil
}
func IssueFromArg(apiClient *gitlab.Client, baseRepoFn func() (glrepo.Interface, error), arg string) (*gitlab.Issue, glrepo.Interface, error) {
@ -139,8 +138,10 @@ func IssueFromArg(apiClient *gitlab.Client, baseRepoFn func() (glrepo.Interface,
//
// OWNER/REPO/issues/id
// GROUP/NAMESPACE/REPO/issues/id
var issueURLPersonalRE = regexp.MustCompile(`^/([^/]+)/([^/]+)/issues/(\d+)`)
var issueURLGroupRE = regexp.MustCompile(`^/([^/]+)/([^/]+)/([^/]+)/issues/(\d+)`)
var (
issueURLPersonalRE = regexp.MustCompile(`^/([^/]+)/([^/]+)/issues/(\d+)`)
issueURLGroupRE = regexp.MustCompile(`^/([^/]+)/([^/]+)/([^/]+)/issues/(\d+)`)
)
func issueMetadataFromURL(s string) (int, glrepo.Interface) {
u, err := url.Parse(s)

View File

@ -56,11 +56,11 @@ type ListOptions struct {
}
func NewCmdList(f *cmdutils.Factory, runE func(opts *ListOptions) error) *cobra.Command {
var opts = &ListOptions{
opts := &ListOptions{
IO: f.IO,
}
var issueListCmd = &cobra.Command{
issueListCmd := &cobra.Command{
Use: "list [flags]",
Short: `List project issues`,
Long: ``,

View File

@ -208,7 +208,6 @@ func TestIssueList_tty_withIssueType(t *testing.T) {
func TestIssueList_tty_mine(t *testing.T) {
t.Run("mine with all flag and user exists", func(t *testing.T) {
fakeHTTP := httpmock.New()
defer fakeHTTP.Verify(t)
@ -230,7 +229,6 @@ func TestIssueList_tty_mine(t *testing.T) {
`)
})
t.Run("user does not exists", func(t *testing.T) {
fakeHTTP := httpmock.New()
defer fakeHTTP.Verify(t)

View File

@ -15,7 +15,7 @@ import (
)
func NewCmdNote(f *cmdutils.Factory) *cobra.Command {
var issueNoteCreateCmd = &cobra.Command{
issueNoteCreateCmd := &cobra.Command{
Use: "note <issue-id>",
Aliases: []string{"comment"},
Short: "Add a comment or note to an issue on GitLab",

View File

@ -72,7 +72,6 @@ func Test_NewCmdNote(t *testing.T) {
defer fakeHTTP.Verify(t)
t.Run("--message flag specified", func(t *testing.T) {
fakeHTTP.RegisterResponder("POST", "/projects/OWNER/REPO/issues/1/notes",
httpmock.NewStringResponse(201, `
{
@ -153,7 +152,6 @@ func Test_mrNoteCreate_prompt(t *testing.T) {
defer fakeHTTP.Verify(t)
t.Run("message provided", func(t *testing.T) {
fakeHTTP.RegisterResponder("POST", "/projects/OWNER/REPO/issues/1/notes",
httpmock.NewStringResponse(201, `
{
@ -190,7 +188,6 @@ func Test_mrNoteCreate_prompt(t *testing.T) {
})
t.Run("message is empty", func(t *testing.T) {
fakeHTTP.RegisterResponder("GET", "/projects/OWNER/REPO/issues/1",
httpmock.NewStringResponse(200, `
{

View File

@ -13,7 +13,7 @@ import (
)
func NewCmdReopen(f *cmdutils.Factory) *cobra.Command {
var issueReopenCmd = &cobra.Command{
issueReopenCmd := &cobra.Command{
Use: "reopen <id>",
Short: `Reopen a closed issue`,
Long: ``,
@ -30,7 +30,6 @@ func NewCmdReopen(f *cmdutils.Factory) *cobra.Command {
c := f.IO.Color()
apiClient, err := f.HttpClient()
if err != nil {
return err
}

View File

@ -11,7 +11,7 @@ import (
)
func NewCmdSubscribe(f *cmdutils.Factory) *cobra.Command {
var issueSubscribeCmd = &cobra.Command{
issueSubscribeCmd := &cobra.Command{
Use: "subscribe <id>",
Short: `Subscribe to an issue`,
Long: ``,

View File

@ -12,7 +12,7 @@ import (
)
func NewCmdUnsubscribe(f *cmdutils.Factory) *cobra.Command {
var issueUnsubscribeCmd = &cobra.Command{
issueUnsubscribeCmd := &cobra.Command{
Use: "unsubscribe <id>",
Short: `Unsubscribe to an issue`,
Long: ``,

View File

@ -15,7 +15,7 @@ import (
)
func NewCmdUpdate(f *cmdutils.Factory) *cobra.Command {
var issueUpdateCmd = &cobra.Command{
issueUpdateCmd := &cobra.Command{
Use: "update <id>",
Short: `Update issue`,
Long: ``,

View File

@ -102,7 +102,6 @@ func TestNewCmdUpdate(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.Name, func(t *testing.T) {
args, _ := shlex.Split(tc.Issue)
cmd.SetArgs(args)
cmd.SetOut(ioutil.Discard)

View File

@ -36,7 +36,7 @@ func NewCmdView(f *cmdutils.Factory) *cobra.Command {
opts := &ViewOpts{
IO: f.IO,
}
var issueViewCmd = &cobra.Command{
issueViewCmd := &cobra.Command{
Use: "view <id>",
Short: `Display the title, body, and other information about an issue.`,
Long: ``,
@ -50,7 +50,6 @@ func NewCmdView(f *cmdutils.Factory) *cobra.Command {
`),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
apiClient, err := f.HttpClient()
if err != nil {
return err

View File

@ -151,7 +151,6 @@ func TestNewCmdView(t *testing.T) {
}
t.Run("show", func(t *testing.T) {
cmd := NewCmdView(stubFactory)
cmdutils.EnableRepoOverride(cmd, stubFactory)
_, err := cmdtest.RunCommand(cmd, "13 -c -s -R glab-cli/test")

View File

@ -12,7 +12,7 @@ import (
)
func NewCmdCreate(f *cmdutils.Factory) *cobra.Command {
var labelCreateCmd = &cobra.Command{
labelCreateCmd := &cobra.Command{
Use: "create [flags]",
Short: `Create labels for repository/project`,
Long: ``,
@ -24,7 +24,6 @@ func NewCmdCreate(f *cmdutils.Factory) *cobra.Command {
`),
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
var err error
apiClient, err := f.HttpClient()

View File

@ -8,7 +8,7 @@ import (
)
func NewCmdLabel(f *cmdutils.Factory) *cobra.Command {
var labelCmd = &cobra.Command{
labelCmd := &cobra.Command{
Use: "label <command> [flags]",
Short: `Manage labels on remote`,
Long: ``,

View File

@ -14,7 +14,7 @@ import (
)
func NewCmdList(f *cmdutils.Factory) *cobra.Command {
var labelListCmd = &cobra.Command{
labelListCmd := &cobra.Command{
Use: "list [flags]",
Short: `List labels in repository`,
Long: ``,
@ -76,7 +76,6 @@ func NewCmdList(f *cmdutils.Factory) *cobra.Command {
//}
return nil
},
}

View File

@ -12,7 +12,7 @@ import (
)
func NewCmdApprove(f *cmdutils.Factory) *cobra.Command {
var mrApproveCmd = &cobra.Command{
mrApproveCmd := &cobra.Command{
Use: "approve {<id> | <branch>}",
Short: `Approve merge requests`,
Long: ``,

View File

@ -10,7 +10,7 @@ import (
)
func NewCmdApprovers(f *cmdutils.Factory) *cobra.Command {
var mrApproversCmd = &cobra.Command{
mrApproversCmd := &cobra.Command{
Use: "approvers [<id> | <branch>] [flags]",
Short: `List eligible approvers for merge requests in any state`,
Long: ``,

View File

@ -19,12 +19,10 @@ type mrCheckoutConfig struct {
upstream string
}
var (
mrCheckoutCfg mrCheckoutConfig
)
var mrCheckoutCfg mrCheckoutConfig
func NewCmdCheckout(f *cmdutils.Factory) *cobra.Command {
var mrCheckoutCmd = &cobra.Command{
mrCheckoutCmd := &cobra.Command{
Use: "checkout [<id> | <branch>]",
Short: "Checkout to an open merge request",
Long: ``,
@ -93,7 +91,6 @@ func NewCmdCheckout(f *cmdutils.Factory) *cobra.Command {
fmt.Println(err)
}
repoRemote, err := remotes.FindByRepo(repo.RepoOwner(), repo.RepoName())
if err != nil {
fmt.Println(err)
}

View File

@ -13,7 +13,7 @@ import (
)
func NewCmdClose(f *cmdutils.Factory) *cobra.Command {
var mrCloseCmd = &cobra.Command{
mrCloseCmd := &cobra.Command{
Use: "close [<id> | <branch>]",
Short: `Close merge requests`,
Long: ``,

View File

@ -83,7 +83,7 @@ func NewCmdCreate(f *cmdutils.Factory, runE func(opts *CreateOpts) error) *cobra
HeadRepo: resolvedHeadRepo(f),
}
var mrCreateCmd = &cobra.Command{
mrCreateCmd := &cobra.Command{
Use: "create",
Short: `Create new merge request`,
Long: ``,
@ -607,7 +607,7 @@ func mrBodyAndTitle(opts *CreateOpts) error {
func handlePush(opts *CreateOpts, remote *glrepo.Remote) error {
if opts.ShouldPush {
var sourceRemote = remote
sourceRemote := remote
sourceBranch := opts.SourceBranch

View File

@ -150,7 +150,8 @@ func TestNewCmdCreate_tty(t *testing.T) {
deadbeef refs/remotes/origin/feat-new-mr
`))
cliStr := []string{"-t", "myMRtitle",
cliStr := []string{
"-t", "myMRtitle",
"-d", "myMRbody",
"-l", "test,bug",
"--milestone", "1",

View File

@ -12,7 +12,7 @@ import (
)
func NewCmdDelete(f *cmdutils.Factory) *cobra.Command {
var mrDeleteCmd = &cobra.Command{
mrDeleteCmd := &cobra.Command{
Use: "delete [<id> | <branch>]",
Short: `Delete merge requests`,
Long: ``,

View File

@ -121,7 +121,6 @@ hosts:
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cli := strings.Join(tt.args, " ")
t.Log(cli)
argv, err := shlex.Split(cli)

View File

@ -17,7 +17,7 @@ import (
)
func NewCmdFor(f *cmdutils.Factory) *cobra.Command {
var mrForCmd = &cobra.Command{
mrForCmd := &cobra.Command{
Use: "for",
Short: `Create new merge request for an issue`,
Long: ``,
@ -84,7 +84,6 @@ func NewCmdFor(f *cmdutils.Factory) *cobra.Command {
_, branchErr = api.CreateBranch(apiClient, repo.FullName(), lb)
fmt.Println(branchErr)
}
}
var mergeTitle string

View File

@ -15,7 +15,7 @@ import (
)
func NewCmdIssues(f *cmdutils.Factory) *cobra.Command {
var mrIssuesCmd = &cobra.Command{
mrIssuesCmd := &cobra.Command{
Use: "issues [<id> | <branch>]",
Short: `Get issues related to a particular merge request.`,
Long: ``,

View File

@ -53,11 +53,11 @@ type ListOptions struct {
}
func NewCmdList(f *cmdutils.Factory, runE func(opts *ListOptions) error) *cobra.Command {
var opts = &ListOptions{
opts := &ListOptions{
IO: f.IO,
}
var mrListCmd = &cobra.Command{
mrListCmd := &cobra.Command{
Use: "list [flags]",
Short: `List merge requests`,
Long: ``,
@ -230,7 +230,6 @@ func listRun(opts *ListOptions) error {
if len(assigneeIds) > 0 || len(reviewerIds) > 0 {
mergeRequests, err = api.ListMRsWithAssigneesOrReviewers(apiClient, repo.FullName(), l, assigneeIds, reviewerIds)
} else if opts.Group != "" {
mergeRequests, err = api.ListGroupMRs(apiClient, opts.Group, api.ProjectListMROptionsToGroup(l))
title.RepoName = opts.Group

View File

@ -42,11 +42,11 @@ type MergeOpts struct {
}
func NewCmdMerge(f *cmdutils.Factory) *cobra.Command {
var opts = &MergeOpts{
opts := &MergeOpts{
MergeMethod: MRMergeMethodMerge,
}
var mrMergeCmd = &cobra.Command{
mrMergeCmd := &cobra.Command{
Use: "merge {<id> | <branch>}",
Short: `Merge/Accept merge requests`,
Long: ``,
@ -264,7 +264,7 @@ func mergeMethodSurvey() (MRMergeMethod, error) {
method MRMergeMethod
}
var mergeOpts = []mergeOption{
mergeOpts := []mergeOption{
{title: "Create a merge commit", method: MRMergeMethodMerge},
{title: "Rebase and merge", method: MRMergeMethodRebase},
{title: "Squash and merge", method: MRMergeMethodSquash},

View File

@ -28,7 +28,7 @@ import (
)
func NewCmdMR(f *cmdutils.Factory) *cobra.Command {
var mrCmd = &cobra.Command{
mrCmd := &cobra.Command{
Use: "mr <command> [flags]",
Short: `Create, view and manage merge requests`,
Long: ``,

View File

@ -37,5 +37,4 @@ func TestMrCmd_noARgs(t *testing.T) {
out := <-outC
assert.Contains(t, out, "Use \"mr [command] --help\" for more information about a command.\n")
}

View File

@ -492,7 +492,6 @@ func Test_MRFromArgsWithOpts(t *testing.T) {
assert.Nil(t, gotMR)
assert.Nil(t, gotRepo)
assert.EqualError(t, err, `no merge requests from branch "foo"`)
})
t.Run("api.GetMR", func(t *testing.T) {
f := *f

View File

@ -14,7 +14,7 @@ import (
)
func NewCmdNote(f *cmdutils.Factory) *cobra.Command {
var mrCreateNoteCmd = &cobra.Command{
mrCreateNoteCmd := &cobra.Command{
Use: "note [<id> | <branch>]",
Aliases: []string{"comment"},
Short: "Add a comment or note to merge request",

View File

@ -77,7 +77,6 @@ func Test_NewCmdNote(t *testing.T) {
defer fakeHTTP.Verify(t)
t.Run("--message flag specified", func(t *testing.T) {
fakeHTTP.RegisterResponder("POST", "/projects/OWNER/REPO/merge_requests/1/notes",
httpmock.NewStringResponse(201, `
{
@ -158,7 +157,6 @@ func Test_mrNoteCreate_prompt(t *testing.T) {
defer fakeHTTP.Verify(t)
t.Run("message provided", func(t *testing.T) {
fakeHTTP.RegisterResponder("POST", "/projects/OWNER/REPO/merge_requests/1/notes",
httpmock.NewStringResponse(201, `
{
@ -195,7 +193,6 @@ func Test_mrNoteCreate_prompt(t *testing.T) {
})
t.Run("message is empty", func(t *testing.T) {
fakeHTTP.RegisterResponder("GET", "/projects/OWNER/REPO/merge_requests/1",
httpmock.NewStringResponse(200, `
{
@ -224,7 +221,6 @@ func Test_mrNoteCreate_no_duplicate(t *testing.T) {
defer fakeHTTP.Verify(t)
t.Run("message provided", func(t *testing.T) {
fakeHTTP.RegisterResponder("GET", "/projects/OWNER/REPO/merge_requests/1",
httpmock.NewStringResponse(200, `
{

View File

@ -9,7 +9,7 @@ import (
)
func NewCmdRebase(f *cmdutils.Factory) *cobra.Command {
var mrRebaseCmd = &cobra.Command{
mrRebaseCmd := &cobra.Command{
Use: "rebase [<id> | <branch>] [flags]",
Short: `Automatically rebase the source_branch of the merge request against its target_branch.`,
Long: heredoc.Doc(`If you don't have permissions to push to the merge request's source branch - you'll get a 403 Forbidden response.

View File

@ -13,7 +13,7 @@ import (
)
func NewCmdReopen(f *cmdutils.Factory) *cobra.Command {
var mrReopenCmd = &cobra.Command{
mrReopenCmd := &cobra.Command{
Use: "reopen [<id>... | <branch>...]",
Short: `Reopen merge requests`,
Example: heredoc.Doc(`

View File

@ -12,7 +12,7 @@ import (
)
func NewCmdRevoke(f *cmdutils.Factory) *cobra.Command {
var mrRevokeCmd = &cobra.Command{
mrRevokeCmd := &cobra.Command{
Use: "revoke [<id> | <branch>]",
Short: `Revoke approval on a merge request`,
Long: ``,

View File

@ -12,7 +12,7 @@ import (
)
func NewCmdSubscribe(f *cmdutils.Factory) *cobra.Command {
var mrSubscribeCmd = &cobra.Command{
mrSubscribeCmd := &cobra.Command{
Use: "subscribe [<id> | <branch>]",
Short: `Subscribe to merge requests`,
Long: ``,

View File

@ -104,7 +104,8 @@ hosts:
{
Name: "Issue on another repo",
Issue: "1 -R profclems/glab",
ExpectedMsg: []string{"- Subscribing to merge request !1",
ExpectedMsg: []string{
"- Subscribing to merge request !1",
"✓ You have successfully subscribed to merge request !1",
"https://gitlab.com/profclems/glab/-/merge_requests/1\n",
},

View File

@ -12,7 +12,7 @@ import (
)
func NewCmdTodo(f *cmdutils.Factory) *cobra.Command {
var mrToDoCmd = &cobra.Command{
mrToDoCmd := &cobra.Command{
Use: "todo [<id> | <branch>]",
Aliases: []string{"add-todo"},
Short: "Add a ToDo to merge request",

View File

@ -12,7 +12,7 @@ import (
)
func NewCmdUnsubscribe(f *cmdutils.Factory) *cobra.Command {
var mrUnsubscribeCmd = &cobra.Command{
mrUnsubscribeCmd := &cobra.Command{
Use: "unsubscribe [<id> | <branch>]",
Short: `Unsubscribe from merge requests`,
Long: ``,

View File

@ -15,7 +15,7 @@ import (
)
func NewCmdUpdate(f *cmdutils.Factory) *cobra.Command {
var mrUpdateCmd = &cobra.Command{
mrUpdateCmd := &cobra.Command{
Use: "update [<id> | <branch>]",
Short: `Update merge requests`,
Long: ``,

View File

@ -117,14 +117,16 @@ hosts:
{
Name: "Remove source branch",
Args: "1 --remove-source-branch",
ExpectedMsg: []string{"- Updating merge request !1",
ExpectedMsg: []string{
"- Updating merge request !1",
"✓ enabled removal of source branch on merge",
},
},
{
Name: "Restore remove source branch",
Args: "1 --remove-source-branch",
ExpectedMsg: []string{"- Updating merge request !1",
ExpectedMsg: []string{
"- Updating merge request !1",
"✓ disabled removal of source branch on merge",
},
},

View File

@ -31,7 +31,7 @@ func NewCmdView(f *cmdutils.Factory) *cobra.Command {
opts := &ViewOpts{
IO: f.IO,
}
var mrViewCmd = &cobra.Command{
mrViewCmd := &cobra.Command{
Use: "view {<id> | <branch>}",
Short: `Display the title, body, and other information about a merge request.`,
Long: ``,

View File

@ -164,7 +164,6 @@ func TestMRView(t *testing.T) {
cmdutils.EnableRepoOverride(cmd, stubFactory)
_, err := cmdtest.RunCommand(cmd, "13 -c -s -R glab-cli/test")
if err != nil {
t.Error(err)
return

View File

@ -16,7 +16,7 @@ import (
)
func NewCmdArchive(f *cmdutils.Factory) *cobra.Command {
var repoArchiveCmd = &cobra.Command{
repoArchiveCmd := &cobra.Command{
Use: "archive <command> [flags]",
Short: `Get an archive of the repository.`,
Example: heredoc.Doc(`

View File

@ -60,7 +60,7 @@ func NewCmdClone(f *cmdutils.Factory, runE func(*CloneOptions, *ContextOpts) err
ctxOpts := &ContextOpts{}
var repoCloneCmd = &cobra.Command{
repoCloneCmd := &cobra.Command{
Use: "clone <repo> [<dir>] [-- [<gitflags>...]]",
Short: `Clone a GitLab repository/project`,
Example: heredoc.Doc(`
@ -158,7 +158,7 @@ func NewCmdClone(f *cmdutils.Factory, runE func(*CloneOptions, *ContextOpts) err
func listProjects(opts *CloneOptions, ListGroupProjectOpts *gitlab.ListGroupProjectsOptions) ([]*gitlab.Project, error) {
var projects []*gitlab.Project
var hasRemaining = true
hasRemaining := true
for hasRemaining {
currentPage, resp, err := api.ListGroupProjects(opts.APIClient.Lab(), opts.GroupName, ListGroupProjectOpts)
@ -216,7 +216,7 @@ func groupClone(opts *CloneOptions, ctxOpts *ContextOpts) error {
ListGroupProjectOpts.Page = opts.Page
}
var projects, err = listProjects(opts, ListGroupProjectOpts)
projects, err := listProjects(opts, ListGroupProjectOpts)
var finalOutput []string
for _, project := range projects {
ctxOpt := *ctxOpts

View File

@ -189,20 +189,20 @@ hosts:
}
func Test_repoClone_group(t *testing.T) {
var names = []string{"glab-cli/test", "glab-cli/test-pv"}
var urls = []string{"git@gitlab.com:glab-cli/test.git", "git@gitlab.com:glab-cli/test-pv.git"}
names := []string{"glab-cli/test", "glab-cli/test-pv"}
urls := []string{"git@gitlab.com:glab-cli/test.git", "git@gitlab.com:glab-cli/test-pv.git"}
repoCloneTest(t, names, urls, 0, false)
}
func Test_repoClone_group_single(t *testing.T) {
var names = []string{"glab-cli/test"}
var urls = []string{"git@gitlab.com:glab-cli/test.git"}
names := []string{"glab-cli/test"}
urls := []string{"git@gitlab.com:glab-cli/test.git"}
repoCloneTest(t, names, urls, 1, false)
}
func Test_repoClone_group_paginate(t *testing.T) {
var names = []string{"glab-cli/test", "glab-cli/test-pv"}
var urls = []string{"git@gitlab.com:glab-cli/test.git", "git@gitlab.com:glab-cli/test-pv.git"}
names := []string{"glab-cli/test", "glab-cli/test-pv"}
urls := []string{"git@gitlab.com:glab-cli/test.git", "git@gitlab.com:glab-cli/test-pv.git"}
repoCloneTest(t, names, urls, 1, true)
}
@ -234,7 +234,7 @@ hosts:
defer restore()
cmd := NewCmdClone(fac, nil)
var cli = "-g glab-cli"
cli := "-g glab-cli"
if perPage != 0 {
cli += fmt.Sprintf(" --per-page %d", perPage)
}

View File

@ -29,7 +29,7 @@ func NewCmdContributors(f *cmdutils.Factory) *cobra.Command {
opts := &Options{
IO: f.IO,
}
var repoContributorsCmd = &cobra.Command{
repoContributorsCmd := &cobra.Command{
Use: "contributors",
Short: `Get repository contributors list.`,
Example: heredoc.Doc(`

View File

@ -21,7 +21,7 @@ import (
)
func NewCmdCreate(f *cmdutils.Factory) *cobra.Command {
var projectCreateCmd = &cobra.Command{
projectCreateCmd := &cobra.Command{
Use: "create [path] [flags]",
Short: `Create a new GitLab project/repository.`,
Long: ``,
@ -237,7 +237,6 @@ func initGit(defaultBranch string) error {
}
func initialiseRepo(projectPath, remoteURL string) error {
gitInit := git.GitCommand("init", projectPath)
gitInit.Stdout = os.Stdout
gitInit.Stderr = os.Stderr

View File

@ -26,13 +26,13 @@ type DeleteOpts struct {
}
func NewCmdDelete(f *cmdutils.Factory) *cobra.Command {
var opts = &DeleteOpts{
opts := &DeleteOpts{
IO: f.IO,
Lab: f.HttpClient,
BaseRepo: f.BaseRepo,
}
var projectCreateCmd = &cobra.Command{
projectCreateCmd := &cobra.Command{
Use: "delete [<NAMESPACE>/]<NAME>",
Short: `Delete an existing repository on GitLab.`,
Long: ``,

View File

@ -51,7 +51,7 @@ func NewCmdFork(f *cmdutils.Factory, runE func(*cmdutils.Factory) error) *cobra.
Config: f.Config,
CurrentDirIsParent: true,
}
var forkCmd = &cobra.Command{
forkCmd := &cobra.Command{
Use: "fork <repo>",
Short: "Create a fork of a GitLab repository",
Example: heredoc.Doc(`
@ -152,9 +152,9 @@ func forkRun(opts *ForkOptions) error {
// we query the import_status for the new project.
importStatus := ""
var importError error
var maximumRetries = 3
var retries = 0
var skipFirstCheck = true
maximumRetries := 3
retries := 0
skipFirstCheck := true
loop:
for {
if !skipFirstCheck {

Some files were not shown because too many files have changed in this diff Show More