class_docstr: Helps to build releases through scripting of steps.
class_docstr_tok: ["Helps","to","build","releases","through","scripting","of","steps","."]
docstr: Checkout or create branch from branch_hash provided.
  
  If the branch does not exist in the remote (origin) or locally then it is
  created at the provided hash point. In all cases the branch is setup with
  the upstream set to the origin.
docstr_tok: ["Checkout","or","create","branch","from","branch_hash","provided",".","If","the","branch","does","not","exist","in","the","remote","(","origin",")","or","locally","then","it","is","created","at","the","provided","hash","point",".","In","all","cases","the","branch","is","setup","with","the","upstream","set","to","the","origin","."]
code: def _checkout_or_create_branch(self):
      """Checkout or create branch from branch_hash provided.
  
      If the branch does not exist in the remote (origin) or locally then it is
      created at the provided hash point. In all cases the branch is setup with
      the upstream set to the origin.
      """
      # Checks if already on the desired branch and assumes branch was already
      # pushed to the remote.
      if self.repo.active_branch.name == self.branch_name:
          return
  
      if any(x.name == self.branch_name for x in self.repo.branches):
          self.repo.git.checkout(self.branch_name)
      else:
          try:
              self.repo.git.checkout(
                  "origin/" + self.branch_name, b=self.branch_name
              )
          except GitCommandError:
              self.repo.create_head(
                  self.branch_name, commit=self.branch_hash
              ).checkout()
              logging.info(
                  "Created branch %s from hash %s.",
                  self.repo.active_branch,
                  self.branch_hash,
              )
  
      self.repo.git.push("--set-upstream", "origin", self.branch_name)
      logging.info(
          "Branch pushed to remote %s.", self.repo.remotes.origin.url
      )
      logging.info(
          "Active branch changed to:%s", self.repo.active_branch
      )
  
imports: import fileinput
  import os
  from absl import app
  from absl import flags
  from absl import logging
  from git import Repo
  from git.exc import GitCommandError
  from git.exc import InvalidGitRepositoryError
label_desc: Use image node_id 8 for calling the ReleaseBuilder obj's underlying member method code with example usage: obj._checkout_or_create_branch() without return types