Skip to content
This repository has been archived by the owner on May 27, 2022. It is now read-only.

Commit

Permalink
chore: lint and fmt all files
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Dec 18, 2017
1 parent f97e4e5 commit 75a0b09
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 17 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
@@ -1,7 +1,9 @@
language: go
go: 1.9
install: make setup
script: make test
install:
- make setup
- npm install -g prettier
script: make ci
after_success:
- bash <(curl -s https://codecov.io/bash)
- gem install fpm
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Expand Up @@ -24,27 +24,27 @@ $ cd antibody

Install the build and lint dependencies:

``` sh
```sh
$ make setup
```

A good way of making sure everything is all right is running the test suite:

``` sh
```sh
$ make test
```

## Test your change

You can create a branch for your changes and try to build from the source as you go:

``` sh
```sh
$ make build
```

When you are satisfied with the changes, we suggest you run:

``` sh
```sh
$ make ci
```

Expand Down
1 change: 0 additions & 1 deletion LICENSE.md
Expand Up @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

7 changes: 7 additions & 0 deletions Makefile
Expand Up @@ -26,6 +26,7 @@ cover: test
# Run all the linters
lint:
gometalinter --vendor ./...
find . -name '*.md' -not -wholename './vendor/*' | xargs prettier -l
.PHONY: lint

# Run all the tests and code checks
Expand All @@ -37,6 +38,12 @@ build:
go build
.PHONY: build

# gofmt and goimports all go files
fmt:
find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done
find . -name '*.md' -not -wholename './vendor/*' | xargs prettier --write
.PHONY: fmt

# Generates the static documentation
static-gen:
@rm -rf dist/getantibody.github.io/theme
Expand Down
5 changes: 4 additions & 1 deletion bundle/zsh.go
Expand Up @@ -18,7 +18,10 @@ func (bundle zshBundle) Get() (result string, err error) {
return result, err
}
for _, glob := range zshGlobs {
files, _ := filepath.Glob(filepath.Join(bundle.Project.Folder(), glob))
files, err := filepath.Glob(filepath.Join(bundle.Project.Folder(), glob))
if err != nil {
return result, err
}
if files == nil {
continue
}
Expand Down
3 changes: 3 additions & 0 deletions project/git.go
Expand Up @@ -73,6 +73,7 @@ func NewGit(cwd, line string) Project {

func (g gitProject) Download() error {
if _, err := os.Stat(g.folder); os.IsNotExist(err) {
// #nosec
var cmd = exec.Command("git", "clone",
"--recursive",
"--depth", "1",
Expand All @@ -89,6 +90,7 @@ func (g gitProject) Download() error {
}

func (g gitProject) Update() error {
// #nosec
if bts, err := exec.Command(
"git", "-C", g.folder, "pull",
"--recurse-submodules",
Expand All @@ -102,6 +104,7 @@ func (g gitProject) Update() error {
}

func branch(folder string) (string, error) {
// #nosec
branch, err := exec.Command(
"git", "-C", folder, "rev-parse", "--abbrev-ref", "HEAD",
).Output()
Expand Down
18 changes: 9 additions & 9 deletions project/git_test.go
Expand Up @@ -4,7 +4,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"strings"
"testing"

"github.com/getantibody/antibody/project"
Expand Down Expand Up @@ -94,17 +94,17 @@ func TestDownloadFolderNaming(t *testing.T) {
}

func TestSubFolder(t *testing.T) {
assert := assert.New(t)
home := home()
repo := project.NewGit(home, "robbyrussell/oh-my-zsh folder:plugins/aws")
assert.True(strings.HasSuffix(repo.Folder(), "plugins/aws"))
assert := assert.New(t)
home := home()
repo := project.NewGit(home, "robbyrussell/oh-my-zsh folder:plugins/aws")
assert.True(strings.HasSuffix(repo.Folder(), "plugins/aws"))
}

func TestMultipleSubFolders(t *testing.T) {
assert := assert.New(t)
home := home()
assert.NoError(project.NewGit(home, "robbyrussell/oh-my-zsh folder:plugins/aws").Download())
assert.NoError(project.NewGit(home, "robbyrussell/oh-my-zsh folder:plugins/battery").Download())
assert := assert.New(t)
home := home()
assert.NoError(project.NewGit(home, "robbyrussell/oh-my-zsh folder:plugins/aws").Download())
assert.NoError(project.NewGit(home, "robbyrussell/oh-my-zsh folder:plugins/battery").Download())
}

func home() string {
Expand Down

0 comments on commit 75a0b09

Please sign in to comment.