From f5165fd9d4391461ae4d17e4a28a279e7159572f Mon Sep 17 00:00:00 2001 From: Theotime Leveque Date: Mon, 19 Jun 2017 17:11:23 -0400 Subject: [PATCH] Dotfiles: Support Gitlab & Bitbucket. --- backend/config/config.go | 6 +++++- backend/env/env.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/config/config.go b/backend/config/config.go index 449d31e..60fee36 100644 --- a/backend/config/config.go +++ b/backend/config/config.go @@ -21,6 +21,7 @@ import ( "os/exec" "os/user" "path/filepath" + "regexp" "strings" yaml "gopkg.in/yaml.v2" @@ -137,7 +138,10 @@ func SetupConfigFile(ConfigFileName string) { dotfilesRepositoryPrefix := "\ndotfiles:\n" dotfilesRepository := fmt.Sprintf(" repository: %s\n", env.GetDotfilesRepository()) - repositoryProvider := " provider: github" + + re := regexp.MustCompile("([a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9])\\.[a-zA-Z]{2,}") + provider := re.FindStringSubmatch(dotfilesRepository)[1] + repositoryProvider := fmt.Sprintf(" provider: %s", provider) configContent = append(configContent, fmt.Sprintf("%s%s%s", dotfilesRepositoryPrefix, dotfilesRepository, repositoryProvider)...) } diff --git a/backend/env/env.go b/backend/env/env.go index 66c7295..398fd83 100644 --- a/backend/env/env.go +++ b/backend/env/env.go @@ -214,7 +214,7 @@ func GenerateRepositoriesPath() string { // GetDotfilesRepository creates conf line containing the user's input. func GetDotfilesRepository() string { - fmt.Print("\nEnter the full path to your dotfiles Github repository\n(leave blank to skip): ") + fmt.Print("\nEnter the full path to your dotfiles repository\n(leave blank to skip): ") reader := bufio.NewReader(os.Stdin) if input, _ := reader.ReadString('\n'); input != "\n" && input != "" { return string(bytes.TrimSuffix([]byte(input), []byte("\n")))