mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-09-21 04:10:37 +02:00
fix(deploy): all files are uploaded if the index only mode deployment follows a full mode one
switch the branch before rsyncing
This commit is contained in:
parent
77c3f83fd7
commit
01990411c7
@ -688,9 +688,21 @@ def update_servergitmirrors(servergitmirrors, repo_section):
|
||||
|
||||
enabled_remotes = []
|
||||
for d in servergitmirrors:
|
||||
is_index_only = d.get('index_only', False)
|
||||
|
||||
# Use a separate branch for the index only mode as it needs a different set of files to commit
|
||||
if is_index_only:
|
||||
local_branch_name = 'index_only'
|
||||
else:
|
||||
local_branch_name = 'full'
|
||||
if local_branch_name in repo.heads:
|
||||
repo.git.switch(local_branch_name)
|
||||
else:
|
||||
repo.git.switch('--orphan', local_branch_name)
|
||||
|
||||
# trailing slashes have a meaning in rsync which is not needed here, so
|
||||
# make sure both paths have exactly one trailing slash
|
||||
if d.get('index_only', False):
|
||||
if is_index_only:
|
||||
files_to_sync = [str(working_dir_root / repo_section / index_file) for index_file in INDEX_FILES]
|
||||
else:
|
||||
files_to_sync = [str(working_dir_root / repo_section).rstrip('/') + '/']
|
||||
@ -702,6 +714,7 @@ def update_servergitmirrors(servergitmirrors, repo_section):
|
||||
local_repo=repo,
|
||||
enabled_remotes=enabled_remotes,
|
||||
repo_section=repo_section,
|
||||
is_index_only=is_index_only,
|
||||
fdroid_dir=git_fdroiddir,
|
||||
git_mirror_path=str(git_mirror_path),
|
||||
ssh_cmd=ssh_cmd,
|
||||
@ -717,6 +730,7 @@ def upload_to_servergitmirror(mirror_config: Dict[str, str],
|
||||
local_repo: Repo,
|
||||
enabled_remotes: List[str],
|
||||
repo_section: str,
|
||||
is_index_only: bool,
|
||||
fdroid_dir: str,
|
||||
git_mirror_path: str,
|
||||
ssh_cmd: str,
|
||||
@ -727,18 +741,8 @@ def upload_to_servergitmirror(mirror_config: Dict[str, str],
|
||||
logging.info("files:")
|
||||
logging.info(local_repo.git.ls_files())
|
||||
|
||||
index_only = mirror_config.get('index_only', False)
|
||||
|
||||
# Use a separate branch for the index only mode as it needs a different set of files to commit
|
||||
if index_only:
|
||||
local_branch_name = 'index_only'
|
||||
else:
|
||||
local_branch_name = 'full'
|
||||
if local_branch_name in local_repo.heads:
|
||||
local_repo.git.switch(local_branch_name)
|
||||
else:
|
||||
local_repo.git.switch('--orphan', local_branch_name)
|
||||
remote_branch_name = GIT_BRANCH
|
||||
local_branch_name = local_repo.active_branch.name
|
||||
|
||||
remote_url = mirror_config['url']
|
||||
name = REMOTE_HOSTNAME_REGEX.sub(r'\1', remote_url)
|
||||
@ -753,7 +757,7 @@ def upload_to_servergitmirror(mirror_config: Dict[str, str],
|
||||
logging.info('Mirroring to: ' + remote_url)
|
||||
|
||||
logging.info("git status:", local_repo.git.status())
|
||||
if index_only:
|
||||
if is_index_only:
|
||||
# test
|
||||
logging.debug('Adding index files to git mirror')
|
||||
local_repo.index.add(_get_index_file_paths(os.path.join('fdroid', repo_section)))
|
||||
@ -766,7 +770,7 @@ def upload_to_servergitmirror(mirror_config: Dict[str, str],
|
||||
local_repo.index.commit("fdroidserver git-mirror")
|
||||
|
||||
# Test
|
||||
logging.info(f"In index-only: {index_only} mode")
|
||||
logging.info(f"In index-only: {is_index_only} mode")
|
||||
logging.info(local_repo.git.status())
|
||||
logging.info(local_repo.head.log())
|
||||
|
||||
|
@ -1056,6 +1056,7 @@ class DeployTest(unittest.TestCase):
|
||||
local_repo=local_git_repo,
|
||||
enabled_remotes=enabled_remotes,
|
||||
repo_section=repo_section,
|
||||
is_index_only=mirror_config['index_only'],
|
||||
fdroid_dir=str(fdroid_dir),
|
||||
git_mirror_path=str(local_git_repo_path),
|
||||
ssh_cmd=ssh_cmd,
|
||||
|
Loading…
Reference in New Issue
Block a user