Bug 1642704 - Make ./mach try fuzzy --update install if fzf is not present r=ahal
authorTom Ritter <tom@mozilla.com>
Wed, 03 Jun 2020 19:14:48 +0000
changeset 533764 5e2370099c2a7b4f29b2fdb5c5d00b66157324e8
parent 533763 becb52cac8b505e27e1a1f1f42a33b97aa8f49f2
child 533765 51c8ee88801eb4aa552c691213af035f6816b86f
push id37477
push userdluca@mozilla.com
push dateThu, 04 Jun 2020 04:19:27 +0000
treeherdermozilla-central@6fd265574f27 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1642704
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1642704 - Make ./mach try fuzzy --update install if fzf is not present r=ahal Differential Revision: https://phabricator.services.mozilla.com/D77856
tools/tryselect/selectors/fuzzy.py
--- a/tools/tryselect/selectors/fuzzy.py
+++ b/tools/tryselect/selectors/fuzzy.py
@@ -219,35 +219,36 @@ def fzf_bootstrap(update=False):
     # Swap to os.path.commonpath when we're not on Py2
     if fzf_bin and update and not fzf_bin.startswith(fzf_path):
         print("fzf installed somewhere other than {}, please update manually".format(fzf_path))
         sys.exit(1)
 
     def get_fzf():
         return find_executable('fzf', os.path.join(fzf_path, 'bin'))
 
-    if update:
-        ret = run_cmd(['git', 'pull'], cwd=fzf_path)
-        if ret:
-            print("Update fzf failed.")
-            sys.exit(1)
+    if os.path.isdir(fzf_path):
+        if update:
+            ret = run_cmd(['git', 'pull'], cwd=fzf_path)
+            if ret:
+                print("Update fzf failed.")
+                sys.exit(1)
 
-        run_fzf_install_script(fzf_path)
-        return get_fzf()
+            run_fzf_install_script(fzf_path)
+            return get_fzf()
 
-    if os.path.isdir(fzf_path):
         fzf_bin = get_fzf()
         if not fzf_bin or should_force_fzf_update(fzf_bin):
             return fzf_bootstrap(update=True)
 
         return fzf_bin
 
-    install = input("Could not detect fzf, install it now? [y/n]: ")
-    if install.lower() != 'y':
-        return
+    if not update:
+        install = input("Could not detect fzf, install it now? [y/n]: ")
+        if install.lower() != 'y':
+            return
 
     if not find_executable('git'):
         print("Git not found.")
         print(FZF_INSTALL_FAILED)
         sys.exit(1)
 
     cmd = ['git', 'clone', '--depth', '1', 'https://github.com/junegunn/fzf.git']
     if subprocess.call(cmd, cwd=os.path.dirname(fzf_path)):