docs: def get_git_version(path):
      """Get the GIT version."""
      branch_name = get_git_cleaned_branch_name(path)
      # Determine whether working copy is dirty (i.e. contains modified files)
      mods = run_cmd(path, 'git', 'status', '--porcelain', '--untracked-files=no')
      dirty = '.dirty' if mods else ''
      # Get a list of all commits on branch, with corresponding branch/tag refs
      # Each line looks something like: "d3e4d42 (HEAD, master, tag: v0.1)"
      git_output = run_cmd(path, 'git', 'log', '--pretty="%h%d"')
      commits = git_output.strip().replace('"', '').split('\n')
      num_commits_since_branch = len(commits)
      # Short hash of the latest commit
      short_commit_name = commits[0].partition(' ')[0]
      # A valid version is sequence of dotted numbers optionally prefixed by 'v'
      valid_version = re.compile(r'^v?([\.\d]+)$')
  
      def tagged_version(commit):
          """First tag on commit that is valid version, as a list of numbers."""
          refs = commit.partition(' ')[2]
          for ref in refs.lstrip('(').rstrip(')').split(', '):
              if ref.startswith('tag: '):
                  tag = ref[5:].lower()
                  found = valid_version.match(tag)
                  if found:
                      return [int(v) for v in found.group(1).split('.') if v]
          return []
      # Walk back along branch and find first valid tagged version (or use 0.0)
      for commit in commits:
          version_numbers = tagged_version(commit)
          if version_numbers:
              break
      else:
          version_numbers = [0, 0]
      # It is a release if current commit has a version tag (and dir is clean)
      release = (commit == commits[0]) and not dirty
      if not release:
          # We are working towards the next (minor) release according to PEP 440
          version_numbers[-1] += 1
      version = '.'.join([str(v) for v in version_numbers])
      if not release:
          # Development version contains extra embellishments
          version = ("%s.dev%d+%s.%s%s" % (version, num_commits_since_branch,
                                           branch_name, short_commit_name, dirty))
      return version