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

Commit

Permalink
fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Aug 17, 2016
1 parent 071ae43 commit b89e362
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 59 deletions.
11 changes: 11 additions & 0 deletions antibody.go
@@ -1,8 +1,10 @@
package antibody

import (
"os"
"strings"

"github.com/caarlos0/gohome"
"github.com/getantibody/antibody/bundle"
"github.com/getantibody/antibody/event"
)
Expand Down Expand Up @@ -54,3 +56,12 @@ func (a *Antibody) Bundle() (string, error) {
}
}
}

// Home finds the right home folder to use
func Home() string {
home := os.Getenv("ANTIBODY_HOME")
if home == "" {
home = gohome.Cache("antibody")
}
return home
}
2 changes: 1 addition & 1 deletion antibody_test.go
Expand Up @@ -44,5 +44,5 @@ func home() string {
if err != nil {
panic(err.Error())
}
return home + "/"
return home
}
2 changes: 1 addition & 1 deletion bundle/bundle_test.go
Expand Up @@ -98,5 +98,5 @@ func home() string {
if err != nil {
panic(err.Error())
}
return home + "/"
return home
}
3 changes: 1 addition & 2 deletions cmd/antibody/command/bundle.go
Expand Up @@ -6,7 +6,6 @@ import (
"os"
"strings"

"github.com/caarlos0/gohome"
"github.com/getantibody/antibody"
"github.com/urfave/cli"
"golang.org/x/crypto/ssh/terminal"
Expand All @@ -30,7 +29,7 @@ func doBundle(ctx *cli.Context) error {
} else {
input = ctx.Args()
}
sh, err := antibody.New(gohome.Cache("antibody")+"/", input).Bundle()
sh, err := antibody.New(antibody.Home(), input).Bundle()
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/antibody/command/home.go
Expand Up @@ -3,7 +3,7 @@ package command
import (
"fmt"

"github.com/caarlos0/gohome"
"github.com/getantibody/antibody"
"github.com/urfave/cli"
)

Expand All @@ -13,7 +13,7 @@ var Home = cli.Command{
Aliases: []string{"prefix", "p"},
Usage: "shows the current antibody home folder",
Action: func(ctx *cli.Context) error {
fmt.Println(gohome.Cache("antibody") + "/")
fmt.Println(antibody.Home())
return nil
},
}
7 changes: 7 additions & 0 deletions cmd/antibody/main.go
Expand Up @@ -4,12 +4,19 @@ import (
"os"

"github.com/getantibody/antibody/cmd/antibody/command"
"github.com/pkg/profile"
"github.com/urfave/cli"
)

var version = "master"

func main() {
defer profile.Start(
profile.MemProfile,
profile.CPUProfile,
profile.NoShutdownHook,
profile.ProfilePath("."),
).Stop()
app := cli.NewApp()
app.Name = "antibody"
app.Usage = "A faster and simpler antigen written in Golang"
Expand Down
19 changes: 14 additions & 5 deletions project/git.go
@@ -1,8 +1,10 @@
package project

import (
"log"
"os"
"os/exec"
"path/filepath"
"strings"
)

Expand Down Expand Up @@ -30,10 +32,13 @@ func NewGit(cwd, repo, version string) Project {
default:
url = "https://github.com/" + repo
}
folder := cwd + strings.Replace(
folder := filepath.Join(
cwd,
strings.Replace(
url, ":", "-COLON-", -1,
), "/", "-SLASH-", -1,
strings.Replace(
url, ":", "-COLON-", -1,
), "/", "-SLASH-", -1,
),
)
return gitProject{
Version: version,
Expand All @@ -44,9 +49,13 @@ func NewGit(cwd, repo, version string) Project {

func (g gitProject) Download() error {
if _, err := os.Stat(g.folder); os.IsNotExist(err) {
return exec.Command(
cmd := exec.Command(
"git", "clone", "--depth", "1", "-b", g.Version, g.URL, g.folder,
).Run()
)
if bts, err := cmd.CombinedOutput(); err != nil {
log.Println("git clone failed for", g.URL, err, string(bts))
return err
}
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion project/git_test.go
Expand Up @@ -88,5 +88,5 @@ func home() string {
if err != nil {
panic(err.Error())
}
return home + "/"
return home
}
9 changes: 4 additions & 5 deletions scripts/profiling/bundles.txt
Expand Up @@ -54,7 +54,6 @@ AlexisBRENON/oh-my-zsh-reminder
tonyseek/oh-my-zsh-virtualenv-prompt
hchbaw/opp.zsh
marshallmick007/osx-dev-zsh-plugin
allanhortle/otter
deyvisonrocha/pantheon-terminal-notify-zsh-plugin
benclark/parallels-zsh-plugin
sharat87/pip-app
Expand Down Expand Up @@ -90,17 +89,17 @@ tymm/zsh-directory-history
oknowton/zsh-dwim
Tarrasch/zsh-functional
s7anley/zsh-geeknote
caarlos0/jvm kind:path
caarlos0/zsh-git-sync
clauswitt/zsh-grunt-plugin
horosgrisa/zsh-gvm
yerinle/zsh-gvm
joepvd/zsh-hints
# empty line:

zsh-users/zsh-history-substring-search
horosgrisa/zsh-konsole-theme-changer
knu/zsh-manydots-magic
psprint/zsh-navigation-tools
marzocchi/zsh-notify
caarlos0/zsh-open-pr
mkwmms/zsh-osx
caarlos0/zsh-pg
RudthMael/zsh-plugin-ibtool
Expand All @@ -115,6 +114,6 @@ sharat87/zsh-vim-mode
jocelynmallon/zshmarks
# comments should be ignored
# URLs:
git@github.com:caarlos0/jvm.git
git@github.com:caarlos0/jvm.git branch:gh-pages
https://github.com/caarlos0/zsh-open-pr
caarlos0/zsh-git-fetch-merge
37 changes: 0 additions & 37 deletions scripts/profiling/patch.patch

This file was deleted.

10 changes: 5 additions & 5 deletions scripts/profiling/work.sh
@@ -1,13 +1,13 @@
#!/bin/bash

open_pdfs() {
for i in cpu mem block; do
go tool pprof --pdf antibody "$i.pprof" > "$1_$i.pdf" && open "$1_$i.pdf"
find . -name '*.pprof' | while read -r i; do
go tool pprof --pdf antibody "$i.pprof" > "/tmp/$1_$i.pdf" && open "/tmp/$1_$i.pdf"
done
}

git apply "./scripts/profiling/patch.patch"
go build -o antibody ./cmd/antibody
# git apply "./scripts/profiling/patch.patch"
go build -ldflags="-s -w -X main.version=profiling" -o antibody ./cmd/antibody
export ANTIBODY_HOME="$(mktemp -d)"
# bundle all plugins from awesome-zsh-plugins
/usr/bin/time ./antibody bundle < ./scripts/profiling/bundles.txt > /dev/null
Expand All @@ -24,4 +24,4 @@ open_pdfs home
open_pdfs init

rm -f ./antibody
git checkout ./cmd/antibody/main.go
# git checkout ./cmd/antibody/main.go

0 comments on commit b89e362

Please sign in to comment.