Merge branch 'checkupdate' into 'master'
checkupdates: set push ref to HEAD:refs/heads/branch_name See merge request fdroid/fdroidserver!1638
This commit is contained in:
commit
0ac750463f
@ -769,6 +769,10 @@ def push_commits(branch_name='checkupdates'):
|
||||
* https://docs.gitlab.com/ee/user/project/push_options.html
|
||||
|
||||
"""
|
||||
if branch_name != "checkupdates":
|
||||
if callable(getattr(git.SymbolicReference, "_check_ref_name_valid", None)):
|
||||
git.SymbolicReference._check_ref_name_valid(branch_name)
|
||||
|
||||
git_repo = git.Repo.init('.')
|
||||
upstream_main = get_upstream_main_branch(git_repo)
|
||||
files = set()
|
||||
@ -783,6 +787,10 @@ def push_commits(branch_name='checkupdates'):
|
||||
if not files:
|
||||
return
|
||||
|
||||
# https://git-scm.com/docs/git-check-ref-format Git refname can't end with .lock
|
||||
if branch_name.endswith(".lock"):
|
||||
branch_name = f"{branch_name}_"
|
||||
|
||||
remote = git_repo.remotes.origin
|
||||
if branch_name in remote.refs:
|
||||
if not get_changes_versus_ref(git_repo, f'origin/{branch_name}', files[0]):
|
||||
@ -809,7 +817,7 @@ def push_commits(branch_name='checkupdates'):
|
||||
progress = git.RemoteProgress()
|
||||
|
||||
pushinfos = remote.push(
|
||||
f"{branch_name}:{branch_name}",
|
||||
f"HEAD:refs/heads/{branch_name}",
|
||||
progress=progress,
|
||||
force=True,
|
||||
set_upstream=True,
|
||||
|
@ -696,3 +696,12 @@ class CheckupdatesTest(unittest.TestCase):
|
||||
push.assert_called_once()
|
||||
sys_exit.assert_called_once()
|
||||
self.assertIn(appid, git_repo.heads)
|
||||
|
||||
def test_push_commits_invalid_branch_name(self):
|
||||
git_repo, origin_repo, upstream_repo = self._get_test_git_repos()
|
||||
for remote in git_repo.remotes:
|
||||
remote.push(git_repo.active_branch)
|
||||
self.assertEqual(git_repo.head, upstream_repo.head)
|
||||
self.assertEqual(origin_repo.head, upstream_repo.head)
|
||||
# pretend that checkupdates ran but didn't create any new commits
|
||||
fdroidserver.checkupdates.push_commits('')
|
||||
|
Loading…
x
Reference in New Issue
Block a user