Skip to content

Commit de87d99

Browse files
j-piaseckimeta-codesync[bot]
authored andcommitted
Fix repo root resolution (facebook#55648)
Summary: Pull Request resolved: facebook#55648 Changelog: [Internal] Updates the repository root resolution of the C++ api generation script. Reviewed By: cortinico Differential Revision: D93857297 fbshipit-source-id: 4c40ec2178807ddc5cae724c4233e2d029541031
1 parent 03c1399 commit de87d99

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

scripts/cxx-api/parser/path_utils.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,22 @@
88

99

1010
def get_repo_root() -> str:
11-
"""Get the repository root via git."""
12-
result = subprocess.run(
13-
["git", "rev-parse", "--show-toplevel"],
14-
capture_output=True,
15-
text=True,
16-
)
17-
if result.returncode != 0:
18-
raise RuntimeError(
19-
f"Could not determine repo root via 'git rev-parse': {result.stderr}"
20-
)
21-
return result.stdout.strip()
11+
"""Get the repository root directory.
12+
13+
Tries sl (Meta) first, then git (OSS).
14+
"""
15+
for cmd in [["sl", "root"], ["git", "rev-parse", "--show-toplevel"]]:
16+
try:
17+
result = subprocess.run(
18+
cmd,
19+
capture_output=True,
20+
text=True,
21+
)
22+
if result.returncode == 0:
23+
return result.stdout.strip()
24+
except FileNotFoundError:
25+
continue
26+
raise RuntimeError("Could not determine repo root via 'sl root' or 'git rev-parse'")
2227

2328

2429
def get_react_native_dir() -> str:

0 commit comments

Comments
 (0)