author | Simon Fraser <sfraser@mozilla.com> |
Thu, 17 Oct 2019 13:17:29 +0000 | |
changeset 498019 | 6f1a6b95582a8426c2662c3bb5e096f5d1268c47 |
parent 498018 | 94fd033a881633b57bdd7124fdf216d304836f50 |
child 498020 | c260b3893967535faf023573fdd429fc48738778 |
push id | 36703 |
push user | ccoroiu@mozilla.com |
push date | Thu, 17 Oct 2019 21:54:25 +0000 |
treeherder | mozilla-central@c260b3893967 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jlorenzo |
bugs | 1589358 |
milestone | 71.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
|
--- a/tools/tryselect/selectors/fuzzy.py +++ b/tools/tryselect/selectors/fuzzy.py @@ -5,16 +5,17 @@ from __future__ import absolute_import, print_function, unicode_literals import os import platform import re import subprocess import sys from distutils.spawn import find_executable +from distutils.version import StrictVersion from datetime import datetime, timedelta import requests import json from mozbuild.base import MozbuildObject from mozboot.util import get_state_dir from mozterm import Terminal @@ -52,16 +53,31 @@ appropriate instructions for your platfo https://github.com/junegunn/fzf#installation Only the binary is required, if you do not wish to install the shell and editor integrations, download the appropriate binary and put it on your $PATH: https://github.com/junegunn/fzf-bin/releases """.lstrip() +FZF_VERSION_FAILED = """ +Could not obtain the 'fzf' version. + +The 'mach try fuzzy' command depends on fzf, and requires version > 0.18.0 +for some of the features. Please install it following the appropriate +instructions for your platform: + + https://github.com/junegunn/fzf#installation + +Only the binary is required, if you do not wish to install the shell and +editor integrations, download the appropriate binary and put it on your $PATH: + + https://github.com/junegunn/fzf-bin/releases +""".lstrip() + FZF_INSTALL_FAILED = """ Failed to install fzf. Please install fzf manually following the appropriate instructions for your platform: https://github.com/junegunn/fzf#installation @@ -230,16 +246,35 @@ def run_fzf_install_script(fzf_path): else: cmd = ['./install', '--bin'] if run_cmd(cmd, cwd=fzf_path): print(FZF_INSTALL_FAILED) sys.exit(1) +def should_force_fzf_update(fzf_bin): + cmd = [fzf_bin, '--version'] + try: + fzf_version = subprocess.check_output(cmd) + except subprocess.CalledProcessError: + print(FZF_VERSION_FAILED) + sys.exit(1) + + # Some fzf versions have extra, e.g 0.18.0 (ff95134) + fzf_version = fzf_version.split()[0] + + # 0.18.0 introduced FZF_PREVIEW_COLUMNS as an env variable + # in preview subprocesses, which is a feature we use. + if StrictVersion(fzf_version) < StrictVersion('0.18.0'): + print("fzf version is old, forcing update.") + return True + return False + + def fzf_bootstrap(update=False): """Bootstrap fzf if necessary and return path to the executable. The bootstrap works by cloning the fzf repository and running the included `install` script. If update is True, we will pull the repository and re-run the install script. """ fzf_bin = find_executable('fzf') @@ -260,20 +295,20 @@ def fzf_bootstrap(update=False): print("Update fzf failed.") sys.exit(1) run_fzf_install_script(fzf_path) return get_fzf() if os.path.isdir(fzf_path): fzf_bin = get_fzf() - if fzf_bin: - return fzf_bin - # Fzf is cloned, but binary doesn't exist. Try running the install script - return fzf_bootstrap(update=True) + if not fzf_bin or should_force_fzf_update(fzf_bin): + return fzf_bootstrap(update=True) + + return fzf_bin install = raw_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)