Use Different Remote Repos (#58)

This commit is contained in:
6543
2019-10-26 21:29:37 +00:00
committed by lafriks
parent cd1ddb86b5
commit 0515114fa3
3 changed files with 35 additions and 3 deletions

View File

@@ -195,9 +195,31 @@ func curGitRepoPath() (*Login, string, error) {
if err := gitConfig.Unmarshal(bs); err != nil {
return nil, "", err
}
remoteConfig, ok := gitConfig.Remotes["origin"]
// if no remote
if len(gitConfig.Remotes) == 0 {
return nil, "", errors.New("No remote repository set on this git repository")
}
// if only one remote exists
if len(gitConfig.Remotes) >= 1 && len(remoteValue) == 0 {
for remote := range gitConfig.Remotes {
remoteValue = remote
}
if len(gitConfig.Remotes) > 1 {
// if master branch is present, use it as the default remote
masterBranch, ok := gitConfig.Branches["master"]
if ok {
if len(masterBranch.Remote) > 0 {
remoteValue = masterBranch.Remote
}
}
}
}
remoteConfig, ok := gitConfig.Remotes[remoteValue]
if !ok || remoteConfig == nil {
return nil, "", errors.New("No remote origin found on this git repository")
return nil, "", errors.New("No remote " + remoteValue + " found on this git repository")
}
for _, l := range config.Logins {