Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on:
push:
branches:
- "main"
pull_request:
branches:
- "main"

jobs:
checks:
name: Checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: "go.mod"
cache: true

- name: Lint
uses: golangci/golangci-lint-action@v6
with:
verify: true
version: latest

- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: ./...

- name: Run govulncheck
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
43 changes: 43 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: "2"

formatters:
enable:
- gofmt
- goimports
- golines
settings:
gofmt:
simplify: true
golines:
max-len: 120
tab-len: 4
shorten-comments: false
reformat-tags: true
chain-split-dots: true

linters:
enable:
- errcheck
- goconst
- gocyclo
- govet
- ineffassign
- misspell
- staticcheck
- unconvert
- whitespace
- unused
settings:
govet:
enable:
- shadow
gocyclo:
min-complexity: 15
goconst:
min-len: 3
min-occurrences: 3

run:
timeout: 5m
issues-exit-code: 1
tests: false
25 changes: 20 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ module github.com/valeriobelli/gh-milestone
go 1.26

require (
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/MakeNowJust/heredoc/v2 v2.0.1
github.com/briandowns/spinner v1.18.1
github.com/charmbracelet/bubbles v1.0.0
github.com/charmbracelet/bubbletea v1.3.10
github.com/cli/go-gh/v2 v2.13.0
github.com/fatih/color v1.13.0
github.com/google/go-github/v68 v68.0.0
Expand All @@ -19,24 +20,38 @@ require (
)

require (
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/colorprofile v0.4.1 // indirect
github.com/charmbracelet/lipgloss v1.1.1-0.20250319133953-166f707985bc // indirect
github.com/charmbracelet/x/ansi v0.11.6 // indirect
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
github.com/charmbracelet/x/term v0.2.2 // indirect
github.com/cli/safeexec v1.0.1 // indirect
github.com/creack/pty v1.1.18 // indirect
github.com/clipperhouse/displaywidth v0.9.0 // indirect
github.com/clipperhouse/stringish v0.1.1 // indirect
github.com/clipperhouse/uax29/v2 v2.5.0 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/henvic/httpretty v0.1.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/itchyny/timefmt-go v0.1.5 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.19 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/shurcooL/graphql v0.0.0-20200928012149-18c5c3165e3a // indirect
github.com/stretchr/testify v1.7.1 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/net v0.50.0 // indirect
golang.org/x/sys v0.41.0 // indirect
golang.org/x/term v0.40.0 // indirect
golang.org/x/text v0.34.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
70 changes: 35 additions & 35 deletions go.sum

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion internal/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ func Execute() {

rootCommand.Flags().BoolP("version", "v", false, "Print the version of this extension")
rootCommand.PersistentFlags().BoolP("help", "h", false, "Show help for command")
rootCommand.PersistentFlags().StringP("repo", "R", "", "Select another repository using the [HOST/]OWNER/REPO format")
rootCommand.PersistentFlags().
StringP("repo", "R", "", "Select another repository using the [HOST/]OWNER/REPO format")

rootCommand.AddCommand(newCreateCommand())
rootCommand.AddCommand(newDeleteCommand())
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func newListCommand() *cobra.Command {
Long: heredoc.Doc(
`List the available milestones on Github.

Optionally, the Milestones can be filtered by a search string and status and ordered by some criterias.
Optionally, the Milestones can be filtered by a search string and status and ordered by some criteria.

This command permit to print the output as a JSON string and interact with this latter using jq.
`),
Expand All @@ -72,7 +72,7 @@ func newListCommand() *cobra.Command {
command.SilenceUsage = true

return fmt.Errorf(
"Unknown JSON field: %q\nAvailable fields:\n %s",
"unknown JSON field: %q\nAvailable fields:\n %s",
field,
strings.Join(github.MilestoneFields, "\n "),
)
Expand Down Expand Up @@ -117,7 +117,7 @@ func newListCommand() *cobra.Command {
sort.Strings(github.MilestoneFields)

return fmt.Errorf(
"Specify one or more comma-separated fields for `--json`:\n %s",
"specify one or more comma-separated fields for `--json`:\n %s",
strings.Join(github.MilestoneFields, "\n "),
)
}
Expand Down
16 changes: 9 additions & 7 deletions internal/pkg/application/create/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
)

func handleResponseError(response *github.Response) error {
defer response.Body.Close()
if err := response.Body.Close(); err != nil {
return err
}

body, err := io.ReadAll(response.Body)

Expand All @@ -34,19 +36,19 @@ func handleResponseError(response *github.Response) error {
for _, e := range errorResponse.Errors {
switch e.Code {
case "missing":
return errors.New(fmt.Sprintf("The requested milestone does not esist."))
return errors.New("the requested milestone does not exist")
case "missing_field":
return errors.New(fmt.Sprintf("The required field \"%s\" has not been set.", e.Field))
return fmt.Errorf("the required field %q has not been set", e.Field)
case "invalid":
return errors.New(fmt.Sprintf("The content set in the field \"%s\" is invalid.", e.Field))
return fmt.Errorf("the content set in the field %q is invalid", e.Field)
case "already_exists":
return errors.New("The milestone with the same title already exists.")
return errors.New("the milestone with the same title already exists")
case "unprocessable":
return errors.New("The data sent was unprocessable.")
return errors.New("the data sent was unprocessable")
case "custom":
return errors.New(e.Message)
default:
return errors.New("Unknown error")
return errors.New("unknown error")
}
}
}
Expand Down
Loading