diff --git a/recipes/recipe_modules/cipd/api.py b/recipes/recipe_modules/cipd/api.py index 27b6e84f3..4aefd0d7e 100644 --- a/recipes/recipe_modules/cipd/api.py +++ b/recipes/recipe_modules/cipd/api.py @@ -61,7 +61,9 @@ class PackageDefinition(object): def _rel_path(self, path): """Returns a forward-slash-delimited version of `path` which is relative to the package root. Will raise ValueError if path is not inside the root.""" - if path != self.package_root and not self.package_root.is_parent_of(path): + if path == self.package_root: + return '.' + if not self.package_root.is_parent_of(path): raise ValueError( 'path %r is not the package root %r and not a child thereof' % (path, self.package_root)) diff --git a/recipes/recipe_modules/cipd/example.expected/basic_pkg.json b/recipes/recipe_modules/cipd/example.expected/basic_pkg.json index d667fff88..bf2fbb70d 100644 --- a/recipes/recipe_modules/cipd/example.expected/basic_pkg.json +++ b/recipes/recipe_modules/cipd/example.expected/basic_pkg.json @@ -286,7 +286,7 @@ "cipd", "create", "-pkg-def", - "{\"data\": [{\"file\": \"a/path/to/file.py\"}, {\"file\": \"some_config.cfg\"}, {\"dir\": \"directory\", \"exclude\": []}, {\"dir\": \"other_dir\", \"exclude\": [\".*\\\\.pyc\"]}], \"install_mode\": \"\", \"package\": \"infra/fake-package\", \"root\": \"[START_DIR]/some_subdir\"}", + "{\"data\": [{\"file\": \"a/path/to/file.py\"}, {\"file\": \"some_config.cfg\"}, {\"dir\": \".\", \"exclude\": []}, {\"dir\": \"directory\", \"exclude\": []}, {\"dir\": \"other_dir\", \"exclude\": [\".*\\\\.pyc\"]}], \"install_mode\": \"\", \"package\": \"infra/fake-package\", \"root\": \"[START_DIR]/some_subdir\"}", "-json-output", "/path/to/tmp/json", "-service-account-json", diff --git a/recipes/recipe_modules/cipd/example.py b/recipes/recipe_modules/cipd/example.py index 07acdbb42..0a1abbbd1 100644 --- a/recipes/recipe_modules/cipd/example.py +++ b/recipes/recipe_modules/cipd/example.py @@ -68,6 +68,7 @@ def RunSteps(api, use_pkg, pkg_files, pkg_dirs, ver_files, install_mode): pkg = api.cipd.PackageDefinition('infra/fake-package', root, install_mode) for fullpath in pkg_files: pkg.add_file(api.path.abs_to_path(fullpath)) + pkg.add_dir(root) for obj in pkg_dirs: pkg.add_dir(api.path.abs_to_path(obj.get('path', '')), obj.get('exclusions'))