Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[refactoring] Get ghq.completeUser strictly as a boolean value #172

Merged
merged 1 commit into from
May 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions gitutil/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import (
// ConfigSingle fetches single git-config variable.
// returns an empty string and no error if no variable is found with the given key.
func ConfigSingle(key string) (string, error) {
return Config("--get", key)
// --path option expands tilde(~)
return Config("--path", "--get", key)
}

// ConfigAll fetches git-config variable of multiple values.
func ConfigAll(key string) ([]string, error) {
value, err := Config("--get-all", key)
value, err := Config("--path", "--get-all", key)
if err != nil {
return nil, err
}
Expand All @@ -34,7 +35,7 @@ func ConfigAll(key string) ([]string, error) {

// Config invokes 'git config' and handles some errors properly.
func Config(args ...string) (string, error) {
gitArgs := append([]string{"config", "--path", "--null"}, args...)
gitArgs := append([]string{"config", "--null"}, args...)
cmd := exec.Command("git", gitArgs...)
cmd.Stderr = os.Stderr

Expand Down
2 changes: 1 addition & 1 deletion remote_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (repo *OtherRepository) VCS() (*VCSBackend, *url.URL) {
// (in gitconfig:)
// [ghq "https://ghe.example.com/"]
// vcs = github
vcs, err := gitutil.Config("--get-urlmatch", "ghq.vcs", repo.URL().String())
vcs, err := gitutil.Config("--path", "--get-urlmatch", "ghq.vcs", repo.URL().String())
if err != nil {
logger.Log("error", err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion url.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func convertGitURLHTTPToSSH(url *url.URL) (*url.URL, error) {
}

func fillUsernameToPath(path string) (string, error) {
completeUser, err := gitutil.ConfigSingle("ghq.completeUser")
completeUser, err := gitutil.Config("--bool", "--get", "ghq.completeUser")
if err != nil {
return path, err
}
Expand Down