def parse_version(version_string):
    """
    Parse the version from a string

    The format handled is "<major>.<minor>.<patch>-<date> <commit>"

    Args:
      version_string: the version string to parse

    Returns:
      A 3-tuple of numbers: (<major>, <minor>, <patch>)
    """

    # Remove commit from version.
    version = version_string.split(" ", 1)[0]

    # Remove semver "build metadata" tag
    version = version.split("+", 1)[0]

    # Split into (release, date) parts and only return the release
    # as a tuple of integers.
    parts = version.split("-", 1)

    # Handle format x.x.xrcx
    parts = parts[0].split("rc", 1)

    # Turn "release" into a tuple of numbers
    version_tuple = ()
    for number in parts[0].split("."):
        version_tuple += (int(number),)
    return version_tuple