original_docstring: 
      Given a folder pointing to a Git repo, return a dict containing info
      about remote commits not qpplied yet to the repo, or empty dict if nothing
      new.
      
docstring: Given a folder pointing to a Git repo, return a dict containing info
  about remote commits not qpplied yet to the repo, or empty dict if nothing
  new.
docstring_tokens: Given a folder pointing to a Git repo return a dict containing info about remote commits not qpplied yet to the repo or empty dict if nothing new .
code: def check_new_version(folder, max_commits=10):
      """
      Given a folder pointing to a Git repo, return a dict containing info
      about remote commits not qpplied yet to the repo, or empty dict if nothing
      new.
      """
      # from https://stackoverflow.com/questions/8290233/gitpython-get-list-of-remote-commits-not-yet-applied
      try:
          repo = Repo(folder)
      except InvalidGitRepositoryError:
          logging.warning("Not a valid git repository for folder '%s', skipped for checking new version." % folder)
          return
  
      try:
          # Get URL from actual remote branch name that is being tracked.
          # more details: see comments in get_version
          remote_name = repo.active_branch.tracking_branch().remote_name
          url = repo.remote(remote_name).url
          repo_url = re.sub(r"\.git$", "", url)
      except Exception as e:
          logging.debug("Can't determine repository URL: %s" % e)
          repo_url = None
      new_info = {}
      try:
          # we can't directly get the list of new commits without fetching them locally first
          # but we'd like to avoid fetching all the time just to check.
          # what we can do is a ls-remote and check the HEAD hash, if different, then fetch
          # (no pull) and inspect differences.
          head = repo.head.ref
          tracking = head.tracking_branch()
          # inspect remote HEAD for that branch
          output = repo.git.ls_remote("--heads", tracking.remote_name, tracking.remote_head)
          remote_head_hexsha = output.split("\t")[0]
          if remote_head_hexsha == head.commit.hexsha:
              # hashes the same, we're up-to-date with the remote
              return
          else:
              logging.info("HEAD on remote is different, new commit(s) available for '%s'" % folder)
              logging.info("HEAD(remote): %s, HEAD(local): %s" % (remote_head_hexsha, head.commit.hexsha))
              # need to fetch new code locally
              # usually one remotes, but just in case...
              for remote in repo.remotes:
                  remote.fetch()
          # now identify new commits
          new_commits = [commit for commit in tracking.commit.iter_items(repo, f'{head.path}..{tracking.path}')]
          if new_commits:
              new_info = {
                  "latest": new_commits[0].hexsha[:6],
                  "commits": [
                      {
                          "hash": c.hexsha[:6],
                          "url": repo_url and os.path.join(repo_url, "commit", c.hexsha) or None,
                          "date": c.committed_datetime.isoformat(),
                          "message": c.message
                      } for c in new_commits][:max_commits],
                  "total": len(new_commits),
              }
      except Exception as e:
          logging.warning("Can't check for new version: %s" % e)
          raise e
  
      return new_info
code_tokens: def check_new_version ( folder , max_commits = 10 ) : try : repo = Repo ( folder ) except InvalidGitRepositoryError : logging . warning ( "Not a valid git repository for folder '%s', skipped for checking new version." % folder ) return try : remote_name = repo . active_branch . tracking_branch ( ) . remote_name url = repo . remote ( remote_name ) . url repo_url = re . sub ( r"\.git$" , "" , url ) except Exception as e : logging . debug ( "Can't determine repository URL: %s" % e ) repo_url = None new_info = { } try : head = repo . head . ref tracking = head . tracking_branch ( ) output = repo . git . ls_remote ( "--heads" , tracking . remote_name , tracking . remote_head ) remote_head_hexsha = output . split ( "\t" ) [ 0 ] if remote_head_hexsha == head . commit . hexsha : return else : logging . info ( "HEAD on remote is different, new commit(s) available for '%s'" % folder ) logging . info ( "HEAD(remote): %s, HEAD(local): %s" % ( remote_head_hexsha , head . commit . hexsha ) ) for remote in repo . remotes : remote . fetch ( ) new_commits = [ commit for commit in tracking . commit . iter_items ( repo , f'{head.path}..{tracking.path}' ) ] if new_commits : new_info = { "latest" : new_commits [ 0 ] . hexsha [ : 6 ] , "commits" : [ { "hash" : c . hexsha [ : 6 ] , "url" : repo_url and os . path . join ( repo_url , "commit" , c . hexsha ) or None , "date" : c . committed_datetime . isoformat ( ) , "message" : c . message } for c in new_commits ] [ : max_commits ] , "total" : len ( new_commits ) , } except Exception as e : logging . warning ( "Can't check for new version: %s" % e ) raise e return new_info
short_docstring: Given a folder pointing to a Git repo, return a dict containing info
  about remote commits not qpplied yet to the repo, or empty dict if nothing
  new.
short_docstring_tokens: Given a folder pointing to a Git repo return a dict containing info about remote commits not qpplied yet to the repo or empty dict if nothing new .
comment: """
      Given a folder pointing to a Git repo, return a dict containing info
      about remote commits not qpplied yet to the repo, or empty dict if nothing
      new.
      """$SEP$# from https://stackoverflow.com/questions/8290233/gitpython-get-list-of-remote-commits-not-yet-applied$SEP$# Get URL from actual remote branch name that is being tracked.$SEP$# more details: see comments in get_version$SEP$# we can't directly get the list of new commits without fetching them locally first$SEP$# but we'd like to avoid fetching all the time just to check.$SEP$# what we can do is a ls-remote and check the HEAD hash, if different, then fetch$SEP$# (no pull) and inspect differences.$SEP$# inspect remote HEAD for that branch$SEP$# hashes the same, we're up-to-date with the remote$SEP$# need to fetch new code locally$SEP$# usually one remotes, but just in case...$SEP$# now identify new commits