diff --git a/git/git/git.go b/git/git/git.go index 388d9e1..89f1256 100644 --- a/git/git/git.go +++ b/git/git/git.go @@ -55,6 +55,7 @@ func (git git) rootDir(cwd string) (string, error) { func (git git) repoName(root string) string { for _, strat := range []func() (string, bool){ + func() (string, bool) { return git.checkExplicitRepoName(root) }, func() (string, bool) { return git.parseOriginURL(root) }, } { if n, ok := strat(); ok { @@ -68,6 +69,18 @@ var urlRegexes = []*regexp.Regexp{ regexp.MustCompile("^git@github.com:[^/]+/(.+).git$"), } +func (git git) checkExplicitRepoName(root string) (string, bool) { + n, stderr, err := git.Command("-C", root, "config", "tmux-vcs-sync.name").RunOutput() + if err != nil { + if len(stderr) == 0 { + return "", false + } + fmt.Fprint(os.Stderr, stderr) + return "", false + } + return n, true +} + func (git git) parseOriginURL(root string) (string, bool) { url, stderr, err := git.Command("-C", root, "remote", "get-url", "origin").RunOutput() if err != nil {