def _parse_version_chunk(version_chunk):
    """
    Args:
      version_chunk: a chunk of a semantic version, possibly with trailing
                     content at the end; such as "29", "2", or "3 foobar".
                     We handle trailing content because
                     native.bazel_version can: try printing actual_version
                     in check_version below (got for example
                     "2.0.0- (@non-git)").
    Returns:
      The chunk string with trailing content removed, such as "29", "2", or "3"
    """
    for i in range(len(version_chunk)):
        c = version_chunk[i]
        if not c.isdigit():
            return version_chunk[:i]
    return version_chunk