from typing import Tuple


def parse_project_name(name: str, ssh: bool = True) -> Tuple[str, str, str, bool]:
    """Parse the name argument for get_project
    Returns (name, url, branch, is_url).
    If name is not a full url, the returned url will be a https or ssh
    url depending on the boolean argument ssh.
    """
    # This is split off the actual command function for
    # unit testing purposes
    if ':' in name:
        pieces = name.split(':')
        if len(pieces) >= 3:
            name = ':'.join(pieces[:-1])
            branch = pieces[-1]
        elif 'http' in pieces[0] or '@' in pieces[0]:
            branch = ''
        else:
            name, branch = pieces
    else:
        branch = ''

    if not name.startswith(('git@', 'http')):
        if '/' not in name:
            org_name = 'leanprover-community/'+name
        else:
            org_name, name = name, name.split('/')[1]
        if ssh:
            url = 'git@github.com:'+org_name+'.git'
        else:
            url = 'https://github.com/'+org_name+'.git'
        is_url = False
    else:
        url = name
        name = name.split('/')[-1].replace('.git', '')
        is_url = True

    return name, url, branch, is_url