1
0
mirror of https://github.com/oskar456/dzonegit.git synced 2024-05-11 05:55:41 +00:00

Fix crash of post-receive when checkout directory does not exist

This commit is contained in:
Ondřej Caletka
2018-08-16 10:32:22 +02:00
parent 8d99e86222
commit 9923df14b7
3 changed files with 4 additions and 2 deletions

View File

@ -434,6 +434,7 @@ def post_receive(stdin=sys.stdin):
raise SystemExit("Checkout path not defined. Nothing to do.")
print("Checking out repository into {}".format(checkoutpath))
Path(checkoutpath).mkdir(parents=True, exist_ok=True)
subprocess.run(
["git", "checkout", "-f", "master"],
check=True,

View File

@ -5,7 +5,7 @@ readme = Path(__file__).with_name("README.rst").read_text()
setup(
name="dzonegit",
version="0.4",
version="0.5",
description="Git hooks to manage a repository of DNS zones",
long_description=readme,
long_description_content_type="text/x-rst",

View File

@ -280,13 +280,14 @@ def test_post_receive(git_dir):
head,
)
stdin = StringIO(revisions)
codir = git_dir.mkdir("co")
codir = git_dir.join("co")
subprocess.call(["git", "config", "dzonegit.checkoutpath", str(codir)])
subprocess.call([
"git", "config", "dzonegit.reconfigcmd",
"echo TEST >{}/test".format(codir),
])
dzonegit.post_receive(stdin)
dzonegit.post_receive(stdin) # Check coping with existing codir
assert codir.join("dummy.zone").check()
assert codir.join("test").read() == "TEST\n"