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

Revert "Add Experimental filters for smudging/cleaning the SOA serial"

This reverts commit 331df2a4ec.
Increasing serial during the cleaning phase does not work as expected.
Maybe the way is to smudge serial to current unix time during checkout
on the server.
This commit is contained in:
Ondřej Caletka
2018-08-15 13:01:15 +02:00
parent 27ae5ff210
commit b608c25372
3 changed files with 0 additions and 73 deletions

View File

@ -14,9 +14,6 @@ from pathlib import Path
from string import Template
SERIAL_SMUDGE_TAG = "DZONEGIT_DO_NOT_CHANGE_OLD_SERIAL_"
class HookException(ValueError):
"""Exception raised when there is an error in input data.
@ -496,32 +493,3 @@ def post_receive(stdin=sys.stdin):
cmd.append(z)
print("Calling {}".format(" ".join(cmd)))
subprocess.run(cmd)
def clean_serial(stdin=sys.stdin):
""" Git filter command to replace smudged serial with an increased one. """
for line in stdin:
m = re.search(
r"(\s){}([0-9]+)(\s)".format(SERIAL_SMUDGE_TAG),
line,
)
if m:
oldserial = m.group(2)
newserial = get_increased_serial(oldserial)
line = line.replace(SERIAL_SMUDGE_TAG + oldserial, newserial)
print(line, end="")
def smudge_serial(stdin=sys.stdin):
""" Git filter command to smudge SOA serial number. """
sys.stderr.write("Smudging {}\n".format(sys.argv))
zonedata = stdin.read()
if SERIAL_SMUDGE_TAG not in zonedata:
zonedata = re.sub(
r'(^.*\sSOA\s.+?\s)([0-9]+[^0-9])',
r'\g<1>{}\g<2>'.format(SERIAL_SMUDGE_TAG),
zonedata,
count=1,
flags=re.DOTALL | re.IGNORECASE | re.MULTILINE,
)
print(zonedata, end="")

View File

@ -23,8 +23,6 @@ setup(
"dzonegit-pre-receive = dzonegit:pre_receive",
"dzonegit-post-receive = dzonegit:post_receive",
"dzonegit-update = dzonegit:update",
"dzonegit-smudge-serial = dzonegit:smudge_serial",
"dzonegit-clean-serial = dzonegit:clean_serial",
],
},
classifiers=[

View File

@ -332,42 +332,3 @@ def test_get_zone_wildcards():
"a.long.zone.name", "*.long.zone.name",
"*.zone.name", "*.name", "*",
]
def test_smudge_serial(capsys):
stdin = StringIO("""
@ 60 IN SOA ns hm (
60 ; serial
60 ; refresh
60 ; retry
60 ; expire
60 ; minimum
)
60 NS ns.example.org.
""")
dzonegit.smudge_serial(stdin)
stdout = capsys.readouterr().out
assert "{}60 ; serial".format(dzonegit.SERIAL_SMUDGE_TAG) in stdout
stdin = StringIO(stdout)
dzonegit.smudge_serial(stdin)
assert stdout == capsys.readouterr().out
def test_clean_serial(capsys):
stdin = StringIO("""
@ 60 IN SOA ns hm (
{}60 ; serial
60 ; refresh
60 ; retry
60 ; expire
60 ; minimum
)
60 NS ns.example.org.
""".format(dzonegit.SERIAL_SMUDGE_TAG))
dzonegit.clean_serial(stdin)
stdout = capsys.readouterr().out
assert " 61 ; serial" in stdout
stdin = StringIO(stdout)
dzonegit.clean_serial(stdin)
assert stdout == capsys.readouterr().out