Skip to content

Commit 5d5f781

Browse files
committed
made git and ci private.
1 parent bb2dee3 commit 5d5f781

File tree

6 files changed

+42
-17
lines changed

6 files changed

+42
-17
lines changed

Diff for: .codeclimate.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
engines:
3+
golint:
4+
enabled: true
5+
checks:
6+
GoLint/Naming/MixedCaps:
7+
enabled: false
8+
govet:
9+
enabled: true
10+
gofmt:
11+
enabled: true
12+
fixme:
13+
enabled: true
14+
ratings:
15+
paths:
16+
- "**.go"
17+
exclude_paths:
18+
- "**/*_test.go"
19+
- "*_test.go"
20+
- "vendor/"

Diff for: env/ci.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ package env
22

33
import "bytes"
44

5-
type CI struct {
5+
type ci struct {
66
Name string
77
BuildID string
88
BuildURL string
99
}
1010

11-
func (c CI) String() string {
11+
func (c ci) String() string {
1212
out := &bytes.Buffer{}
1313
out.WriteString("CI_NAME=")
1414
out.WriteString(c.Name)
@@ -19,8 +19,8 @@ func (c CI) String() string {
1919
return out.String()
2020
}
2121

22-
func loadCIInfo() CI {
23-
return CI{
22+
func loadCIInfo() ci {
23+
return ci{
2424
Name: findVar(ciNameVars),
2525
BuildID: findVar(ciBuildIDVars),
2626
BuildURL: findVar(ciBuildURLVars),

Diff for: env/ci_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func Test_loadCIFromENV_Alt_Vars(t *testing.T) {
3535

3636
func Test_CI_String(t *testing.T) {
3737
r := require.New(t)
38-
c := CI{
38+
c := ci{
3939
Name: "codeclimate",
4040
BuildID: "a12345",
4141
BuildURL: "http://example.net",

Diff for: env/env.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import (
66
"github.com/gobuffalo/envy"
77
)
88

9+
// Environment represent the current testing environment
910
type Environment struct {
10-
Git Git
11-
CI CI
11+
Git git
12+
CI ci
1213
}
1314

1415
func (e Environment) String() string {
@@ -19,9 +20,14 @@ func (e Environment) String() string {
1920
return out.String()
2021
}
2122

23+
// New environment. If there are problems loading parts of
24+
// the environment an error will be returned. Validation errors
25+
// are not considered an "error" here, but should be checked
26+
// further down the chain, when validation of the environment
27+
// is required.
2228
func New() (Environment, error) {
2329
e := Environment{}
24-
git, err := FindGitInfo()
30+
git, err := findGitInfo()
2531
if err != nil {
2632
return e, err
2733
}

Diff for: env/git.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import (
66
"strings"
77
)
88

9-
type Git struct {
9+
type git struct {
1010
Branch string
1111
CommitSHA string
1212
CommittedAt string
1313
}
1414

15-
func (g Git) String() string {
15+
func (g git) String() string {
1616
out := &bytes.Buffer{}
1717
out.WriteString("GIT_BRANCH=")
1818
out.WriteString(g.Branch)
@@ -23,14 +23,14 @@ func (g Git) String() string {
2323
return out.String()
2424
}
2525

26-
func FindGitInfo() (Git, error) {
26+
func findGitInfo() (git, error) {
2727
_, err := exec.LookPath("git")
2828
if err != nil {
2929
// git isn't present, so load from ENV vars:
3030
return loadGitFromENV()
3131
}
3232

33-
g := Git{}
33+
g := git{}
3434

3535
cmd := exec.Command("git", "rev-parse", "--abbrev-ref", "HEAD")
3636
out, err := cmd.Output()
@@ -55,9 +55,8 @@ func FindGitInfo() (Git, error) {
5555
return g, nil
5656
}
5757

58-
func loadGitFromENV() (Git, error) {
59-
// TODO: find via other variables:
60-
return Git{
58+
func loadGitFromENV() (git, error) {
59+
return git{
6160
Branch: findVar(gitBranchVars),
6261
CommitSHA: findVar(gitCommitShaVars),
6362
CommittedAt: findVar(gitCommittedAtVars),

Diff for: env/git_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
func Test_FindGitInfo(t *testing.T) {
1111
r := require.New(t)
12-
g, err := FindGitInfo()
12+
g, err := findGitInfo()
1313
r.NoError(err)
1414
r.NotZero(g.Branch)
1515
r.NotZero(g.CommitSHA)
@@ -46,7 +46,7 @@ func Test_loadGitFromENV_Alt_Vars(t *testing.T) {
4646

4747
func Test_Git_String(t *testing.T) {
4848
r := require.New(t)
49-
g := Git{
49+
g := git{
5050
Branch: "master",
5151
CommitSHA: "a12345",
5252
CommittedAt: "12:45",

0 commit comments

Comments
 (0)