parameters: (current_branch="HEAD")
return_statement: return common_commit
docstring: When running outside of CI, this will estimate the target merge commit hash
      of `current_branch` by finding a common ancester with the remote branch
      'branch-{major}.{minor}' where {major} and {minor} are determined from the
      repo version.
  
      Parameters
      ----------
      current_branch : str, optional
          Which branch to consider as the current branch, by default "HEAD"
  
      Returns
      -------
      str
          The common commit hash ID
docstring_summary: When running outside of CI, this will estimate the target merge commit hash
      of `current_branch` by finding a common ancester with the remote branch
      'branch-{major}.{minor}' where {major} and {minor} are determined from the
      repo version.
docstring_tokens: When running outside of CI this will estimate the target merge commit hash of current_branch by finding a common ancester with the remote branch branch - { major } . { minor } where { major } and { minor } are determined from the repo version .
function: def determine_merge_commit(current_branch="HEAD"):
      """
      When running outside of CI, this will estimate the target merge commit hash
      of `current_branch` by finding a common ancester with the remote branch
      'branch-{major}.{minor}' where {major} and {minor} are determined from the
      repo version.
  
      Parameters
      ----------
      current_branch : str, optional
          Which branch to consider as the current branch, by default "HEAD"
  
      Returns
      -------
      str
          The common commit hash ID
      """
  
      try:
          # Try to determine the target branch from the most recent tag
          head_branch = __git("describe",
                              "--all",
                              "--tags",
                              "--match='branch-*'",
                              "--abbrev=0")
      except subprocess.CalledProcessError:
          print("   [DEBUG] Could not determine target branch from most recent "
                "tag. Falling back to 'branch-{major}.{minor}.")
          head_branch = None
  
      if (head_branch is not None):
          # Convert from head to branch name
          head_branch = __git("name-rev", "--name-only", head_branch)
      else:
          # Try and guess the target branch as "branch-<major>.<minor>"
          version = repo_version_major_minor()
  
          if (version is None):
              return None
  
          head_branch = "branch-{}".format(version)
  
      try:
          # Now get the remote tracking branch
          remote_branch = __git("rev-parse",
                                "--abbrev-ref",
                                "--symbolic-full-name",
                                head_branch + "@{upstream}")
      except subprocess.CalledProcessError:
          print("   [DEBUG] Could not remote tracking reference for "
                f"branch {head_branch}.")
          remote_branch = None
  
      if (remote_branch is None):
          return None
  
      print(f"   [DEBUG] Determined TARGET_BRANCH as: '{remote_branch}'. "
            "Finding common ancestor.")
  
      common_commit = __git("merge-base", remote_branch, current_branch)
  
      return common_commit
function_tokens: def determine_merge_commit ( current_branch = "HEAD" ) : try : # Try to determine the target branch from the most recent tag head_branch = __git ( "describe" , "--all" , "--tags" , "--match='branch-*'" , "--abbrev=0" ) except subprocess . CalledProcessError : print ( "   [DEBUG] Could not determine target branch from most recent " "tag. Falling back to 'branch-{major}.{minor}." ) head_branch = None if ( head_branch is not None ) : # Convert from head to branch name head_branch = __git ( "name-rev" , "--name-only" , head_branch ) else : # Try and guess the target branch as "branch-<major>.<minor>" version = repo_version_major_minor ( ) if ( version is None ) : return None head_branch = "branch-{}" . format ( version ) try : # Now get the remote tracking branch remote_branch = __git ( "rev-parse" , "--abbrev-ref" , "--symbolic-full-name" , head_branch + "@{upstream}" ) except subprocess . CalledProcessError : print ( "   [DEBUG] Could not remote tracking reference for " f"branch {head_branch}." ) remote_branch = None if ( remote_branch is None ) : return None print ( f"   [DEBUG] Determined TARGET_BRANCH as: '{remote_branch}'. " "Finding common ancestor." ) common_commit = __git ( "merge-base" , remote_branch , current_branch ) return common_commit