Skip to content

Commit

Permalink
Cherry-pick 276030@main (305fc1b). rdar://107109166
Browse files Browse the repository at this point in the history
    [hooks/pre-push] Make our pre-push hook case insensitive
    https://bugs.webkit.org/show_bug.cgi?id=254303
    rdar://107109166

    Reviewed by Aakash Jain.

    Make all our remote logic in our pre-push hook case insensitive.

    * Tools/Scripts/hooks/pre-push:
    * Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/install_hooks.py:
    (InstallHooks._security_levels):
    (InstallHooks.main):

    Canonical link: https://commits.webkit.org/276030@main

Canonical link: https://commits.webkit.org/272448.731@safari-7618-branch
  • Loading branch information
JonWBedard committed Mar 14, 2024
1 parent 9143c71 commit 2add35a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Tools/Scripts/hooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def security_level_for_remote(remote):
match = REMOTE_RE.match(remote)
if not match:
return None
return SECURITY_LEVELS.get('{}:{}'.format(match.group('host'), match.group('path')), None)
return SECURITY_LEVELS.get('{}:{}'.format(match.group('host'), match.group('path')).lower(), None)


def security_level_for_remotes(remotes, name_to_remote=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _security_levels(cls, repository):
for name, rmt in remotes_by_name.items():
match = cls.REMOTE_RE.match(rmt)
if match:
result['{}:{}'.format(match.group('host'), match.group('path'))] = levels_by_name.get(name, None)
result['{}:{}'.format(match.group('host'), match.group('path')).lower()] = levels_by_name.get(name, None)

proc = run(
[local.Git.executable(), 'config', '--get-regexp', 'remote.+url'],
Expand All @@ -122,7 +122,7 @@ def _security_levels(cls, repository):
match = cls.REMOTE_RE.match(value)
if not match:
continue
key = '{}:{}'.format(match.group('host'), match.group('path'))
key = '{}:{}'.format(match.group('host'), match.group('path')).lower()
if key in result:
continue
repo = 'https://{}/{}'.format(match.group('host'), match.group('path'))
Expand All @@ -131,7 +131,7 @@ def _security_levels(cls, repository):
parent = ((remote.GitHub(repo).request() or {}).get('parent') or {}).get('full_name')
if not parent:
continue
parent_key = '{}:{}'.format(match.group('host'), parent)
parent_key = '{}:{}'.format(match.group('host'), parent).lower()
if parent_key in result:
result[key] = result[parent_key]
return result
Expand Down Expand Up @@ -168,15 +168,15 @@ def main(cls, args, repository, hooks=None, identifier_template=None, **kwargs):
sys.stderr.write("'{}' is not a valid security level\n".format(value))
continue
value = int(value)
if key in security_levels:
exisiting_level = security_levels.get(key, None)
if key.lower() in security_levels:
exisiting_level = security_levels.get(key.lower(), None)
if exisiting_level is None:
sys.stderr.write("'{}' is already specified, but with an unknown security level\n".format(key))
if exisiting_level != value:
sys.stderr.write("'{}' already has a security level of '{}'\n".format(key, exisiting_level))
early_exit = True
continue
security_levels[key] = value
security_levels[key.lower()] = value
if early_exit:
return 1

Expand Down

0 comments on commit 2add35a

Please sign in to comment.