class_docstr: TODO: Reimplement functions with robust library: https://github.com/gitpython-developers/GitPython
  
  This CodeDriver manages source control management for the project using git
class_docstr_tok: ["TODO",":","Reimplement","functions","with","robust","library",":","https",":","\/\/github.com\/gitpython-developers\/GitPython","This","CodeDriver","manages","source","control","management","for","the","project","using","git"]
docstr: Add remaining files, make a commit and add it to a datmo code ref
  
  Parameters
  ----------
  commit_id : str, optional
      if commit_id is given, it will not add files and not create a commit
  
  Returns
  -------
  commit_id : str
      commit id for the ref created
  
  Raises
  ------
  CommitDoesNotExist
      commit id specified does not match a valid commit within the tree
  CommitFailed
      commit could not be created
docstr_tok: ["Add","remaining","files",",","make","a","commit","and","add","it","to","a","datmo","code","ref","Parameters","--","--","--","--","--","commit_id",":","str",",","optional","if","commit_id","is","given",",","it","will","not","add","files","and","not","create","a","commit","Returns","--","--","--","-","commit_id",":","str","commit","id","for","the","ref","created","Raises","--","--","--","CommitDoesNotExist","commit","id","specified","does","not","match","a","valid","commit","within","the","tree","CommitFailed","commit","could","not","be","created"]
code: def create_ref(self, commit_id=None):
      """Add remaining files, make a commit and add it to a datmo code ref
  
      Parameters
      ----------
      commit_id : str, optional
          if commit_id is given, it will not add files and not create a commit
  
      Returns
      -------
      commit_id : str
          commit id for the ref created
  
      Raises
      ------
      CommitDoesNotExist
          commit id specified does not match a valid commit within the tree
      CommitFailed
          commit could not be created
      """
      self.ensure_code_refs_dir()
      if not commit_id:
          try:
              _ = self.latest_commit()
              message = "auto commit by datmo"
          except Exception:
              message = "auto initial commit by datmo"
          # add files and commit changes on current branch
          self.add("-A")
          _ = self.commit(options=["-m", message])
          try:
              commit_id = self.latest_commit()
          except GitExecutionError as e:
              raise CommitFailed(
                  __(
                      "error",
                      "controller.code.driver.git.create_ref.cannot_commit",
                      str(e),
                  )
              )
      # writing git commit into ref if exists
      if not self.exists_commit(commit_id):
          raise CommitDoesNotExist(
              __(
                  "error",
                  "controller.code.driver.git.create_ref.no_commit",
                  commit_id,
              )
          )
      # git refs for datmo for the latest commit id is created
      code_ref_path = os.path.join(
          self.filepath, ".git/refs/datmo/", commit_id
      )
      with open(code_ref_path, "wb") as f:
          f.write(to_bytes(commit_id))
      return commit_id
  
imports: import os
  import shutil
  import subprocess
  import semver
  from io import open
  from giturlparse import parse
  from datmo.core.util.i18n import get
  from datmo.core.util.exceptions import PathDoesNotExist, GitUrlArgumentError, GitExecutionError, FileIOError, CommitDoesNotExist, CommitFailed, DatmoFolderInWorkTree, UnstagedChanges
  from datmo.core.controller.code.driver import CodeDriver
  from datmo.config import Config
label_desc: Use image node_id 5 for calling the GitCodeDriver obj's underlying member method code with example usage: obj.create_ref(commit_id) and returns: commit_id