original_docstring: 
          Initialize/attach to a remote using pygit2. Return a boolean which
          will let the calling function know whether or not a new repo was
          initialized by this function.
          
docstring: Initialize/attach to a remote using pygit2. Return a boolean which
  will let the calling function know whether or not a new repo was
  initialized by this function.
docstring_tokens: Initialize / attach to a remote using pygit2 . Return a boolean which will let the calling function know whether or not a new repo was initialized by this function .
code: def init_remote(self):
          '''
          Initialize/attach to a remote using pygit2. Return a boolean which
          will let the calling function know whether or not a new repo was
          initialized by this function.
          '''
          new = False
          if not os.listdir(self.cachedir):
              # Repo cachedir is empty, initialize a new repo there
              self.repo = pygit2.init_repository(self.cachedir)
              new = True
          else:
              # Repo cachedir exists, try to attach
              try:
                  try:
                      self.repo = pygit2.Repository(self.cachedir)
                  except pygit2.GitError as exc:
                      import pwd
                      # https://github.com/libgit2/pygit2/issues/339
                      # https://github.com/libgit2/libgit2/issues/2122
                      if "Error stat'ing config file" not in str(exc):
                          raise
                      home = pwd.getpwnam(salt.utils.get_user()).pw_dir
                      pygit2.settings.search_path[pygit2.GIT_CONFIG_LEVEL_GLOBAL] = home
                      self.repo = pygit2.Repository(self.cachedir)
              except KeyError:
                  log.error(_INVALID_REPO.format(self.cachedir, self.url, self.role))
                  return new
  
          self.gitdir = salt.utils.path_join(self.repo.workdir, '.git')
  
          if not self.repo.remotes:
              try:
                  self.repo.create_remote('origin', self.url)
                  # Ensure tags are also fetched
                  self.repo.config.set_multivar(
                      'remote.origin.fetch',
                      'FOO',
                      '+refs/tags/*:refs/tags/*'
                  )
                  self.repo.config.set_multivar(
                      'http.sslVerify',
                      '',
                      str(self.ssl_verify).lower()
                  )
              except os.error:
                  # This exception occurs when two processes are trying to write
                  # to the git config at once, go ahead and pass over it since
                  # this is the only write. This should place a lock down.
                  pass
              else:
                  new = True
          return new
code_tokens: def init_remote ( self ) : new = False if not os . listdir ( self . cachedir ) : self . repo = pygit2 . init_repository ( self . cachedir ) new = True else : try : try : self . repo = pygit2 . Repository ( self . cachedir ) except pygit2 . GitError as exc : import pwd if "Error stat'ing config file" not in str ( exc ) : raise home = pwd . getpwnam ( salt . utils . get_user ( ) ) . pw_dir pygit2 . settings . search_path [ pygit2 . GIT_CONFIG_LEVEL_GLOBAL ] = home self . repo = pygit2 . Repository ( self . cachedir ) except KeyError : log . error ( _INVALID_REPO . format ( self . cachedir , self . url , self . role ) ) return new self . gitdir = salt . utils . path_join ( self . repo . workdir , '.git' ) if not self . repo . remotes : try : self . repo . create_remote ( 'origin' , self . url ) self . repo . config . set_multivar ( 'remote.origin.fetch' , 'FOO' , '+refs/tags/*:refs/tags/*' ) self . repo . config . set_multivar ( 'http.sslVerify' , '' , str ( self . ssl_verify ) . lower ( ) ) except os . error : pass else : new = True return new
short_docstring: Initialize/attach to a remote using pygit2.
short_docstring_tokens: Initialize / attach to a remote using pygit2 .
comment: '''
          Initialize/attach to a remote using pygit2. Return a boolean which
          will let the calling function know whether or not a new repo was
          initialized by this function.
          '''$SEP$# Repo cachedir is empty, initialize a new repo there$SEP$# Repo cachedir exists, try to attach$SEP$# https://github.com/libgit2/pygit2/issues/339$SEP$# https://github.com/libgit2/libgit2/issues/2122$SEP$# Ensure tags are also fetched$SEP$# This exception occurs when two processes are trying to write$SEP$# to the git config at once, go ahead and pass over it since$SEP$# this is the only write. This should place a lock down.