diff options
author | Josh Bialkowski <josh.bialkowski@gmail.com> | 2019-11-22 22:34:19 -0800 |
---|---|---|
committer | Josh Bialkowski <josh.bialkowski@gmail.com> | 2019-12-18 07:42:16 -0800 |
commit | cd889572f7870a62758240b323a9086a76c5120a (patch) | |
tree | 2d8a210632e3b82517cd259760e94e375ebff123 /bridge/jira/client.go | |
parent | 7657a38ff20a7b3b2dbec5e6c981038c871f46e7 (diff) | |
download | git-bug-cd889572f7870a62758240b323a9086a76c5120a.tar.gz |
codereview #2: some cleanup, correct use of nothing-events
* return error, don't panic
* skipping status export is an error
* use switch in config.go
* move PromptPassword to input
* move client construction into getIdentityClient
* use non-pointer context throughout client since it is an interface
* remove some TODOs
* don't emit multiple nothing-events, just one per bug only if nothing
happened.
* rename EditBody to EditCreateComment
* add configuration notes about additional values
* store bug id map in a dictionary in the config
* some fixes from testing
Diffstat (limited to 'bridge/jira/client.go')
-rw-r--r-- | bridge/jira/client.go | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/bridge/jira/client.go b/bridge/jira/client.go index 486c1a87..6dd25ccb 100644 --- a/bridge/jira/client.go +++ b/bridge/jira/client.go @@ -15,6 +15,7 @@ import ( "github.com/MichaelMure/git-bug/bridge/core" "github.com/MichaelMure/git-bug/bug" + "github.com/MichaelMure/git-bug/input" "github.com/pkg/errors" ) @@ -318,12 +319,12 @@ func (self *ClientTransport) RoundTrip( type Client struct { *http.Client serverURL string - ctx *context.Context + ctx context.Context } // NewClient Construct a new client connected to the provided server and // utilizing the given context for asynchronous events -func NewClient(serverURL string, ctx *context.Context) *Client { +func NewClient(serverURL string, ctx context.Context) *Client { cookiJar, _ := cookiejar.New(nil) client := &http.Client{ Transport: &ClientTransport{underlyingTransport: http.DefaultTransport}, @@ -353,7 +354,7 @@ func (client *Client) Login(conf core.Configuration) error { password := conf[keyPassword] if password == "" { var err error - password, err = PromptPassword() + password, err = input.PromptPassword() if err != nil { return err } @@ -397,7 +398,7 @@ func (client *Client) RefreshTokenRaw(credentialsJSON []byte) error { } if client.ctx != nil { - ctx, cancel := context.WithTimeout(*client.ctx, defaultTimeout) + ctx, cancel := context.WithTimeout(client.ctx, defaultTimeout) defer cancel() req = req.WithContext(ctx) } @@ -465,7 +466,7 @@ func (client *Client) Search(jql string, maxResults int, startAt int) ( } if client.ctx != nil { - ctx, cancel := context.WithTimeout(*client.ctx, defaultTimeout) + ctx, cancel := context.WithTimeout(client.ctx, defaultTimeout) defer cancel() request = request.WithContext(ctx) } @@ -593,7 +594,7 @@ func (client *Client) GetIssue( request.URL.RawQuery = query.Encode() if client.ctx != nil { - ctx, cancel := context.WithTimeout(*client.ctx, defaultTimeout) + ctx, cancel := context.WithTimeout(client.ctx, defaultTimeout) defer cancel() request = request.WithContext(ctx) } @@ -648,7 +649,7 @@ func (client *Client) GetComments( request.URL.RawQuery = query.Encode() if client.ctx != nil { - ctx, cancel := context.WithTimeout(*client.ctx, defaultTimeout) + ctx, cancel := context.WithTimeout(client.ctx, defaultTimeout) defer cancel() request = request.WithContext(ctx) } @@ -776,7 +777,7 @@ func (client *Client) GetChangeLog( request.URL.RawQuery = query.Encode() if client.ctx != nil { - ctx, cancel := context.WithTimeout(*client.ctx, defaultTimeout) + ctx, cancel := context.WithTimeout(client.ctx, defaultTimeout) defer cancel() request = request.WithContext(ctx) } @@ -905,7 +906,7 @@ func (client *Client) GetProject(projectIDOrKey string) (*Project, error) { } if client.ctx != nil { - ctx, cancel := context.WithTimeout(*client.ctx, defaultTimeout) + ctx, cancel := context.WithTimeout(client.ctx, defaultTimeout) defer cancel() request = request.WithContext(ctx) } @@ -972,7 +973,7 @@ func (client *Client) CreateIssue( } if client.ctx != nil { - ctx, cancel := context.WithTimeout(*client.ctx, defaultTimeout) + ctx, cancel := context.WithTimeout(client.ctx, defaultTimeout) defer cancel() request = request.WithContext(ctx) } @@ -1086,7 +1087,7 @@ func (client *Client) UpdateIssueBody( } if client.ctx != nil { - ctx, cancel := context.WithTimeout(*client.ctx, defaultTimeout) + ctx, cancel := context.WithTimeout(client.ctx, defaultTimeout) defer cancel() request = request.WithContext(ctx) } @@ -1138,7 +1139,7 @@ func (client *Client) AddComment(issueKeyOrID, body string) (*Comment, error) { } if client.ctx != nil { - ctx, cancel := context.WithTimeout(*client.ctx, defaultTimeout) + ctx, cancel := context.WithTimeout(client.ctx, defaultTimeout) defer cancel() request = request.WithContext(ctx) } @@ -1189,7 +1190,7 @@ func (client *Client) UpdateComment(issueKeyOrID, commentID, body string) ( } if client.ctx != nil { - ctx, cancel := context.WithTimeout(*client.ctx, defaultTimeout) + ctx, cancel := context.WithTimeout(client.ctx, defaultTimeout) defer cancel() request = request.WithContext(ctx) } @@ -1255,7 +1256,7 @@ func (client *Client) UpdateLabels( } if client.ctx != nil { - ctx, cancel := context.WithTimeout(*client.ctx, defaultTimeout) + ctx, cancel := context.WithTimeout(client.ctx, defaultTimeout) defer cancel() request = request.WithContext(ctx) } @@ -1304,7 +1305,7 @@ func (client *Client) GetTransitions(issueKeyOrID string) ( } if client.ctx != nil { - ctx, cancel := context.WithTimeout(*client.ctx, defaultTimeout) + ctx, cancel := context.WithTimeout(client.ctx, defaultTimeout) defer cancel() request = request.WithContext(ctx) } @@ -1368,7 +1369,7 @@ func (client *Client) DoTransition( } if client.ctx != nil { - ctx, cancel := context.WithTimeout(*client.ctx, defaultTimeout) + ctx, cancel := context.WithTimeout(client.ctx, defaultTimeout) defer cancel() request = request.WithContext(ctx) } @@ -1414,7 +1415,7 @@ func (client *Client) GetServerInfo() (*ServerInfo, error) { } if client.ctx != nil { - ctx, cancel := context.WithTimeout(*client.ctx, defaultTimeout) + ctx, cancel := context.WithTimeout(client.ctx, defaultTimeout) defer cancel() request = request.WithContext(ctx) } |