From 4ee2c7238f61878412f482573257d4a2fdb36575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelmer=20Vernoo=C4=B3?= Date: Sat, 28 Sep 2024 14:59:17 +0100 Subject: [PATCH] git: don't assume default branch is named master --- xandikos/store/git.py | 4 ++-- xandikos/tests/test_web.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xandikos/store/git.py b/xandikos/store/git.py index 0e47743..51122c3 100644 --- a/xandikos/store/git.py +++ b/xandikos/store/git.py @@ -211,12 +211,12 @@ def __init__( self, repo, *, - ref: bytes = b"refs/heads/master", + ref: bytes = b"HEAD", check_for_duplicate_uids=True, **kwargs, ) -> None: super().__init__(MemoryIndex(), **kwargs) - self.ref = ref + self.ref = repo.refs.follow(ref)[0][-1] self.repo = repo # Maps uids to (sha, fname) self._uid_to_fname: dict[str, tuple[bytes, str]] = {} diff --git a/xandikos/tests/test_web.py b/xandikos/tests/test_web.py index 3a44319..a1f8148 100644 --- a/xandikos/tests/test_web.py +++ b/xandikos/tests/test_web.py @@ -156,7 +156,7 @@ def test_git_refs(self): self.store.import_one("foo.ics", "text/calendar", [EXAMPLE_VCALENDAR1]) app = XandikosApp(self.backend, "user") - default_branch = b"refs/heads/master" + default_branch = self.store.repo.refs.follow(b"HEAD")[0][-1] commit_hash = self.store.repo.refs[default_branch] environ = {"PATH_INFO": "/c/.git/info/refs", "REQUEST_METHOD": "GET", "QUERY_STRING": ""}