Skip to content

Commit

Permalink
Dotfiles: Support Gitlab & Bitbucket.
Browse files Browse the repository at this point in the history
  • Loading branch information
Theotime Leveque committed Jun 19, 2017
1 parent 838b7e0 commit f5165fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion backend/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os/exec"
"os/user"
"path/filepath"
"regexp"
"strings"

yaml "gopkg.in/yaml.v2"
Expand Down Expand Up @@ -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)...)
}

Expand Down
2 changes: 1 addition & 1 deletion backend/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
Expand Down

0 comments on commit f5165fd

Please sign in to comment.