mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-09-21 04:10:37 +02:00
fix(deploy): files are not pushed to the remote
This commit is contained in:
parent
d1c881e2c3
commit
0e3bd6f63e
@ -730,12 +730,13 @@ def upload_to_servergitmirror(mirror_config: Dict[str, str],
|
|||||||
|
|
||||||
# Use a separate branch for the index only mode as it needs a different set of files to commit
|
# Use a separate branch for the index only mode as it needs a different set of files to commit
|
||||||
if index_only:
|
if index_only:
|
||||||
branch_name = 'index_only'
|
local_branch_name = 'index_only'
|
||||||
else:
|
else:
|
||||||
branch_name = 'full'
|
local_branch_name = 'full'
|
||||||
if branch_name not in local_repo.heads:
|
if local_branch_name not in local_repo.heads:
|
||||||
local_repo.create_head(branch_name)
|
local_repo.create_head(local_branch_name)
|
||||||
local_repo.head.reference = local_repo.heads[branch_name]
|
local_repo.head.reference = local_repo.heads[local_branch_name]
|
||||||
|
remote_branch_name = GIT_BRANCH
|
||||||
|
|
||||||
remote_url = mirror_config['url']
|
remote_url = mirror_config['url']
|
||||||
name = REMOTE_HOSTNAME_REGEX.sub(r'\1', remote_url)
|
name = REMOTE_HOSTNAME_REGEX.sub(r'\1', remote_url)
|
||||||
@ -751,8 +752,6 @@ def upload_to_servergitmirror(mirror_config: Dict[str, str],
|
|||||||
|
|
||||||
if index_only:
|
if index_only:
|
||||||
# test
|
# test
|
||||||
print(glob.glob('.' + '/**/*', recursive=True))
|
|
||||||
|
|
||||||
logging.debug('Adding index files to git mirror')
|
logging.debug('Adding index files to git mirror')
|
||||||
local_repo.index.add(_get_index_file_paths(os.path.join('fdroid', repo_section)))
|
local_repo.index.add(_get_index_file_paths(os.path.join('fdroid', repo_section)))
|
||||||
else:
|
else:
|
||||||
@ -807,7 +806,7 @@ def upload_to_servergitmirror(mirror_config: Dict[str, str],
|
|||||||
logging.debug(_('Pushing to {url}').format(url=remote.url))
|
logging.debug(_('Pushing to {url}').format(url=remote.url))
|
||||||
with local_repo.git.custom_environment(GIT_SSH_COMMAND=ssh_cmd):
|
with local_repo.git.custom_environment(GIT_SSH_COMMAND=ssh_cmd):
|
||||||
pushinfos = remote.push(
|
pushinfos = remote.push(
|
||||||
GIT_BRANCH, force=True, set_upstream=True, progress=progress
|
f"{local_branch_name}:{remote_branch_name}", force=True, set_upstream=True, progress=progress
|
||||||
)
|
)
|
||||||
for pushinfo in pushinfos:
|
for pushinfo in pushinfos:
|
||||||
if pushinfo.flags & (git.remote.PushInfo.ERROR
|
if pushinfo.flags & (git.remote.PushInfo.ERROR
|
||||||
|
@ -1028,14 +1028,14 @@ class DeployTest(unittest.TestCase):
|
|||||||
|
|
||||||
os.chdir(self.testdir)
|
os.chdir(self.testdir)
|
||||||
|
|
||||||
local_repo_path = Path(self.testdir) / 'local'
|
local_git_repo_path = Path(self.testdir) / 'local'
|
||||||
local_repo = git.Repo.init(
|
local_git_repo = git.Repo.init(
|
||||||
local_repo_path, initial_branch=initial_branch
|
local_git_repo_path, initial_branch=initial_branch
|
||||||
)
|
)
|
||||||
# An initial commit of the git tree is required be for other operations
|
# An initial commit of the git tree is required be for other operations
|
||||||
local_repo.index.commit('Initial commit')
|
local_git_repo.index.commit('Initial commit')
|
||||||
|
|
||||||
fdroid_dir = local_repo_path / 'fdroid'
|
fdroid_dir = local_git_repo_path / 'fdroid'
|
||||||
repo_dir = fdroid_dir / repo_section
|
repo_dir = fdroid_dir / repo_section
|
||||||
repo_dir.mkdir(parents=True)
|
repo_dir.mkdir(parents=True)
|
||||||
for filename in fdroidserver.deploy.INDEX_FILES:
|
for filename in fdroidserver.deploy.INDEX_FILES:
|
||||||
@ -1044,23 +1044,37 @@ class DeployTest(unittest.TestCase):
|
|||||||
fp.write('not a real one, but has the right filename')
|
fp.write('not a real one, but has the right filename')
|
||||||
|
|
||||||
# The remote repo must be a bare repo to allow being pushed to
|
# The remote repo must be a bare repo to allow being pushed to
|
||||||
remote_repo_path = Path(self.testdir) / 'remote'
|
remote_git_repo_dir = Path(self.testdir) / 'remote'
|
||||||
remote_repo = git.Repo.init(remote_repo_path, initial_branch=initial_branch, bare=True)
|
remote_git_repo = git.Repo.init(
|
||||||
|
remote_git_repo_dir, initial_branch=initial_branch, bare=True
|
||||||
|
)
|
||||||
|
|
||||||
mirror_config = {"url": str(remote_repo_path), "index_only": True}
|
mirror_config = {"url": str(remote_git_repo_dir), "index_only": True}
|
||||||
enabled_remotes = []
|
enabled_remotes = []
|
||||||
ssh_cmd = 'ssh -oBatchMode=yes'
|
ssh_cmd = 'ssh -oBatchMode=yes'
|
||||||
fdroidserver.deploy.upload_to_servergitmirror(
|
fdroidserver.deploy.upload_to_servergitmirror(
|
||||||
mirror_config=mirror_config,
|
mirror_config=mirror_config,
|
||||||
local_repo=local_repo,
|
local_repo=local_git_repo,
|
||||||
enabled_remotes=enabled_remotes,
|
enabled_remotes=enabled_remotes,
|
||||||
repo_section=repo_section,
|
repo_section=repo_section,
|
||||||
fdroid_dir=str(fdroid_dir),
|
fdroid_dir=str(fdroid_dir),
|
||||||
git_mirror_path=str(local_repo_path),
|
git_mirror_path=str(local_git_repo_path),
|
||||||
ssh_cmd=ssh_cmd,
|
ssh_cmd=ssh_cmd,
|
||||||
progress=git.RemoteProgress()
|
progress=git.RemoteProgress(),
|
||||||
)
|
)
|
||||||
assert remote_repo.is_dirty
|
|
||||||
|
verify_repo = remote_git_repo.clone(
|
||||||
|
Path(self.testdir) / 'verify',
|
||||||
|
)
|
||||||
|
|
||||||
|
for filename in fdroidserver.deploy.INDEX_FILES:
|
||||||
|
remote_file = f"fdroid/{repo_section}/{filename}"
|
||||||
|
|
||||||
|
self.assertIsNotNone(verify_repo.working_tree_dir)
|
||||||
|
if verify_repo.working_tree_dir is not None:
|
||||||
|
self.assertTrue(
|
||||||
|
(Path(verify_repo.working_tree_dir) / remote_file).exists()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user