diff --git a/fdroidserver/deploy.py b/fdroidserver/deploy.py index c1423397..dd930315 100644 --- a/fdroidserver/deploy.py +++ b/fdroidserver/deploy.py @@ -25,7 +25,7 @@ import re import subprocess import time import urllib -from git import Optional +from typing import Optional import yaml from argparse import ArgumentParser, Namespace import logging @@ -687,11 +687,22 @@ def update_servergitmirrors(servergitmirrors, repo_section): progress = None repo = git.Repo.init(git_mirror_path, initial_branch=GIT_BRANCH) - initial_commit_ref = repo.head.commit + + # An initial commit of the git tree is required be for other operations + initial_branch_ref = repo.head.ref + repo.index.commit('Initial commit') enabled_remotes = [] for d in servergitmirrors: index_only = d.get('index_only', False) + if index_only: + # Use a separate branch for the index only mode as it needs a different set of files to commit + repo.create_head('index_only', initial_branch_ref) + repo.heads.index_only.checkout() + else: + repo.create_head('full', initial_branch_ref) + repo.heads.full.checkout() + remote_url = d['url'] name = REMOTE_HOSTNAME_REGEX.sub(r'\1', remote_url) enabled_remotes.append(name) @@ -777,8 +788,9 @@ def update_servergitmirrors(servergitmirrors, repo_section): else: logging.debug(remote.url + ': ' + pushinfo.summary) - # Reset the repository to the initial commit so we can choose which files to commit to the next remote - repo.head.reset(initial_commit_ref, index=True, working_tree=True) + # Switch to the initial branch + repo.head.reference = initial_branch_ref + repo.head.reset(index=True, working_tree=True) if progress: progressbar.done()