mirror of
https://github.com/oskar456/dzonegit.git
synced 2024-05-11 05:55:41 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7d693253d | ||
|
|
3777453d2f |
11
dzonegit.py
11
dzonegit.py
@@ -232,9 +232,11 @@ def check_updated_zones(against, revision=None, autoupdate_serial=False):
|
||||
|
||||
if autoupdate_serial:
|
||||
newserial = get_increased_serial(rnew.serial)
|
||||
replace_serial(f, rnew.serial, newserial)
|
||||
errmsg += " Serial has been automatically increased."
|
||||
errmsg += " Check and recommit."
|
||||
if replace_serial(f, rnew.serial, newserial):
|
||||
errmsg += " Serial has been automatically increased."
|
||||
errmsg += " Check and recommit."
|
||||
else:
|
||||
errmsg += " Autoupdate of serial number failed."
|
||||
raise HookException(
|
||||
errmsg,
|
||||
fname=f,
|
||||
@@ -277,8 +279,9 @@ def replace_serial(path, oldserial, newserial):
|
||||
flags=re.DOTALL | re.IGNORECASE | re.MULTILINE,
|
||||
)
|
||||
if count != 1:
|
||||
raise HookException("Cannot update zone serial number")
|
||||
return False
|
||||
path.write_text(updated)
|
||||
return True
|
||||
|
||||
|
||||
def get_zone_wildcards(name):
|
||||
|
||||
2
setup.py
2
setup.py
@@ -5,7 +5,7 @@ readme = Path(__file__).with_name("README.rst").read_text()
|
||||
|
||||
setup(
|
||||
name="dzonegit",
|
||||
version="0.7",
|
||||
version="0.9",
|
||||
description="Git hooks to manage a repository of DNS zones",
|
||||
long_description=readme,
|
||||
long_description_content_type="text/x-rst",
|
||||
|
||||
@@ -177,12 +177,12 @@ def test_replace_serial(git_dir):
|
||||
@ 60 IN SOA ns hm 1 61 60 60 60
|
||||
60 NS ns.example.org.
|
||||
""")
|
||||
dzonegit.replace_serial(Path("dummy.zone"), "1", "60")
|
||||
assert dzonegit.replace_serial(Path("dummy.zone"), "1", "60")
|
||||
assert git_dir.join("dummy.zone").read() == """
|
||||
@ 60 IN SOA ns hm 60 61 60 60 60
|
||||
60 NS ns.example.org.
|
||||
"""
|
||||
dzonegit.replace_serial(Path("dummy.zone"), "60", "61")
|
||||
assert dzonegit.replace_serial(Path("dummy.zone"), "60", "61")
|
||||
assert git_dir.join("dummy.zone").read() == """
|
||||
@ 60 IN SOA ns hm 61 61 60 60 60
|
||||
60 NS ns.example.org.
|
||||
@@ -197,7 +197,7 @@ def test_replace_serial(git_dir):
|
||||
)
|
||||
60 NS ns.example.org.
|
||||
""")
|
||||
dzonegit.replace_serial(Path("dummy.zone"), "60", "6000000")
|
||||
assert dzonegit.replace_serial(Path("dummy.zone"), "60", "6000000")
|
||||
assert git_dir.join("dummy.zone").read() == """
|
||||
@ 60 IN SOA ns hm (
|
||||
6000000 ; serial
|
||||
@@ -208,6 +208,7 @@ def test_replace_serial(git_dir):
|
||||
)
|
||||
60 NS ns.example.org.
|
||||
"""
|
||||
assert not dzonegit.replace_serial(Path("dummy.zone"), "0", "60")
|
||||
|
||||
|
||||
def test_check_updated_zones(git_dir):
|
||||
|
||||
Reference in New Issue
Block a user