mirror of
https://github.com/oskar456/dzonegit.git
synced 2024-05-11 05:55:41 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7d693253d | ||
|
|
3777453d2f | ||
|
|
023906177a | ||
|
|
e79bb901f3 | ||
|
|
f07c84aa32 |
10
README.rst
10
README.rst
@@ -59,24 +59,22 @@ Support for $UNIXTIME directive
|
||||
|
||||
If you want to use ``$UNIXTIME`` in your zone files instead of serial number,
|
||||
you have to install a `smudge` filter on the server, that will replace the
|
||||
directive with current unix time on checkout. First, set up the filter in
|
||||
the Git configuration:
|
||||
directive with current unix time on every checkout. First, set up the filter
|
||||
in the Git configuration:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
$ git config --global filter.dzonegit.smudge $(which dzonegit-smudge-serial)
|
||||
$ git config --global filter.dzonegit.clean cat
|
||||
|
||||
|
||||
Then, apply the filter on all zone files using ``.gitattributes`` file inside
|
||||
the repository:
|
||||
Then, apply the filter on all zone files using either ``.git/info/attributes``
|
||||
or directly ``.gitattributes`` file inside the repository:
|
||||
|
||||
.. code-block::
|
||||
|
||||
*.zone filter=dzonegit
|
||||
|
||||
|
||||
|
||||
Configuration options
|
||||
---------------------
|
||||
|
||||
|
||||
14
dzonegit.py
14
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):
|
||||
@@ -479,7 +482,8 @@ def post_receive(stdin=sys.stdin):
|
||||
if refname != "refs/heads/master":
|
||||
continue
|
||||
if against == "0000000000000000000000000000000000000000":
|
||||
against = get_head() # Empty commit
|
||||
# Empty commit
|
||||
against = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
|
||||
should_reconfig = [
|
||||
f for f in get_altered_files(against, "ACDRU", revision)
|
||||
if f.suffix == ".zone"
|
||||
|
||||
2
setup.py
2
setup.py
@@ -5,7 +5,7 @@ readme = Path(__file__).with_name("README.rst").read_text()
|
||||
|
||||
setup(
|
||||
name="dzonegit",
|
||||
version="0.6",
|
||||
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):
|
||||
@@ -328,7 +329,7 @@ def test_post_receive(git_dir):
|
||||
git_dir.chdir()
|
||||
head = dzonegit.get_head()
|
||||
revisions = "{} {} refs/heads/master\n".format(
|
||||
"4b825dc642cb6eb9a060e54bf8d69288fbee4904",
|
||||
"0000000000000000000000000000000000000000",
|
||||
head,
|
||||
)
|
||||
stdin = StringIO(revisions)
|
||||
|
||||
Reference in New Issue
Block a user