launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25656
[Merge] ~pappacena/turnip:py3-ensure-binary-oid-hex into turnip:master
Thiago F. Pappacena has proposed merging ~pappacena/turnip:py3-ensure-binary-oid-hex into turnip:master.
Commit message:
Do not assume binary OID or ref on hook.py
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~pappacena/turnip/+git/turnip/+merge/393765
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~pappacena/turnip:py3-ensure-binary-oid-hex into turnip:master.
diff --git a/turnip/pack/hooks/hook.py b/turnip/pack/hooks/hook.py
index de9aa5c..38b52a3 100755
--- a/turnip/pack/hooks/hook.py
+++ b/turnip/pack/hooks/hook.py
@@ -33,7 +33,7 @@ READONLY_REF_NAMESPACES = [
def check_ancestor(old, new):
# This is a delete, setting the new ref.
- if new == GIT_OID_HEX_ZERO:
+ if six.ensure_binary(new) == GIT_OID_HEX_ZERO:
return False
# https://git-scm.com/docs/git-merge-base#_discussion
return_code = subprocess.call(
@@ -48,10 +48,11 @@ def is_default_branch(pushed_branch):
def determine_permissions_outcome(old, ref, rule_lines):
- if any(ref.startswith(i) for i in READONLY_REF_NAMESPACES):
+ if any(six.ensure_binary(ref).startswith(i) for i in
+ READONLY_REF_NAMESPACES):
return b"%s is in a read-only namespace." % ref
rule = rule_lines.get(ref, [])
- if old == GIT_OID_HEX_ZERO:
+ if six.ensure_binary(old) == GIT_OID_HEX_ZERO:
# We are creating a new ref
if 'create' in rule:
return
@@ -96,11 +97,12 @@ def match_update_rules(rule_lines, ref_line):
the rule_lines to confirm that the user has permissions for that operation.
"""
ref, old, new = ref_line
- if any(ref.startswith(i) for i in READONLY_REF_NAMESPACES):
+ if any(six.ensure_binary(ref).startswith(i)
+ for i in READONLY_REF_NAMESPACES):
return [b"%s is in a read-only namespace." % ref]
# If it's a create, the old ref doesn't exist
- if old == GIT_OID_HEX_ZERO:
+ if six.ensure_binary(old) == GIT_OID_HEX_ZERO:
return []
# https://git-scm.com/docs/git-merge-base#_discussion