def render_pep440_tag(pieces):
    """TAG[[.postDISTANCE].dev0+gHEX] -- Just the tag if not dirty, else more info

    Useful for projects that want commit based tracking on some branches
    but have the master branch only report tags, to allow for commits that
    do not modify actual code (e.g. to .github/* or docs).

    Exceptions:
    1: no tags. 0.postDISTANCE[.dev0]+gHEX
    """
    if pieces['closest-tag']:
        rendered = pieces['closest-tag']
        if pieces['dirty']:
            rendered += '.post%d' % pieces['distance']
            rendered += '.dev0'
            rendered += '+g%s' % pieces['short']
    else:
        rendered = '0.post%d' % pieces['distance']
        if pieces['dirty']:
            rendered += '.dev0'
        rendered += '+g%s' % pieces['short']
    return rendered
