def find_version_tag()

in cdk-project/lib/images/codebuild-image/python/src/notebooks/git.py [0:0]


    def find_version_tag(self):
        depth = 1
        cmd = "git describe --tags --abbrev=0 --match v[0-9][0-9.]*".split()

        # try up to 1024 commits
        for _ in range(0, 10):
            try:
                return notebooks.common.check_output_capture_error(cmd)
            except subprocess.CalledProcessError as e:
                if self._revcount() < depth:
                    # no more commits
                    return None

                if "No tags" in e.stdout or "No names found" in e.stdout:
                    depth = depth * 2
                    notebooks.common.check_call_quiet(f"git fetch --depth {depth}".split())
                else:
                    raise

        return None