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:
@ -434,6 +434,7 @@ def post_receive(stdin=sys.stdin):
|
|||||||
raise SystemExit("Checkout path not defined. Nothing to do.")
|
raise SystemExit("Checkout path not defined. Nothing to do.")
|
||||||
|
|
||||||
print("Checking out repository into {}…".format(checkoutpath))
|
print("Checking out repository into {}…".format(checkoutpath))
|
||||||
|
Path(checkoutpath).mkdir(parents=True, exist_ok=True)
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["git", "checkout", "-f", "master"],
|
["git", "checkout", "-f", "master"],
|
||||||
check=True,
|
check=True,
|
||||||
|
2
setup.py
2
setup.py
@ -5,7 +5,7 @@ readme = Path(__file__).with_name("README.rst").read_text()
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="dzonegit",
|
name="dzonegit",
|
||||||
version="0.4",
|
version="0.5",
|
||||||
description="Git hooks to manage a repository of DNS zones",
|
description="Git hooks to manage a repository of DNS zones",
|
||||||
long_description=readme,
|
long_description=readme,
|
||||||
long_description_content_type="text/x-rst",
|
long_description_content_type="text/x-rst",
|
||||||
|
@ -280,13 +280,14 @@ def test_post_receive(git_dir):
|
|||||||
head,
|
head,
|
||||||
)
|
)
|
||||||
stdin = StringIO(revisions)
|
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.checkoutpath", str(codir)])
|
||||||
subprocess.call([
|
subprocess.call([
|
||||||
"git", "config", "dzonegit.reconfigcmd",
|
"git", "config", "dzonegit.reconfigcmd",
|
||||||
"echo TEST >{}/test".format(codir),
|
"echo TEST >{}/test".format(codir),
|
||||||
])
|
])
|
||||||
dzonegit.post_receive(stdin)
|
dzonegit.post_receive(stdin)
|
||||||
|
dzonegit.post_receive(stdin) # Check coping with existing codir
|
||||||
assert codir.join("dummy.zone").check()
|
assert codir.join("dummy.zone").check()
|
||||||
assert codir.join("test").read() == "TEST\n"
|
assert codir.join("test").read() == "TEST\n"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user