Skip to content

Commit

Permalink
fixes issues found with summing in #31
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed Mar 22, 2017
1 parent a29d2ba commit d3cef85
Show file tree
Hide file tree
Showing 12 changed files with 22,836 additions and 92 deletions.
19 changes: 13 additions & 6 deletions cmd/format-coverage.go
@@ -1,13 +1,13 @@
package cmd

import (
"errors"
"io"
"os"
"path/filepath"

"github.com/codeclimate/test-reporter/formatters"
"github.com/codeclimate/test-reporter/formatters/ruby"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -38,26 +38,33 @@ func (f CoverageFormatter) Save() error {
}
err = in.Parse()
if err != nil {
return err
return errors.WithStack(err)
}

var out io.Writer
if formatOptions.Print || formatOptions.Output == "-" {
out = os.Stdout
} else {
os.MkdirAll(filepath.Dir(formatOptions.Output), 0755)
err = os.MkdirAll(filepath.Dir(formatOptions.Output), 0755)
if err != nil {
return errors.WithStack(err)
}
out, err = os.Create(formatOptions.Output)
if err != nil {
return err
return errors.WithStack(err)
}
}

rep, err := in.Format()
if err != nil {
return err
return errors.WithStack(err)
}

return rep.Save(out)
err = rep.Save(out)
if err != nil {
return errors.WithStack(err)
}
return nil
}

func init() {
Expand Down
12 changes: 7 additions & 5 deletions env/git.go
Expand Up @@ -6,6 +6,8 @@ import (
"os/exec"
"strconv"
"strings"

"github.com/pkg/errors"
)

type Git struct {
Expand Down Expand Up @@ -37,25 +39,25 @@ func findGitInfo() (Git, error) {
cmd := exec.Command("git", "rev-parse", "--abbrev-ref", "HEAD")
out, err := cmd.Output()
if err != nil {
return g, err
return g, errors.WithStack(err)
}
g.Branch = strings.TrimSpace(string(out))

cmd = exec.Command("git", "log", "-1", "--pretty=format:%H")
out, err = cmd.Output()
if err != nil {
return g, err
return g, errors.WithStack(err)
}
g.CommitSHA = strings.TrimSpace(string(out))

cmd = exec.Command("git", "log", "-1", "--pretty=format:%ct")
out, err = cmd.Output()
if err != nil {
return g, err
return g, errors.WithStack(err)
}
g.CommittedAt, err = strconv.Atoi(strings.TrimSpace(string(out)))
if err != nil {
return g, err
return g, errors.WithStack(err)
}
return g, nil
}
Expand All @@ -68,7 +70,7 @@ func GitSHA(path string) (string, error) {
cmd := exec.Command("git", args...)
out, err := cmd.Output()
if err != nil {
return "", err
return "", errors.WithStack(err)
}
return strings.TrimSpace(string(out)), nil
}
Expand Down

0 comments on commit d3cef85

Please sign in to comment.