mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
gitfs: add initial fetch to pygit2 and dulwich
This commit is contained in:
parent
78f92e9ab2
commit
53c4b4aaa4
1 changed files with 28 additions and 15 deletions
|
@ -565,12 +565,13 @@ class GitPython(GitProvider):
|
|||
'remote.origin.fetch',
|
||||
'+refs/tags/*:refs/tags/*')
|
||||
self.repo.git.config('http.sslVerify', self.ssl_verify)
|
||||
self.fetch()
|
||||
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
|
||||
|
||||
def dir_list(self, tgt_env):
|
||||
|
@ -943,6 +944,8 @@ class Pygit2(GitProvider):
|
|||
# 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
|
||||
|
||||
def dir_list(self, tgt_env):
|
||||
|
@ -1614,10 +1617,24 @@ class Dulwich(GitProvider): # pylint: disable=abstract-method
|
|||
new = False
|
||||
if not os.listdir(self.cachedir):
|
||||
# Repo cachedir is empty, initialize a new repo there
|
||||
self.repo = dulwich.repo.Repo.init(self.cachedir)
|
||||
new = True
|
||||
else:
|
||||
# Repo cachedir exists, try to attach
|
||||
try:
|
||||
self.repo = dulwich.repo.Repo(self.cachedir)
|
||||
except dulwich.repo.NotGitRepository:
|
||||
log.error(_INVALID_REPO.format(self.cachedir, self.url))
|
||||
return new
|
||||
|
||||
self.lockfile = os.path.join(self.repo.path, 'update.lk')
|
||||
|
||||
# Read in config file and look for the remote
|
||||
try:
|
||||
conf = self.get_conf()
|
||||
conf.get(('remote', 'origin'), 'url')
|
||||
except KeyError:
|
||||
try:
|
||||
self.repo = dulwich.repo.Repo.init(self.cachedir)
|
||||
new = True
|
||||
conf = self.get_conf()
|
||||
conf.set('http', 'sslVerify', self.ssl_verify)
|
||||
# Add remote manually, there is no function/object to do this
|
||||
conf.set(
|
||||
|
@ -1630,17 +1647,10 @@ class Dulwich(GitProvider): # pylint: disable=abstract-method
|
|||
conf.write_to_path()
|
||||
except os.error:
|
||||
pass
|
||||
else:
|
||||
# Repo cachedir exists, try to attach
|
||||
try:
|
||||
self.repo = dulwich.repo.Repo(self.cachedir)
|
||||
except dulwich.repo.NotGitRepository:
|
||||
log.error(_INVALID_REPO.format(self.cachedir, self.url))
|
||||
return new
|
||||
|
||||
self.lockfile = os.path.join(self.repo.path, 'update.lk')
|
||||
|
||||
# No way to interact with remotes, so just assume success
|
||||
else:
|
||||
new = True
|
||||
except os.error:
|
||||
pass
|
||||
return new
|
||||
|
||||
def walk_tree(self, tree, path):
|
||||
|
@ -1748,6 +1758,9 @@ class GitBase(object):
|
|||
repo_obj.root = repo_obj.root.rstrip(os.path.sep)
|
||||
# Sanity check and assign the credential parameter
|
||||
repo_obj.verify_auth()
|
||||
if repo_obj.new:
|
||||
# Perform initial fetch
|
||||
repo_obj.fetch()
|
||||
self.remotes.append(repo_obj)
|
||||
|
||||
# Don't allow collisions in cachedir naming
|
||||
|
|
Loading…
Add table
Reference in a new issue