Permalink
Browse files

set user agent

  • Loading branch information...
markbates committed Mar 20, 2017
1 parent cf12ed4 commit f960b32a7e0ae6d189139468edc4ce4813e62978
Showing with 11 additions and 3 deletions.
  1. +9 −1 cmd/upload-coverage.go
  2. +1 −1 formatters/report.go
  3. +1 −1 version/version.go
@@ -9,6 +9,7 @@ import (
"os"
"time"

"github.com/codeclimate/test-reporter/version"
"github.com/gobuffalo/envy"
"github.com/spf13/cobra"
)
@@ -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
}
@@ -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()
@@ -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.