docs: def git_clone(prettyname: str, url: str, directory: str,
                branch: str = None,
                commit: str = None,
                clone_options: List[str] = None,
                run_func: Callable[[List[str]], Any] = None) -> bool:
      """
      Fetches a Git repository, unless we have it already.
  
      Args:
          prettyname: name to display to user
          url: URL
          directory: destination directory
          branch: repository branch
          commit: repository commit tag
          clone_options: additional options to pass to ``git clone``
          run_func: function to use to call an external command
  
      Returns:
          did we need to do anything?
      """
      run_func = run_func or subprocess.check_call
      clone_options = clone_options or []  # type: List[str]
      if os.path.isdir(directory):
          log.info("Not re-cloning {} Git repository: using existing source "
                   "in {}".format(prettyname, directory))
          return False
      log.info("Fetching {} source from {} into {}",
               prettyname, url, directory)
      require_executable(GIT)
      gitargs = [GIT, "clone"] + clone_options
      if branch:
          gitargs += ["--branch", branch]
      gitargs += [url, directory]
      run_func(gitargs)
      if commit:
          log.info("Resetting {} local Git repository to commit {}",
                   prettyname, commit)
          run_func([GIT,
                    "-C", directory,
                    "reset", "--hard", commit])
          # Using a Git repository that's not in the working directory:
          # https://stackoverflow.com/questions/1386291/git-git-dir-not-working-as-expected  # noqa
      return True