Skip to content

Commit

Permalink
Reduce dependencies (#161)
Browse files Browse the repository at this point in the history
* Simpler homedir detection w/o library

* Typo in godoc comment

* Undo bad autoremove of gitconfig import

* Update dep with removal of homedir and new meta sha
  • Loading branch information
tydavis authored and zaquestion committed Jun 11, 2018
1 parent 2900ecb commit f446b9a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
8 changes: 1 addition & 7 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions internal/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

retry "github.com/avast/retry-go"
"github.com/pkg/errors"
"github.com/tcnksm/go-gitconfig"
gitconfig "github.com/tcnksm/go-gitconfig"
)

// IsHub is true when using "hub" as the git binary
Expand Down Expand Up @@ -93,7 +93,7 @@ func LastCommitMessage() (string, error) {
return strings.TrimSpace(string(msg)), nil
}

// Log produces a a formatted gitlog between 2 git shas
// Log produces a formatted gitlog between 2 git shas
func Log(sha1, sha2 string) (string, error) {
cmd := New("-c", "log.showSignature=false",
"log",
Expand Down
19 changes: 15 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package main
import (
"log"
"os"
"os/user"
"path"
"runtime"

homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/viper"
"github.com/zaquestion/lab/cmd"
"github.com/zaquestion/lab/internal/config"
Expand All @@ -19,10 +20,20 @@ func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
cmd.Version = version

home, err := homedir.Dir()
if err != nil {
log.Fatal(err)
var home string
switch runtime.GOOS {
case "windows":
// userprofile works for roaming AD profiles
home = os.Getenv("USERPROFILE")
default:
// Assume linux or osx
u, err := user.Current()
if err != nil {
log.Fatalf("cannot retrieve current user: %v \n", err)
}
home = u.HomeDir
}

confpath := path.Join(home, ".config")
if _, err := os.Stat(confpath); os.IsNotExist(err) {
os.Mkdir(confpath, 0700)
Expand Down

0 comments on commit f446b9a

Please sign in to comment.