repo.bzl: Run patch -p1 in _apply_patch on Windows

The patch command in MSYS is version 2.7, which also supports renaming.

PiperOrigin-RevId: 254022429
This commit is contained in:
A. Unique TensorFlower 2019-06-19 10:26:38 -07:00 committed by TensorFlower Gardener
parent 338c2f269b
commit 87f2f24f95

11
third_party/repo.bzl vendored
View File

@ -61,12 +61,13 @@ def _repos_are_siblings():
return Label("@foo//bar").workspace_root.startswith("../") return Label("@foo//bar").workspace_root.startswith("../")
# Apply a patch_file to the repository root directory # Apply a patch_file to the repository root directory
# Runs 'git apply' # Runs 'git apply' on Unix, 'patch -p1' on Windows.
def _apply_patch(ctx, patch_file): def _apply_patch(ctx, patch_file):
cmd = _wrap_bash_cmd( if _is_windows(ctx):
ctx, patch_command = ["patch", "-p1", "-d", ctx.path("."), "-i", ctx.path(patch_file)]
["git", "apply", "-v", ctx.path(patch_file)], else:
) patch_command = ["git", "apply", "-v", ctx.path(patch_file)]
cmd = _wrap_bash_cmd(ctx, patch_command)
_execute_and_check_ret_code(ctx, cmd) _execute_and_check_ret_code(ctx, cmd)
def _apply_delete(ctx, paths): def _apply_delete(ctx, paths):