Fix repo root resolution (#55648)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55648

Changelog: [Internal]

Updates the repository root resolution of the C++ api generation script.

Reviewed By: cortinico

Differential Revision: D93857297

fbshipit-source-id: 4c40ec2178807ddc5cae724c4233e2d029541031
This commit is contained in:
Jakub Piasecki
2026-02-25 11:16:36 -08:00
committed by meta-codesync[bot]
parent 03c1399163
commit de87d9989f
+16 -11
View File
@@ -8,17 +8,22 @@ import subprocess
def get_repo_root() -> str:
"""Get the repository root via git."""
result = subprocess.run(
["git", "rev-parse", "--show-toplevel"],
capture_output=True,
text=True,
)
if result.returncode != 0:
raise RuntimeError(
f"Could not determine repo root via 'git rev-parse': {result.stderr}"
)
return result.stdout.strip()
"""Get the repository root directory.
Tries sl (Meta) first, then git (OSS).
"""
for cmd in [["sl", "root"], ["git", "rev-parse", "--show-toplevel"]]:
try:
result = subprocess.run(
cmd,
capture_output=True,
text=True,
)
if result.returncode == 0:
return result.stdout.strip()
except FileNotFoundError:
continue
raise RuntimeError("Could not determine repo root via 'sl root' or 'git rev-parse'")
def get_react_native_dir() -> str: