def tokenize_spec(spec):
    """Tokenize a GitHub-style spec into parts, error if spec invalid."""
    spec_parts = spec.split('/', 2)
    if len(spec_parts) != 3:
        msg = ('Spec is not of the form "user/repo/ref", provided: "{spec}".'
            .format(spec=spec))
        if len(spec_parts) == 2 and spec_parts[-1] != 'master':
            msg += ' Did you mean "{spec}/master"?'.format(spec=spec)
        raise ValueError(msg)
    return spec_parts
