From 18bce221976611340f2b51f200663a50f534b9fb Mon Sep 17 00:00:00 2001
From: Robert Iannucci <iannucci@chromium.org>
Date: Wed, 1 Mar 2017 15:43:17 -0800
Subject: [PATCH] [cipd] use "cipd" so recipe engine can find .bat on windows.

BUG=697327

Change-Id: Ie220a09f243da08a24520203b622197be27a396b
Reviewed-on: https://chromium-review.googlesource.com/448658
Reviewed-by: Vadim Shtayura <vadimsh@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
---
 recipe_modules/cipd/api.py                    | 32 +++++++------------
 .../cipd/example.expected/win64.json          | 26 +++++++--------
 2 files changed, 24 insertions(+), 34 deletions(-)

diff --git a/recipe_modules/cipd/api.py b/recipe_modules/cipd/api.py
index b5940eec2..392debeb9 100644
--- a/recipe_modules/cipd/api.py
+++ b/recipe_modules/cipd/api.py
@@ -8,24 +8,14 @@ from recipe_engine import recipe_api
 class CIPDApi(recipe_api.RecipeApi):
   """CIPDApi provides basic support for CIPD.
 
-  This assumes that `cipd` (or `cipd.exe` on windows) has been installed
-  somewhere in $PATH. This will be true if you use depot_tools, or if your
-  recipe is running inside of chrome-infrastructure's systems (buildbot,
+  This assumes that `cipd` (or `cipd.exe` or `cipd.bat` on windows) has been
+  installed somewhere in $PATH. This will be true if you use depot_tools, or if
+  your recipe is running inside of chrome-infrastructure's systems (buildbot,
   swarming).
   """
   def __init__(self, *args, **kwargs):
     super(CIPDApi, self).__init__(*args, **kwargs)
     self._cipd_credentials = None
-    self._executable = None
-
-  def initialize(self):
-    self._executable = 'cipd'
-    if self.m.platform.is_win:
-      self._executable += '.exe'
-
-  @property
-  def executable(self):
-    return self._executable
 
   def set_service_account_credentials(self, path):
     self._cipd_credentials = path
@@ -59,7 +49,7 @@ class CIPDApi(recipe_api.RecipeApi):
     return self.m.step(
         'build %s' % self.m.path.basename(package_name),
         [
-          self.executable,
+          'cipd',
           'pkg-build',
           '-in', input_dir,
           '-name', package_name,
@@ -73,7 +63,7 @@ class CIPDApi(recipe_api.RecipeApi):
 
   def register(self, package_name, package_path, refs=None, tags=None):
     cmd = [
-      self.executable,
+      'cipd',
       'pkg-register', package_path,
       '-json-output', self.m.json.output(),
     ]
@@ -97,7 +87,7 @@ class CIPDApi(recipe_api.RecipeApi):
     This builds and uploads the package in one step.
     """
     cmd = [
-      self.executable,
+      'cipd',
       'create',
       '-pkg-def', pkg_def,
       '-json-output', self.m.json.output(),
@@ -126,7 +116,7 @@ class CIPDApi(recipe_api.RecipeApi):
                     for name, version in sorted(packages.items())]
     ensure_file = self.m.raw_io.input('\n'.join(package_list))
     cmd = [
-      self.executable,
+      'cipd',
       'ensure',
       '-root', root,
       '-ensure-file', ensure_file,
@@ -141,7 +131,7 @@ class CIPDApi(recipe_api.RecipeApi):
 
   def set_tag(self, package_name, version, tags):
     cmd = [
-      self.executable,
+      'cipd',
       'set-tag', package_name,
       '-version', version,
       '-json-output', self.m.json.output(),
@@ -161,7 +151,7 @@ class CIPDApi(recipe_api.RecipeApi):
 
   def set_ref(self, package_name, version, refs):
     cmd = [
-      self.executable,
+      'cipd',
       'set-ref', package_name,
       '-version', version,
       '-json-output', self.m.json.output(),
@@ -183,7 +173,7 @@ class CIPDApi(recipe_api.RecipeApi):
     assert ':' in tag, 'tag must be in a form "k:v"'
 
     cmd = [
-      self.executable,
+      'cipd',
       'search', package_name,
       '-tag', tag,
       '-json-output', self.m.json.output(),
@@ -200,7 +190,7 @@ class CIPDApi(recipe_api.RecipeApi):
   def describe(self, package_name, version,
                test_data_refs=None, test_data_tags=None):
     cmd = [
-      self.executable,
+      'cipd',
       'describe', package_name,
       '-version', version,
       '-json-output', self.m.json.output(),
diff --git a/recipe_modules/cipd/example.expected/win64.json b/recipe_modules/cipd/example.expected/win64.json
index 0687892fd..b5bea284d 100644
--- a/recipe_modules/cipd/example.expected/win64.json
+++ b/recipe_modules/cipd/example.expected/win64.json
@@ -1,7 +1,7 @@
 [
   {
     "cmd": [
-      "cipd.exe",
+      "cipd",
       "ensure",
       "-root",
       "[START_DIR]\\packages",
@@ -27,7 +27,7 @@
   },
   {
     "cmd": [
-      "cipd.exe",
+      "cipd",
       "search",
       "public/package/windows-amd64",
       "-tag",
@@ -52,7 +52,7 @@
   },
   {
     "cmd": [
-      "cipd.exe",
+      "cipd",
       "describe",
       "public/package/windows-amd64",
       "-version",
@@ -103,7 +103,7 @@
   },
   {
     "cmd": [
-      "cipd.exe",
+      "cipd",
       "ensure",
       "-root",
       "[START_DIR]\\packages",
@@ -133,7 +133,7 @@
   },
   {
     "cmd": [
-      "cipd.exe",
+      "cipd",
       "search",
       "private/package/windows-amd64",
       "-tag",
@@ -158,7 +158,7 @@
   },
   {
     "cmd": [
-      "cipd.exe",
+      "cipd",
       "describe",
       "private/package/windows-amd64",
       "-version",
@@ -204,7 +204,7 @@
   },
   {
     "cmd": [
-      "cipd.exe",
+      "cipd",
       "pkg-build",
       "-in",
       "fake-input-dir",
@@ -228,7 +228,7 @@
   },
   {
     "cmd": [
-      "cipd.exe",
+      "cipd",
       "pkg-build",
       "-in",
       "fake-input-dir",
@@ -254,7 +254,7 @@
   },
   {
     "cmd": [
-      "cipd.exe",
+      "cipd",
       "pkg-register",
       "fake-package-path",
       "-json-output",
@@ -283,7 +283,7 @@
   },
   {
     "cmd": [
-      "cipd.exe",
+      "cipd",
       "create",
       "-pkg-def",
       "[START_DIR]\\fake-package.yaml",
@@ -308,7 +308,7 @@
   },
   {
     "cmd": [
-      "cipd.exe",
+      "cipd",
       "set-tag",
       "fake-package",
       "-version",
@@ -338,7 +338,7 @@
   },
   {
     "cmd": [
-      "cipd.exe",
+      "cipd",
       "set-ref",
       "fake-package",
       "-version",
@@ -368,7 +368,7 @@
   },
   {
     "cmd": [
-      "cipd.exe",
+      "cipd",
       "search",
       "fake-package/windows-amd64",
       "-tag",