Skip to content

Commit

Permalink
set user agent
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed Mar 20, 2017
1 parent cf12ed4 commit f960b32
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion cmd/upload-coverage.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"time"

"github.com/codeclimate/test-reporter/version"
"github.com/gobuffalo/envy"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -49,7 +50,14 @@ func (u Uploader) Upload() error {
c := http.Client{
Timeout: 30 * time.Second,
}
res, err := c.Post(u.EndpointURL, "application/json", in)
req, err := http.NewRequest("POST", u.EndpointURL, in)
if err != nil {
return err
}
req.Header.Set("User-Agent", fmt.Sprintf("TestReporter/%s (Code Climate, Inc.)", version.FormattedVersion()))
req.Header.Set("Content-Type", "application/json")

res, err := c.Do(req)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion formatters/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type ccEnvironment struct {
func newCCEnvironment() ccEnvironment {
cc := ccEnvironment{
RailsRoot: envy.Get("RAILS_ROOT", ""),
ReporterVersion: version.FormattedVersion(),
ReporterVersion: version.Version,
}

pwd, _ := os.Getwd()
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ func FormattedVersion() string {
if Version == "" {
return "unknown"
}
return fmt.Sprintf("%s (%s @ %s)\n", Version, BuildVersion, BuildTime)
return fmt.Sprintf("%s (%s @ %s)", Version, BuildVersion, BuildTime)
}

0 comments on commit f960b32

Please sign in to comment.