Skip to content
Permalink
Browse files
[GitHub] git-webkit pr doesn't sort Xcode project files before uploading
https://bugs.webkit.org/show_bug.cgi?id=239975
<rdar://92976140>

Reviewed by Chris Dumez.

* Tools/Scripts/hooks/pre-commit: Sort Xcode project files on commit.

Canonical link: https://commits.webkit.org/250916@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294748 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
JonWBedard committed May 24, 2022
1 parent 74f9635 commit 24f50e76fd6af39ebca44f8d3b2ff6c754e07bbf
Showing 1 changed file with 38 additions and 0 deletions.
@@ -0,0 +1,38 @@
#!/usr/bin/env {{ python }}

import os
import subprocess
import sys

LOCATION = '{{ location }}'
SCRIPTS = os.path.dirname(os.path.dirname(LOCATION))


def files(staged=True):
try:
lines = []
for line in subprocess.check_output(
['{{ git }}', 'diff', '--name-only'] + (['--staged'] if staged else []),
encoding='utf-8',
).splitlines():
if line:
lines.append(line)
return lines
except subprocess.CalledProcessError:
return []


staged = files(staged=True)
unstaged = files(staged=False)

project_files = []
for line in staged or unstaged:
if line.endswith('pbxproj'):
project_files.append(line)

if project_files:
code = subprocess.run([os.path.join(SCRIPTS, 'sort-Xcode-project-file')] + project_files).returncode
if staged:
code += subprocess.run(['{{ git }}', 'add'] + project_files).returncode
sys.exit(code)
sys.exit(0)

0 comments on commit 24f50e7

Please sign in to comment.