aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Vlad Losev <vladlosev@users.noreply.github.com>2017-02-16 14:45:08 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2017-02-16 16:57:42 +0000
commitdf23e2f2512c45143d113a3b3101afc8a4fa4e83 (patch)
treee93d998c5915c1844fc3b242bcf9f97b9576d028 /tools
parent97b6af8d71bf54bfa62f18e90a458394da76087a (diff)
Fixes directory path computation in docker_build
This fixes #1178. When a docker_build rule has a `files` input that is at the root of the repository, it contains no / characters, and the current version of `_short_path_dirname` returns the last character of the name instead of an empty string. Closes #2529. -- Reviewed-on: https://github.com/bazelbuild/bazel/pull/2529 PiperOrigin-RevId: 147714720 MOS_MIGRATED_REVID=147714720
Diffstat (limited to 'tools')
-rw-r--r--tools/build_defs/docker/docker.bzl6
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/build_defs/docker/docker.bzl b/tools/build_defs/docker/docker.bzl
index 17773ba6d5..03a5805439 100644
--- a/tools/build_defs/docker/docker.bzl
+++ b/tools/build_defs/docker/docker.bzl
@@ -53,7 +53,11 @@ def _validate_command(name, argument):
def _short_path_dirname(path):
"""Returns the directory's name of the short path of an artifact."""
sp = path.short_path
- return sp[:sp.rfind("/")]
+ last_sep = sp.rfind("/")
+ if last_sep == -1:
+ return "" # The artifact is at the top level.
+
+ return sp[:last_sep]
def _dest_path(f, strip_prefix):
"""Returns the short path of f, stripped of strip_prefix."""