mirror of
https://github.com/oskar456/dzonegit.git
synced 2024-05-11 05:55:41 +00:00
Add allowfancynames option
This commit is contained in:
@ -63,6 +63,10 @@ named ``dzonegit``. All boolean options default to *False*.
|
||||
*dzonegit.ignorewhitespaceerrors*
|
||||
Ignore white space errors in ``pre-commit`` and ``pre-receive``/``update`` hooks.
|
||||
|
||||
*dzonegit.allowfancynames*
|
||||
In ``pre-commit`` and ``pre-receive``/``update`` hooks, do not enforce zone
|
||||
file name to be similar to the name of the zone.
|
||||
|
||||
*dzonegit.noserialupdate*
|
||||
Do not try to automatically update zone serial number if necessary.
|
||||
Valid only in the ``pre-commit`` hook.
|
||||
|
@ -173,15 +173,15 @@ def get_zone_origin(zonedata):
|
||||
def get_zone_name(path, zonedata):
|
||||
"""
|
||||
Try to guess zone name from either filename or the first $ORIGIN.
|
||||
Throw a HookException if filename and zone ORIGIN differ more than
|
||||
in slashes.
|
||||
Unless disabled, throw a HookException if filename and zone ORIGIN differ
|
||||
more than in slashes.
|
||||
"""
|
||||
stemname = Path(path).stem.lower()
|
||||
originname = get_zone_origin(zonedata)
|
||||
if originname:
|
||||
tt = str.maketrans("", "", "/_,:-+*%^&#$")
|
||||
sn, on = [s.translate(tt) for s in [stemname, originname]]
|
||||
if sn != on:
|
||||
if sn != on and not get_config("dzonegit.allowfancynames", bool):
|
||||
raise HookException(
|
||||
"Zone origin {o} differs from zone file.".format(o=originname),
|
||||
fname=path,
|
||||
|
@ -131,6 +131,8 @@ ns.example.com. 60 IN A 192.0.2.1
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
dzonegit.get_zone_name("zones/example.org.zone", testzone)
|
||||
subprocess.call(["git", "config", "dzonegit.allowfancynames", "TRUE"])
|
||||
dzonegit.get_zone_name("zones/example.org.zone", testzone)
|
||||
testzone = b"""
|
||||
$ORIGIN 240/28.2.0.192.in-addr.arpa.
|
||||
@ 60 IN SOA ns hostmaster 1 60 60 60 60
|
||||
|
Reference in New Issue
Block a user