From 87f2f24f957abb76ad80e16b26b7221ddd277752 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 19 Jun 2019 10:26:38 -0700 Subject: [PATCH] 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 --- third_party/repo.bzl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/third_party/repo.bzl b/third_party/repo.bzl index 4ab132c39f4..4fc91afb36c 100644 --- a/third_party/repo.bzl +++ b/third_party/repo.bzl @@ -61,12 +61,13 @@ def _repos_are_siblings(): return Label("@foo//bar").workspace_root.startswith("../") # 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): - cmd = _wrap_bash_cmd( - ctx, - ["git", "apply", "-v", ctx.path(patch_file)], - ) + if _is_windows(ctx): + patch_command = ["patch", "-p1", "-d", ctx.path("."), "-i", 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) def _apply_delete(ctx, paths):