Skip to content

Commit

Permalink
Merge pull request #106 from jvansanten/commit-status
Browse files Browse the repository at this point in the history
Display commit status in UI and other improvements
  • Loading branch information
Cian911 authored Dec 29, 2024
2 parents ed93104 + e83ab64 commit 9074e40
Show file tree
Hide file tree
Showing 11 changed files with 526 additions and 280 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.swp
debug.log
bin/*
dist/
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ Available Commands:
Flags:
-a, --approve Pass an optional approve flag as an argument which will only approve and not merge selected repos.
--close Pass an optional argument to close a pull request.
--commit-msg string Add a custom message when approving a pull request.
-c, --config string Pass an optional config file as an argument with list of repositories.
-d, --delay int Set the value of delay, which will determine how long to wait between mergeing pull requests. Default is (6) seconds. (default 6)
-e, --enterprise-base-url string For Github Enterprise users, you can pass your enterprise base. Format: http(s)://[hostname]/
Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.19

require (
github.com/AlecAivazis/survey/v2 v2.3.6
github.com/google/go-github/v45 v45.2.0
github.com/olekukonko/tablewriter v0.0.5
github.com/shurcooL/githubv4 v0.0.0-20240727222349-48295856cce7
github.com/spf13/cobra v1.6.1
github.com/spf13/viper v1.14.0
github.com/stretchr/testify v1.9.0
Expand All @@ -16,7 +16,6 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
Expand All @@ -30,12 +29,12 @@ require (
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
golang.org/x/crypto v0.13.0 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/term v0.12.0 // indirect
Expand Down
10 changes: 4 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-github/v45 v45.2.0 h1:5oRLszbrkvxDDqBCNj2hjDZMKmvexaZ1xw/FCD+K3FI=
github.com/google/go-github/v45 v45.2.0/go.mod h1:FObaZJEDSTa/WGCzZ2Z3eoCDXWJKMenWWTrd8jrta28=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
Expand Down Expand Up @@ -184,6 +180,10 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/githubv4 v0.0.0-20240727222349-48295856cce7 h1:cYCy18SHPKRkvclm+pWm1Lk4YrREb4IOIb/YdFO0p2M=
github.com/shurcooL/githubv4 v0.0.0-20240727222349-48295856cce7/go.mod h1:zqMwyHmnN/eDOZOdiTohqIUKUrTFX62PNlu7IJdu0q8=
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 h1:17JxqqJY66GmZVHkmAsGEkcIu0oCe3AM420QDgGwZx0=
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466/go.mod h1:9dIRpgIY7hVhoqfe0/FcYp0bpInZaT7dc3BYOprrIUE=
github.com/spf13/afero v1.9.2 h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw=
github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y=
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
Expand Down Expand Up @@ -226,8 +226,6 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down
34 changes: 22 additions & 12 deletions pkg/cli/gomerge/gomerge.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package gomerge

import (
"github.com/cian911/go-merge/pkg/cli/list"
"github.com/cian911/go-merge/pkg/cli/version"
"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/cian911/go-merge/pkg/cli/list"
"github.com/cian911/go-merge/pkg/cli/version"
)

func New() (c *cobra.Command) {
Expand All @@ -13,20 +14,30 @@ func New() (c *cobra.Command) {
Short: "Gomerge makes it simple to merge an open pull request from your terminal.",
}

c.PersistentFlags().StringP("repo", "r", "", "Pass name of repository as argument (organization/repo).")
c.PersistentFlags().
StringP("repo", "r", "", "Pass name of repository as argument (organization/repo).")
c.PersistentFlags().
StringArrayP("label", "l", []string{}, "Pass an optional list of labels to filter pull requests. (label1,label2,label3)")
c.PersistentFlags().StringP("token", "t", "", "Pass your github personal access token (PAT).")
c.PersistentFlags().StringP("config", "c", "", "Pass an optional config file as an argument with list of repositories.")
c.PersistentFlags().BoolP("approve", "a", false, "Pass an optional approve flag as an argument which will only approve and not merge selected repos.")
c.PersistentFlags().StringP("merge-method", "m", "", "Pass an optional merge method for the pull request (merge [default], squash, rebase).")
c.PersistentFlags().BoolP("skip", "s", false, "Pass an optional flag to skip a pull request and continue if one or more are not mergable.")
c.PersistentFlags().BoolP("close", "", false, "Pass an optional argument to close a pull request.")
c.PersistentFlags().IntP("delay", "d", 6, "Set the value of delay, which will determine how long to wait between mergeing pull requests. Default is (6) seconds.")
c.PersistentFlags().StringP("enterprise-base-url", "e", "", "For Github Enterprise users, you can pass your enterprise base. Format: http(s)://[hostname]/")
c.PersistentFlags().StringP("commit-msg", "", "", "Add a custom message when approving a pull request.")
c.PersistentFlags().
StringP("config", "c", "", "Pass an optional config file as an argument with list of repositories.")
c.PersistentFlags().
BoolP("approve", "a", false, "Pass an optional approve flag as an argument which will only approve and not merge selected repos.")
c.PersistentFlags().
StringP("merge-method", "m", "", "Pass an optional merge method for the pull request (merge [default], squash, rebase).")
c.PersistentFlags().
BoolP("skip", "s", false, "Pass an optional flag to skip a pull request and continue if one or more are not mergable.")
c.PersistentFlags().
BoolP("close", "", false, "Pass an optional argument to close a pull request.")
c.PersistentFlags().
IntP("delay", "d", 6, "Set the value of delay, which will determine how long to wait between mergeing pull requests. Default is (6) seconds.")
c.PersistentFlags().
StringP("enterprise-base-url", "e", "", "For Github Enterprise users, you can pass your enterprise base. Format: http(s)://[hostname]/")

c.MarkFlagRequired("token")

viper.BindPFlag("repo", c.PersistentFlags().Lookup("repo"))
viper.BindPFlag("label", c.PersistentFlags().Lookup("label"))
viper.BindPFlag("token", c.PersistentFlags().Lookup("token"))
viper.BindPFlag("config", c.PersistentFlags().Lookup("config"))
viper.BindPFlag("approve", c.PersistentFlags().Lookup("approve"))
Expand All @@ -35,7 +46,6 @@ func New() (c *cobra.Command) {
viper.BindPFlag("delay", c.PersistentFlags().Lookup("delay"))
viper.BindPFlag("close", c.PersistentFlags().Lookup("close"))
viper.BindPFlag("enterprise-base-url", c.PersistentFlags().Lookup("enterprise-base-url"))
viper.BindPFlag("commit-msg", c.PersistentFlags().Lookup("commit-msg"))

c.AddCommand(list.NewCommand())
c.AddCommand(version.NewCommand())
Expand Down
Loading

0 comments on commit 9074e40

Please sign in to comment.