Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make TravisCI build green again #62

Merged
merged 4 commits into from
Sep 10, 2018
Merged
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
8 changes: 4 additions & 4 deletions authentication.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package gerrit

import (
"crypto/md5" // nolint: gas
"crypto/md5" // nolint: gosec
"crypto/rand"
"encoding/base64"
"errors"
Expand Down Expand Up @@ -117,15 +117,15 @@ func (s *AuthenticationService) digestAuthHeader(response *http.Response) (strin
uriHeader := authenticate["uri"]

// A1
h := md5.New() // nolint: gas
h := md5.New() // nolint: gosec
A1 := fmt.Sprintf("%s:%s:%s", s.name, realmHeader, s.secret)
if _, err := io.WriteString(h, A1); err != nil {
return "", err
}
HA1 := fmt.Sprintf("%x", h.Sum(nil))

// A2
h = md5.New() // nolint: gas
h = md5.New() // nolint: gosec
A2 := fmt.Sprintf("%s:%s", response.Request.Method, uriHeader)
if _, err := io.WriteString(h, A2); err != nil {
return "", err
Expand All @@ -141,7 +141,7 @@ func (s *AuthenticationService) digestAuthHeader(response *http.Response) (strin
bytes += n
}
cnonce := base64.StdEncoding.EncodeToString(k)
digest := md5.New() // nolint: gas
digest := md5.New() // nolint: gosec
if _, err := digest.Write([]byte(strings.Join([]string{HA1, nonceHeader, "00000001", cnonce, qopHeader, HA2}, ":"))); err != nil {
return "", err
}
Expand Down
26 changes: 16 additions & 10 deletions changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,11 @@ type RobotCommentInput struct {
CommentInput

// The ID of the robot that generated this comment.
RobotId string `json:"robot_id"`
RobotID string `json:"robot_id"`
// An ID of the run of the robot.
RobotRunId string `json:"robot_run_id"`
RobotRunID string `json:"robot_run_id"`
// URL to more information.
Url string `json:"url,omitempty"`
URL string `json:"url,omitempty"`
// Robot specific properties as map that maps arbitrary keys to values.
Properties *map[string]*string `json:"properties,omitempty"`
// Suggested fixes for this robot comment as a list of FixSuggestionInfo
Expand All @@ -277,11 +277,11 @@ type RobotCommentInfo struct {
CommentInfo

// The ID of the robot that generated this comment.
RobotId string `json:"robot_id"`
RobotID string `json:"robot_id"`
// An ID of the run of the robot.
RobotRunId string `json:"robot_run_id"`
RobotRunID string `json:"robot_run_id"`
// URL to more information.
Url string `json:"url,omitempty"`
URL string `json:"url,omitempty"`
// Robot specific properties as map that maps arbitrary keys to values.
Properties map[string]string `json:"properties,omitempty"`
// Suggested fixes for this robot comment as a list of FixSuggestionInfo
Expand All @@ -294,7 +294,7 @@ type RobotCommentInfo struct {
type FixSuggestionInfo struct {
// The UUID of the suggested fix. It will be generated automatically and
// hence will be ignored if it’s set for input objects.
FixId string `json:"fix_id"`
FixID string `json:"fix_id"`
// A description of the suggested fix.
Description string `json:"description"`
// A list of FixReplacementInfo entities indicating how the content of one or
Expand Down Expand Up @@ -780,11 +780,17 @@ func (s *ChangesService) change(tail string, changeID string, input interface{})

v := new(ChangeInfo)
resp, err := s.client.Do(req, v)
if err != nil {
return nil, resp, err
}
if resp.StatusCode == http.StatusConflict {
body, _ := ioutil.ReadAll(resp.Body)
err = errors.New(string(body[:]))
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return v, resp, err
}
return v, resp, errors.New(string(body[:]))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A trivial thing I just spotted: body[:] could be simplified to body. It's already a slice, no need to slice it again.

}
return v, resp, err
return v, resp, nil
}

// SubmitChange submits a change.
Expand Down