comparison src/git_serve/__init__.py @ 3:189f4a0bc653

don't try to pass bytes to pathlib.Path
author Paul Fisher <paul@pfish.zone>
date Sat, 14 Feb 2026 18:53:30 -0500
parents 871dcb2a2aeb
children 5ad58438318a
comparison
equal deleted inserted replaced
2:871dcb2a2aeb 3:189f4a0bc653
1 from __future__ import annotations 1 from __future__ import annotations
2 2
3 import binascii 3 import binascii
4 import email.parser 4 import email.parser
5 import email.policy 5 import email.policy
6 import os 6 import os.path
7 import pathlib
8 import re 7 import re
9 import shutil 8 import shutil
10 import subprocess 9 import subprocess
11 import threading 10 import threading
12 import typing as t 11 import typing as t
188 187
189 def export_hook(ui: hgui.ui, repo: GittyRepo, **__: object) -> None: 188 def export_hook(ui: hgui.ui, repo: GittyRepo, **__: object) -> None:
190 never_export = ui.configbool(b'git-serve', b'never-export') 189 never_export = ui.configbool(b'git-serve', b'never-export')
191 if never_export: 190 if never_export:
192 return 191 return
193 git_repo = pathlib.Path(repo.githandler.gitdir)
194 always_export = ui.configbool(b'git-serve', b'always-export', False) 192 always_export = ui.configbool(b'git-serve', b'always-export', False)
195 if always_export or git_repo.exists(): 193 if always_export or os.path.isdir(repo.githandler.gitdir):
196 export_repo(repo) 194 export_repo(repo)
197 195
198 196
199 def export_repo(repo: GittyRepo) -> None: 197 def export_repo(repo: GittyRepo) -> None:
200 clean_all_refs(repo.githandler.git.refs) 198 clean_all_refs(repo.githandler.git.refs)
206 return hasattr(repo, 'githandler') 204 return hasattr(repo, 'githandler')
207 205
208 206
209 # Interfacing with Mercurial 207 # Interfacing with Mercurial
210 208
211 __version__ = '0.1' 209 __version__ = '0.1.1'
212 210
213 cmdtable: dict[bytes, object] = {} 211 cmdtable: dict[bytes, object] = {}
214 212
215 command = registrar.command(cmdtable) 213 command = registrar.command(cmdtable)
216 214