Skip to content

Commit

Permalink
Switch from user.Current() to mitchellh/go-homedir
Browse files Browse the repository at this point in the history
Sometimes when hub is cross-compiled, `user.Current()` won't work on
certain systems. Use an alternative way of obtaining the user's home
directory.
  • Loading branch information
mislav committed Jan 22, 2016
1 parent 19017f9 commit 9048d4f
Show file tree
Hide file tree
Showing 5 changed files with 282 additions and 12 deletions.
15 changes: 3 additions & 12 deletions github/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,20 @@ import (
"fmt"
"io/ioutil"
"os"
"os/user"
"path/filepath"
"strconv"

"github.com/github/hub/ui"
"github.com/github/hub/utils"
"github.com/howeyc/gopass"
"github.com/mitchellh/go-homedir"
)

var defaultConfigsFile string

func init() {
homeDir := os.Getenv("HOME")

if homeDir == "" {
if u, err := user.Current(); err == nil {
homeDir = u.HomeDir
}
}

if homeDir == "" {
utils.Check(fmt.Errorf("Can't get current user's home dir"))
}
homeDir, err := homedir.Dir()
utils.Check(err)

defaultConfigsFile = filepath.Join(homeDir, ".config", "hub")
}
Expand Down
21 changes: 21 additions & 0 deletions vendor/github.com/mitchellh/go-homedir/LICENSE

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

14 changes: 14 additions & 0 deletions vendor/github.com/mitchellh/go-homedir/README.md

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

132 changes: 132 additions & 0 deletions vendor/github.com/mitchellh/go-homedir/homedir.go

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

112 changes: 112 additions & 0 deletions vendor/github.com/mitchellh/go-homedir/homedir_test.go

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

0 comments on commit 9048d4f

Please sign in to comment.