forked from mirrors/gecko-dev
Bug 1665445: install-moz-phab installs the Phabricator credentials r=firefox-build-system-reviewers,rstewart
Since `install-moz-phab` is meant to simplify the moz-phab setup flow, automatically prompting for Phabricator credentials removes an otherwise manual step. Detecting the "console_script" location of a package in a cross-platform, virtualenv-supporting and "--user"-supporting way is tough, and the most consistent solution seems to be to list the package contents of moz-phab and look for the one that seems to be the entry point. Differential Revision: https://phabricator.services.mozilla.com/D90642
This commit is contained in:
parent
5151d7d8a7
commit
1de0840710
3 changed files with 23 additions and 1 deletions
|
|
@ -427,7 +427,7 @@ def _finalize_telemetry_legacy(context, instance, handler, success, start_time,
|
||||||
|
|
||||||
# The user is performing a maintenance command, skip the upload
|
# The user is performing a maintenance command, skip the upload
|
||||||
if handler.name in ('bootstrap', 'doctor', 'mach-commands', 'vcs-setup',
|
if handler.name in ('bootstrap', 'doctor', 'mach-commands', 'vcs-setup',
|
||||||
'create-mach-environment',
|
'create-mach-environment', 'install-moz-phab',
|
||||||
# We call mach environment in client.mk which would cause the
|
# We call mach environment in client.mk which would cause the
|
||||||
# data submission to block the forward progress of make.
|
# data submission to block the forward progress of make.
|
||||||
'environment'):
|
'environment'):
|
||||||
|
|
|
||||||
1
mach
1
mach
|
|
@ -55,6 +55,7 @@ py2commands="
|
||||||
nativecmds="
|
nativecmds="
|
||||||
bootstrap
|
bootstrap
|
||||||
create-mach-environment
|
create-mach-environment
|
||||||
|
install-moz-phab
|
||||||
"
|
"
|
||||||
|
|
||||||
run_py() {
|
run_py() {
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ class PhabricatorCommandProvider(MachCommandBase):
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
existing = mozfile.which("moz-phab")
|
existing = mozfile.which("moz-phab")
|
||||||
if existing and not force:
|
if existing and not force:
|
||||||
|
|
@ -90,3 +91,23 @@ class PhabricatorCommandProvider(MachCommandBase):
|
||||||
|
|
||||||
self.log(logging.INFO, "run", {}, "Installing moz-phab")
|
self.log(logging.INFO, "run", {}, "Installing moz-phab")
|
||||||
subprocess.run(command)
|
subprocess.run(command)
|
||||||
|
|
||||||
|
dist = pkg_resources.get_distribution('mozphab')
|
||||||
|
|
||||||
|
# "get_metadata_lines('RECORD')" shows us all the files (paths and hashes) used by this
|
||||||
|
# package. Fetch them and strip off the hash.
|
||||||
|
package_files = [file.split(',')[0] for file in dist.get_metadata_lines('RECORD')]
|
||||||
|
potential_cli_paths = [file for file in package_files
|
||||||
|
if os.path.basename(file) in ('moz-phab.exe', 'moz-phab')]
|
||||||
|
|
||||||
|
if len(potential_cli_paths) != 1:
|
||||||
|
self.log(
|
||||||
|
logging.WARNING,
|
||||||
|
"no_mozphab_console_script",
|
||||||
|
{},
|
||||||
|
"Could not find the CLI script for moz-phab. Skipping install-certificate step."
|
||||||
|
)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
console_script = os.path.realpath(os.path.join(dist.location, potential_cli_paths[0]))
|
||||||
|
subprocess.run([console_script, 'install-certificate'])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue