Skip to content

Commit cefdfb0

Browse files
afrindmeta-codesync[bot]
authored andcommitted
Fix getdeps patch application
Summary: Apply patches from the git repo root so paths resolve correctly even when src_dir is a subdirectory of the repo (e.g. fizz, wangle). Without this, patches with paths relative to the repo root fail to apply. Reviewed By: bigfootjon Differential Revision: D93644294 fbshipit-source-id: 5e0006eb988eb4cdc6f0ecb0dae8cb35b7189c5d
1 parent 979ed64 commit cefdfb0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

build/fbcode_builder/getdeps/builder.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,16 @@ def _apply_patchfile(self) -> None:
137137
return
138138
old_wd = os.getcwd()
139139
os.chdir(self.src_dir)
140-
print(f"Patching {self.manifest.name} with {self.patchfile} in {self.src_dir}")
140+
# Apply patches from the git repo root so paths resolve correctly
141+
# even when src_dir is a subdirectory of the repo.
142+
try:
143+
git_root = subprocess.check_output(
144+
["git", "rev-parse", "--show-toplevel"], text=True
145+
).strip()
146+
os.chdir(git_root)
147+
except subprocess.CalledProcessError:
148+
pass # not a git repo, stay in src_dir
149+
print(f"Patching {self.manifest.name} with {self.patchfile} in {os.getcwd()}")
141150
patchfile = os.path.join(
142151
self.build_opts.fbcode_builder_dir, "patches", self.patchfile
143152
)

0 commit comments

Comments
 (0)