// parseArgsRemoteString returns a remote name and a string if parsed.
// If there is an error, it returns two empty strings.
// If no remote is given, it returns the project name of the default remote
// (ie 'origin').
// If no second argument is given, it returns "" as second return value.
parseArgsRemoteString returns a remote name and a string if parsed.
If there is an error, it returns two empty strings.
If no remote is given, it returns the project name of the default remote
.
If no second argument is given, it returns "" as second return value.
// parseArgsRemoteString returns a remote name and a string if parsed . // If there is an error it returns two empty strings . // If no remote is given it returns the project name of the default remote // ( ie ' origin ' ) . // If no second argument is given it returns " " as second return value .
func parseArgsRemoteString(args []string) (string, string, error) {
	if !git.InsideGitRepo() {
		if len(args) >= 2 {
			return args[0], args[1], nil
		} else if len(args) >= 1 {
			return args[0], "", nil
		} else {
			return "", "", errors.New("Not enough arguments. Expected at least 1")
		}
	}
	remote, str := forkedFromRemote, ""
	if len(args) == 1 {
		ok, err := git.IsRemote(args[0])
		if err != nil {
			return "", "", err
		}
		if ok {
			remote = args[0]
		} else {
			str = args[0]
		}
	} else if len(args) > 1 {
		remote, str = args[0], args[1]
	}
	ok, err := git.IsRemote(remote)
	if err != nil {
		return "", "", err
	}
	if !ok {
		return "", "", errors.Errorf("%s is not a valid remote", remote)
	}
	remote, err = git.PathWithNameSpace(remote)
	if err != nil {
		return "", "", err
	}
	return remote, str, nil
}
func parseArgsRemoteString ( args [ ] string ) ( string , string , error ) { if ! git . InsideGitRepo ( ) { if len ( args ) >= 2 { return args [ 0 ] , args [ 1 ] , nil } else if len ( args ) >= 1 { return args [ 0 ] , " " , nil } else { return " " , " " , errors . New ( " " ) } } remote , str := forkedFromRemote , " " if len ( args ) == 1 { ok , err := git . IsRemote ( args [ 0 ] ) if err != nil { return " " , " " , err } if ok { remote = args [ 0 ] } else { str = args [ 0 ] } } else if len ( args ) > 1 { remote , str = args [ 0 ] , args [ 1 ] } ok , err := git . IsRemote ( remote ) if err != nil { return " " , " " , err } if ! ok { return " " , " " , errors . Errorf ( " " , remote ) } remote , err = git . PathWithNameSpace ( remote ) if err != nil { return " " , " " , err } return remote , str , nil }
parseArgsRemoteString returns a remote name and a string if parsed.
parseArgsRemoteString returns a remote name and a string if parsed .