diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b9317954..7b790b2a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -125,6 +125,10 @@ ubuntu_lts_ppa: - apt-get update - apt-get dist-upgrade - apt-get install --install-recommends dexdump fdroidserver git jq python3-setuptools sdkmanager + + # Test things work with a default branch other than 'master' + - git config --global init.defaultBranch thisisnotmasterormain + - cd tests - ./run-tests diff --git a/fdroidserver/btlog.py b/fdroidserver/btlog.py index 870ff93b..ea79bc8a 100755 --- a/fdroidserver/btlog.py +++ b/fdroidserver/btlog.py @@ -65,7 +65,7 @@ def make_binary_transparency_log( else: if not os.path.exists(btrepo): os.mkdir(btrepo) - gitrepo = git.Repo.init(btrepo) + gitrepo = git.Repo.init(btrepo, initial_branch=deploy.GIT_BRANCH) if not url: url = common.config['repo_url'].rstrip('/') diff --git a/fdroidserver/deploy.py b/fdroidserver/deploy.py index 0415f7f4..54496f78 100644 --- a/fdroidserver/deploy.py +++ b/fdroidserver/deploy.py @@ -39,6 +39,8 @@ config = None options = None start_timestamp = time.gmtime() +GIT_BRANCH = 'master' + BINARY_TRANSPARENCY_DIR = 'binary_transparency' AUTO_S3CFG = '.fdroid-deploy-s3cfg' @@ -407,7 +409,7 @@ def update_servergitmirrors(servergitmirrors, repo_section): elif 'identity_file' in config: ssh_cmd += ' -oIdentitiesOnly=yes -i "%s"' % config['identity_file'] - repo = git.Repo.init(git_mirror_path) + repo = git.Repo.init(git_mirror_path, initial_branch=GIT_BRANCH) enabled_remotes = [] for remote_url in servergitmirrors: @@ -480,7 +482,9 @@ def update_servergitmirrors(servergitmirrors, repo_section): logging.debug(_('Pushing to {url}').format(url=remote.url)) with repo.git.custom_environment(GIT_SSH_COMMAND=ssh_cmd): - pushinfos = remote.push('master', force=True, set_upstream=True, progress=progress) + pushinfos = remote.push( + GIT_BRANCH, force=True, set_upstream=True, progress=progress + ) for pushinfo in pushinfos: if pushinfo.flags & (git.remote.PushInfo.ERROR | git.remote.PushInfo.REJECTED @@ -691,7 +695,7 @@ def push_binary_transparency(git_repo_path, git_remote): remote_path = os.path.abspath(git_repo_path) if not os.path.isdir(os.path.join(git_remote, '.git')): os.makedirs(git_remote, exist_ok=True) - thumbdriverepo = git.Repo.init(git_remote) + thumbdriverepo = git.Repo.init(git_remote, initial_branch=GIT_BRANCH) local = thumbdriverepo.create_remote('local', remote_path) else: thumbdriverepo = git.Repo(git_remote) @@ -702,7 +706,7 @@ def push_binary_transparency(git_repo_path, git_remote): local.set_url(remote_path) else: local = thumbdriverepo.create_remote('local', remote_path) - local.pull('master') + local.pull(GIT_BRANCH) else: # from online machine to remote on a server on the internet gitrepo = git.Repo(git_repo_path) @@ -713,7 +717,7 @@ def push_binary_transparency(git_repo_path, git_remote): origin.set_url(git_remote) else: origin = gitrepo.create_remote('origin', git_remote) - origin.push('master') + origin.push(GIT_BRANCH) def main(): diff --git a/tests/run-tests b/tests/run-tests index bfdb2a8c..e076359a 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -1129,7 +1129,7 @@ echo_header "setup a new repo from scratch using ANDROID_HOME with git mirror" # fake git remote server for repo mirror SERVER_GIT_MIRROR=`create_test_dir` cd $SERVER_GIT_MIRROR -$git init +$git init --initial-branch=master $git config receive.denyCurrentBranch updateInstead REPOROOT=`create_test_dir` @@ -1191,7 +1191,7 @@ SERVERWEBROOT=`create_test_dir`/fdroid cd $OFFLINE_ROOT mkdir binary_transparency cd binary_transparency -$git init +$git init --initial-branch=master # fake git remote server for binary transparency log BINARY_TRANSPARENCY_REMOTE=`create_test_dir` @@ -1199,7 +1199,7 @@ BINARY_TRANSPARENCY_REMOTE=`create_test_dir` # fake git remote server for repo mirror SERVER_GIT_MIRROR=`create_test_dir` cd $SERVER_GIT_MIRROR -$git init +$git init --initial-branch=master $git config receive.denyCurrentBranch updateInstead cd $OFFLINE_ROOT