Skip to content

Commit

Permalink
repo.bzl: Run patch -p1 in _apply_patch on Windows
Browse files Browse the repository at this point in the history
The patch command in MSYS is version 2.7, which also supports renaming.

PiperOrigin-RevId: 254022429
  • Loading branch information
tensorflower-gardener committed Jun 19, 2019
1 parent 338c2f2 commit 87f2f24
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions third_party/repo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 87f2f24

Please sign in to comment.