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

Commit

Permalink
Merge pull request #66 from caarlos0/improvements
Browse files Browse the repository at this point in the history
more readable code
  • Loading branch information
caarlos0 committed Sep 6, 2015
2 parents 32cf378 + f1fb55f commit a0f585a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# antibody [![Circle CI](https://circleci.com/gh/caarlos0/antibody.svg?style=svg)](https://circleci.com/gh/caarlos0/antibody) [![Stories in Ready](https://badge.waffle.io/caarlos0/antibody.png?label=ready&title=Ready)](https://waffle.io/caarlos0/antibody)
# antibody [![Build Status](https://img.shields.io/circleci/project/caarlos0/antibody/master.svg)](https://circleci.com/gh/caarlos0/antibody) [![Coverage Status](https://coveralls.io/repos/caarlos0/antibody/badge.svg?branch=master&service=github)](https://coveralls.io/github/caarlos0/antibody?branch=master) [![Stories in Ready](https://badge.waffle.io/caarlos0/antibody.png?label=ready&title=Ready)](https://waffle.io/caarlos0/antibody)

A faster and simpler version of antigen written in Go.

Expand Down
2 changes: 1 addition & 1 deletion antibody.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (a Antibody) forEach(action bundleAction) {
func Home() string {
home := os.Getenv("ANTIBODY_HOME")
if home == "" {
return gohome.Cache("antibody")
home = gohome.Cache("antibody")
}
return home
}
12 changes: 5 additions & 7 deletions bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@ import (
"github.com/caarlos0/antibody/git"
)

var globs = []string{"*.plugin.zsh", "*.zsh", "*.sh"}

// Bundle is a git-based bundle/plugin
type Bundle struct {
git.Repo
}

// New creates a new bundle instance
func New(fullName, folder string) Bundle {
return Bundle{
git.NewGithubRepo(fullName, folder),
}
return Bundle{git.NewGithubRepo(fullName, folder)}
}

// Sourceables returns the list of files that could be sourced
func (b Bundle) Sourceables() []string {
globs := []string{"*.plugin.zsh", "*.zsh", "*.sh"}
for _, glob := range globs {
files, _ := filepath.Glob(filepath.Join(b.Folder(), glob))
if files != nil {
Expand All @@ -48,10 +47,9 @@ func List(folder string) []Bundle {
func Parse(s, folder string) []Bundle {
var bundles []Bundle
for _, b := range strings.Split(s, "\n") {
if strings.TrimSpace(b) == "" {
continue
if strings.TrimSpace(b) != "" {
bundles = append(bundles, New(b, folder))
}
bundles = append(bundles, New(b, folder))
}
return bundles
}
9 changes: 9 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@ deployment:
tag: /v[0-9]+(\.[0-9]+)*/
commands:
- ./scripts/release.sh
test:
pre:
- go get github.com/pierrre/gotestcover
- go get github.com/mattn/goveralls
- go get golang.org/x/tools/cmd/cover
override:
- gotestcover -race -coverprofile=coverage.out ./...
post:
- goveralls -coverprofile=coverage.out -service=circle-ci -repotoken=$COVERALLS_TOKEN
6 changes: 3 additions & 3 deletions cmd/antibody/actions/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ func Bundle(ctx *cli.Context) {
bundle.Parse(string(entries), antibody.Home()),
).Download()
} else {
antibody.New([]bundle.Bundle{
bundle.New(ctx.Args().First(), antibody.Home()),
}).Download()
antibody.New(
[]bundle.Bundle{bundle.New(ctx.Args().First(), antibody.Home())},
).Download()
}
}

Expand Down
8 changes: 4 additions & 4 deletions git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ func (r Repo) Name() string {
// Download clones a repository
func (r Repo) Download() error {
if _, err := os.Stat(r.folder); os.IsNotExist(err) {
clone := exec.Command("git", "clone", "--depth", "1", r.url, r.folder)
return clone.Run()
return exec.Command(
"git", "clone", "--depth", "1", r.url, r.folder,
).Run()
}
return nil
}

// Update updates a repository
func (r Repo) Update() error {
pull := exec.Command("git", "-C", r.folder, "pull", "origin", "master")
return pull.Run()
return exec.Command("git", "-C", r.folder, "pull", "origin", "master").Run()
}

0 comments on commit a0f585a

Please sign in to comment.