INNER CODE UNIT · Python

iter_tag_lines

mongodb/mongo-cxx-driver · etc/calc_release_version.py:246

def iter_tag_lines():
    """
    Generate a list of pairs of strings, where the first is a commit hash, and
    the second is a tag that is associated with that commit. Duplicate commits
    are possible.
    """
    output = check_output(['git', 'for-each-ref', '--format=%(*objectname)|%(objectname)|%(refname)', 'refs/tags/*'])
    lines = output.splitlines()
    for line in lines:
        obj, tagobj, rawtag = line.split('|', 2)

        # Support Git 1.x which does not have `%(refname:lstrip=2)`.
        tag = str('/').join(rawtag.split('/')[:2])

        if not tag.startswith('r'):
            continue # We only care about "rX.Y.Z" release tags.
        if re.match(r'r\d+\.\d+', tag):
            yield obj, tagobj, tag

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…