Skip to content

Commit 19e1e86

Browse files
authored
Add pre-commit config and include goimports (#52)
1 parent 7b8ec9c commit 19e1e86

File tree

7 files changed

+32
-8
lines changed

7 files changed

+32
-8
lines changed

.circleci/config.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ install_gruntwork_utils: &install_gruntwork_utils
2323
--go-version ${GOLANG_VERSION}
2424
version: 2
2525
jobs:
26+
pre-commit:
27+
<<: *defaults
28+
steps:
29+
- checkout
30+
- run:
31+
command: |
32+
pip install pre-commit
33+
go get golang.org/x/tools/cmd/goimports
34+
export GOPATH=~/go/bin && export PATH=$PATH:$GOPATH
35+
pre-commit install
36+
pre-commit run --all-files
2637
test:
2738
<<: *defaults
2839
steps:
@@ -50,7 +61,15 @@ workflows:
5061
version: 2
5162
build-and-test:
5263
jobs:
64+
- pre-commit:
65+
filters:
66+
tags:
67+
only: /^v.*/
68+
context:
69+
- Gruntwork Admin
5370
- test:
71+
requires:
72+
- pre-commit
5473
filters:
5574
tags:
5675
only: /^v.*/

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
repos:
2+
- repo: https://github.com/gruntwork-io/pre-commit
3+
rev: v0.1.13
4+
hooks:
5+
- id: goimports

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type GitXargsConfig struct {
1515
DryRun bool
1616
SkipPullRequests bool
1717
SkipArchivedRepos bool
18-
MaxConcurrentRepos int
18+
MaxConcurrentRepos int
1919
BranchName string
2020
CommitMessage string
2121
PullRequestTitle string

mocks/mocks.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ var MockGithubRepositories = []*github.Repository{
4747
},
4848
&github.Repository{
4949
Owner: &github.User{
50-
Login: &ownerName,
50+
Login: &ownerName,
5151
},
52-
Name: &repoName4,
53-
HTMLURL: &repoURL4,
52+
Name: &repoName4,
53+
HTMLURL: &repoURL4,
5454
Archived: &archivedFlag,
5555
},
5656
}

repository/fetch-repos_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ func TestSkipArchivedRepos(t *testing.T) {
6363

6464
githubRepos, reposByOrgLookupErr := getReposByOrg(config)
6565

66-
assert.Equal(t, len(githubRepos), len(mocks.MockGithubRepositories) -1)
66+
assert.Equal(t, len(githubRepos), len(mocks.MockGithubRepositories)-1)
6767
assert.NoError(t, reposByOrgLookupErr)
6868
}

repository/process.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func ProcessRepos(gitxargsConfig *config.GitXargsConfig, repos []*github.Reposit
4848
// run report that is displayed in table format to the operator following each run
4949
func processRepo(config *config.GitXargsConfig, repo *github.Repository) error {
5050
logger := logging.GetLogger("git-xargs")
51-
51+
5252
// Create a new temporary directory in the default temp directory of the system, but append
5353
// git-xargs-<repo-name> to it so that it's easier to find when you're looking for it
5454
repositoryDir, localRepository, cloneErr := cloneLocalRepository(config, repo)

repository/repo-operations.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func cloneLocalRepository(config *config.GitXargsConfig, repo *github.Repository
5353
})
5454

5555
logger.WithFields(logrus.Fields{
56-
"Repo": repo.GetName(),
56+
"Repo": repo.GetName(),
5757
}).Debug(gitProgressBuffer)
5858

5959
if err != nil {
@@ -196,7 +196,7 @@ func checkoutLocalBranch(config *config.GitXargsConfig, ref *plumbing.Reference,
196196
}
197197

198198
logger.WithFields(logrus.Fields{
199-
"Repo": remoteRepository.GetName(),
199+
"Repo": remoteRepository.GetName(),
200200
}).Debug(gitProgressBuffer)
201201

202202
pullErr := worktree.Pull(po)

0 commit comments

Comments
 (0)