fix(LFS): fixed pull_changes method to support a new (sync_large_objects) flag, updated all parts that will use a new flag. Fixes: RCCE-8

This commit is contained in:
Serhii Ilin 2024-01-08 14:22:04 +02:00
parent 8048eb5a1e
commit 840ea1daef
5 changed files with 10 additions and 8 deletions

View file

@ -2227,7 +2227,7 @@ def revoke_user_group_permission(request, apiuser, repoid, usergroupid):
@jsonrpc_method()
def pull(request, apiuser, repoid, remote_uri=Optional(None)):
def pull(request, apiuser, repoid, remote_uri=Optional(None), sync_large_objects=Optional(False)):
"""
Triggers a pull on the given repository from a remote location. You
can use this to keep remote repositories up-to-date.
@ -2244,6 +2244,8 @@ def pull(request, apiuser, repoid, remote_uri=Optional(None)):
:type repoid: str or int
:param remote_uri: Optional remote URI to pass in for pull
:type remote_uri: str
:param sync_large_objects: Optional flag for pulling LFS objects.
:type sync_large_objects: bool
Example output:
@ -2277,7 +2279,7 @@ def pull(request, apiuser, repoid, remote_uri=Optional(None)):
try:
ScmModel().pull_changes(
repo.repo_name, apiuser.username, remote_uri=remote_uri)
repo.repo_name, apiuser.username, remote_uri=remote_uri, sync_large_objects=sync_large_objects)
return {
'msg': 'Pulled from url `{}` on repo `{}`'.format(
remote_uri_display, repo.repo_name),

View file

@ -52,7 +52,7 @@ class RepoSettingsRemoteView(RepoAppView):
try:
ScmModel().pull_changes(
self.db_repo_name, self._rhodecode_user.username)
self.db_repo_name, self._rhodecode_user.username, sync_large_objects=True)
h.flash(_('Pulled from remote location'), category='success')
except Exception:
log.exception("Exception during pull from remote")

View file

@ -669,11 +669,11 @@ class GitRepository(BaseRepository):
self._remote.pull(url, refs=refs, update_after=update_after)
self._remote.invalidate_vcs_cache()
def fetch(self, url, commit_ids=None):
def fetch(self, url, commit_ids=None, **kwargs):
"""
Fetch all git objects from external location.
"""
self._remote.sync_fetch(url, refs=commit_ids)
self._remote.sync_fetch(url, refs=commit_ids, **kwargs)
self._remote.invalidate_vcs_cache()
def push(self, url):

View file

@ -577,7 +577,7 @@ class MercurialRepository(BaseRepository):
self._remote.pull(url, commit_ids=commit_ids)
self._remote.invalidate_vcs_cache()
def fetch(self, url, commit_ids=None):
def fetch(self, url, commit_ids=None, **kwargs):
"""
Backward compatibility with GIT fetch==pull
"""

View file

@ -387,7 +387,7 @@ class ScmModel(BaseModel):
self.sa.add(repo)
return repo
def pull_changes(self, repo, username, remote_uri=None, validate_uri=True):
def pull_changes(self, repo, username, remote_uri=None, validate_uri=True, **kwargs):
dbrepo = self._get_repo(repo)
remote_uri = remote_uri or dbrepo.clone_uri
if not remote_uri:
@ -409,7 +409,7 @@ class ScmModel(BaseModel):
repo_name = dbrepo.repo_name
try:
# TODO: we need to make sure those operations call proper hooks !
repo.fetch(remote_uri)
repo.fetch(remote_uri, **kwargs)
self.mark_for_invalidation(repo_name)
except Exception: