Skip to content

Commit

Permalink
Add pre-commit config and include goimports (gruntwork-io#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
infraredgirl authored Sep 23, 2021
1 parent 7b8ec9c commit 19e1e86
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 8 deletions.
19 changes: 19 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ install_gruntwork_utils: &install_gruntwork_utils
--go-version ${GOLANG_VERSION}
version: 2
jobs:
pre-commit:
<<: *defaults
steps:
- checkout
- run:
command: |
pip install pre-commit
go get golang.org/x/tools/cmd/goimports
export GOPATH=~/go/bin && export PATH=$PATH:$GOPATH
pre-commit install
pre-commit run --all-files
test:
<<: *defaults
steps:
Expand Down Expand Up @@ -50,7 +61,15 @@ workflows:
version: 2
build-and-test:
jobs:
- pre-commit:
filters:
tags:
only: /^v.*/
context:
- Gruntwork Admin
- test:
requires:
- pre-commit
filters:
tags:
only: /^v.*/
Expand Down
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repos:
- repo: https://github.com/gruntwork-io/pre-commit
rev: v0.1.13
hooks:
- id: goimports
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type GitXargsConfig struct {
DryRun bool
SkipPullRequests bool
SkipArchivedRepos bool
MaxConcurrentRepos int
MaxConcurrentRepos int
BranchName string
CommitMessage string
PullRequestTitle string
Expand Down
6 changes: 3 additions & 3 deletions mocks/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ var MockGithubRepositories = []*github.Repository{
},
&github.Repository{
Owner: &github.User{
Login: &ownerName,
Login: &ownerName,
},
Name: &repoName4,
HTMLURL: &repoURL4,
Name: &repoName4,
HTMLURL: &repoURL4,
Archived: &archivedFlag,
},
}
Expand Down
2 changes: 1 addition & 1 deletion repository/fetch-repos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ func TestSkipArchivedRepos(t *testing.T) {

githubRepos, reposByOrgLookupErr := getReposByOrg(config)

assert.Equal(t, len(githubRepos), len(mocks.MockGithubRepositories) -1)
assert.Equal(t, len(githubRepos), len(mocks.MockGithubRepositories)-1)
assert.NoError(t, reposByOrgLookupErr)
}
2 changes: 1 addition & 1 deletion repository/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func ProcessRepos(gitxargsConfig *config.GitXargsConfig, repos []*github.Reposit
// run report that is displayed in table format to the operator following each run
func processRepo(config *config.GitXargsConfig, repo *github.Repository) error {
logger := logging.GetLogger("git-xargs")

// Create a new temporary directory in the default temp directory of the system, but append
// git-xargs-<repo-name> to it so that it's easier to find when you're looking for it
repositoryDir, localRepository, cloneErr := cloneLocalRepository(config, repo)
Expand Down
4 changes: 2 additions & 2 deletions repository/repo-operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func cloneLocalRepository(config *config.GitXargsConfig, repo *github.Repository
})

logger.WithFields(logrus.Fields{
"Repo": repo.GetName(),
"Repo": repo.GetName(),
}).Debug(gitProgressBuffer)

if err != nil {
Expand Down Expand Up @@ -196,7 +196,7 @@ func checkoutLocalBranch(config *config.GitXargsConfig, ref *plumbing.Reference,
}

logger.WithFields(logrus.Fields{
"Repo": remoteRepository.GetName(),
"Repo": remoteRepository.GetName(),
}).Debug(gitProgressBuffer)

pullErr := worktree.Pull(po)
Expand Down

0 comments on commit 19e1e86

Please sign in to comment.