Class ArcanistBaseWorkflow
This class is stable: you may safely extend it.
Implements a runnable command, like "arc diff" or "arc help".
Managing Conduit
Workflows have the builtin ability to open a Conduit connection to a
Phabricator installation, so methods can be invoked over the API. Workflows
may either not need this (e.g., "help"), or may need a Conduit but not
authentication (e.g., calling only public APIs), or may need a Conduit and
authentication (e.g., "arc diff").
To specify that you need an unauthenticated conduit, override
requiresConduit() to return true. To specify that you need an
authenticated conduit, override requiresAuthentication() to
return true. You can also manually invoke establishConduit()
and/or authenticateConduit() later in a workflow to upgrade it.
Once a conduit is open, you can access the client by calling
getConduit(), which allows you to invoke methods. You can get
verified information about the user identity by calling getUserPHID()
or getUserName() after authentication occurs.
Scratch Files
Arcanist workflows can read and write 'scratch files', which are temporary
files stored in the project that persist across commands. They can be useful
if you want to save some state, or keep a copy of a long message the user
entered if something goes wrong.
Tasks
Conduit
Scratch Files
Unspecified
Methods
public this __construct()
This method is not documented.
private askForAdd()
This method is not documented.
final public this authenticateConduit()
Open and authenticate a conduit connection to a Phabricator server using
provided credentials. Normally, Arcanist does this for you automatically
when you return true from requiresAuthentication(), but you can
also upgrade an existing workflow to one with an authenticated conduit
by invoking this method manually.
You must authenticate the conduit before you can make authenticated conduit
calls (almost all calls require authentication).
This method uses credentials provided via setConduitCredentials()
to authenticate to the server:
- user (required) The username to authenticate with.
- certificate (required) The Conduit certificate to use.
- description (optional) Description of the invoking command.
Successful authentication allows you to call getUserPHID() and
getUserName(), as well as use the client you access with
getConduit() to make authenticated calls.
public buildChildWorkflow($command, array $argv)
| parameters | wild | $command | |
| array | $argv | |
| return | wild | | |
This method is not documented.
public desiresRepositoryAPI()
This method is not documented.
public desiresWorkingCopy()
This method is not documented.
protected didParseArguments()
This method is not documented.
protected dispatchEvent($type, array $data)
| parameters | wild | $type | |
| array | $data | |
| return | wild | | |
This method is not documented.
final public this establishConduit()
Open a conduit channel to the server which was previously configured by
calling setConduitURI(). Arcanist will do this automatically if
the workflow returns true from requiresConduit(), or you can
later upgrade a workflow and build a conduit by invoking it manually.
You must establish a conduit before you can make conduit calls.
public finalize()
Finalizes any cleanup operations that need to occur regardless of
whether the command succeeded or failed.
public finalizeWorkingCopy()
This method is not documented.
public this forceConduitVersion($version)
| parameters | int | $version | Version the client should pretend to be. |
| return | this | | |
Force arc to identify with a specific Conduit version during the
protocol handshake. This is primarily useful for development (especially
for sending diffs which bump the client Conduit version), since the client
still actually speaks the builtin version of the protocol.
Controlled by the --conduit-version flag.
public getArcanistConfiguration()
This method is not documented.
public getArgument($key, $default = null)
| parameters | wild | $key | |
| wild | $default | |
| return | wild | | |
This method is not documented.
public getArguments()
This method is not documented.
protected getChange($path)
| parameters | wild | $path | |
| return | wild | | |
This method is not documented.
protected list|null getChangedLines($path, $mode)
| parameters | string | $path | Path within the repository. |
| string | $mode | Change selection mode (see ArcanistDiffHunk). |
| return | list|null | | List of changed line numbers, or null to indicate that the path is not a line-oriented text file. |
Return a list of lines changed by the current diff, or null if the
change list is meaningless (for example, because the path is a directory
or binary file).
public getCommand()
This method is not documented.
public abstract string getCommandHelp()
| return | string | | 10-space indented help to use the command. |
Return console formatted string with command help printed in arc help.
public abstract string getCommandSynopses()
| return | string | | 6-space indented list of available command synopses. |
Return console formatted string with all command synopses.
final public getCompleteArgumentSpecification()
This method is not documented.
final public string getConduitURI()
Returns the URI the conduit connection within the workflow uses.
public int getConduitVersion()
| return | int | | Version the client should claim to be. |
Get the protocol version the client should identify with.
final public getConfigFromWhateverSourceAvailiable($key)
| parameters | wild | $key | |
| return | wild | | |
This method is not documented.
protected getParentWorkflow()
This method is not documented.
public getPassedArguments()
This method is not documented.
protected getPassthruArgumentsAsArgv($command)
| parameters | wild | $command | |
| return | wild | | |
This method is not documented.
protected getPassthruArgumentsAsMap($command)
| parameters | wild | $command | |
| return | wild | | |
This method is not documented.
protected getProjectInfo()
This method is not documented.
protected mixed getReadableScratchFilePath($path)
| parameters | string | $path | Scratch file name. |
| return | mixed | | String, or false on failure. |
Get a human-readable description of the scratch file location.
public getRepositoryAPI()
This method is not documented.
protected getRepositoryEncoding()
This method is not documented.
protected getRepositoryVersion()
This method is not documented.
protected mixed getScratchFilePath($path)
| parameters | string | $path | Scratch file name. |
| return | mixed | | File path, or false on failure. |
Get the path to a scratch file, if possible.
protected getShellCompletions(array $argv)
| parameters | array | $argv | |
| return | wild | | |
This method is not documented.
protected getSupportedRevisionControlSystems()
This method is not documented.
public static getSystemArcConfigLocation()
This method is not documented.
public static getUserConfigurationFileLocation()
This method is not documented.
final public getUserGUID()
final public string getUserName()
| return | string | | Authenticated username. |
Return the username for the user once they've authenticated via Conduit.
final public phid getUserPHID()
| return | phid | | Authenticated user PHID. |
Returns the PHID for the user once they've authenticated via Conduit.
public abstract string getWorkflowName()
| return | string | | The command a user types to invoke this workflow. |
Return the command used to invoke this workflow from the command like,
e.g. "help" for ArcanistHelpWorkflow.
public getWorkingCopy()
This method is not documented.
public getWorkingDirectory()
This method is not documented.
final protected bool isConduitAuthenticated()
| return | bool | | True if conduit is authenticated, false otherwise. |
This method is not documented.
protected isHistoryImmutable()
This method is not documented.
private loadBundleFromConduit(ConduitClient $conduit, $params)
| parameters | ConduitClient | $conduit | |
| wild | $params | |
| return | wild | | |
This method is not documented.
protected loadDiffBundleFromConduit(ConduitClient $conduit, $diff_id)
| parameters | ConduitClient | $conduit | |
| wild | $diff_id | |
| return | wild | | |
This method is not documented.
protected loadProjectRepository()
This method is not documented.
protected loadRevisionBundleFromConduit(ConduitClient $conduit, $revision_id)
| parameters | ConduitClient | $conduit | |
| wild | $revision_id | |
| return | wild | | |
This method is not documented.
protected newDiffParser()
This method is not documented.
protected newInteractiveEditor($text)
| parameters | wild | $text | |
| return | wild | | |
This method is not documented.
protected normalizeRevisionID($revision_id)
| parameters | wild | $revision_id | |
| return | wild | | |
This method is not documented.
public parseArguments(array $args)
| parameters | array | $args | |
| return | wild | | |
This method is not documented.
public parseBaseCommitArgument(array $argv)
| parameters | array | $argv | |
| return | wild | | |
This method is not documented.
public static readGlobalArcConfig()
This method is not documented.
public readLocalArcConfig()
This method is not documented.
protected mixed readScratchFile($path)
| parameters | string | $path | Scratch file name. |
| return | mixed | | String for file contents, or false for failure. |
Try to read a scratch file, if it exists and is readable.
protected array readScratchJSONFile($path)
| parameters | string | $path | Scratch file name. |
| return | array | | Empty array for failure. |
Try to read a scratch JSON file, if it exists and is readable.
public static readSystemArcConfig()
This method is not documented.
public static readUserConfigurationFile()
This method is not documented.
protected bool removeScratchFile($path)
| parameters | string | $path | Scratch file name to remove. |
| return | bool | | True if the file was removed successfully. |
Try to remove a scratch file.
protected renderRevisionList(array $revisions)
| parameters | array | $revisions | |
| return | wild | | |
This method is not documented.
public requireCleanWorkingCopy()
This method is not documented.
public bool requiresAuthentication()
| return | bool | | True if arc should build an authenticated conduit channel before running the workflow. |
Override this to return true if your workflow requires an authenticated
conduit channel. This implies that it requires a conduit. Arc will build
and authenticate the channel for you before the workflow executes.
public bool requiresConduit()
| return | bool | | True if arc should build a conduit channel before running the workflow. |
Override this to return true if your workflow requires a conduit channel.
Arc will build the channel for you before your workflow executes. This
implies that you only need an unauthenticated channel; if you need
authentication, override requiresAuthentication().
public requiresRepositoryAPI()
This method is not documented.
public requiresWorkingCopy()
This method is not documented.
protected resolveCall(ConduitFuture $method, $timeout = null)
| parameters | ConduitFuture | $method | |
| wild | $timeout | |
| return | wild | | |
This method is not documented.
public abstract run()
This method is not documented.
protected list selectPathsForWorkflow(array $paths, $rev, $omit_mask = null)
| parameters | list | $paths | List of explicitly provided paths. |
| string|null | $rev | Revision name, if provided. |
| mask | $omit_mask | Mask of ArcanistRepositoryAPI flags to exclude. Defaults to ArcanistRepositoryAPI::FLAG_UNTRACKED. |
| return | list | | List of paths the workflow should act on. |
Workflows like 'lint' and 'unit' operate on a list of working copy paths.
The user can either specify the paths explicitly ("a.js b.php"), or by
specfifying a revision ("--rev a3f10f1f") to select all paths modified
since that revision, or by omitting both and letting arc choose the
default relative revision.
This method takes the user's selections and returns the paths that the
workflow should act upon.
public setArcanistConfiguration(ArcanistConfiguration $arcanist_configuration)
| parameters | ArcanistConfiguration | $arcanist_configuration | |
| return | wild | | |
This method is not documented.
public setCommand($command)
| parameters | wild | $command | |
| return | wild | | |
This method is not documented.
public setCommitMode($mode)
| parameters | wild | $mode | |
| return | wild | | |
This method is not documented.
final public this setConduitCredentials(array $credentials)
Set credentials which will be used to authenticate against Conduit. These
credentials can then be used to establish an authenticated connection to
conduit by calling authenticateConduit(). Arcanist sets some
defaults for all workflows regardless of whether or not they return true
from requireAuthentication(), based on the ~/.arcrc and
.arcconf files if they are present. Thus, you can generally upgrade a
workflow which does not require authentication into an authenticated
workflow by later invoking requireAuthentication(). You should not
normally need to call this method unless you are specifically overriding
the defaults.
public this setConduitTimeout($timeout)
| parameters | float | $timeout | Timeout, in seconds. |
| return | this | | |
Override the default timeout for Conduit.
Controlled by the --conduit-timeout flag.
final public this setConduitURI($conduit_uri)
| parameters | string | $conduit_uri | The URI to open a conduit to when establishConduit() is called. |
| return | this | | |
Set the URI which the workflow will open a conduit connection to when
establishConduit() is called. Arcanist makes an effort to set
this by default for all workflows (by reading .arcconfig and/or the
value of --conduit-uri) even if they don't need Conduit, so a workflow
can generally upgrade into a conduit workflow later by just calling
establishConduit().
You generally should not need to call this method unless you are
specifically overriding the default URI. It is normally sufficient to
just invoke establishConduit().
private setParentWorkflow($parent_workflow)
| parameters | wild | $parent_workflow | |
| return | wild | | |
This method is not documented.
public setRepositoryAPI($api)
| parameters | wild | $api | |
| return | wild | | |
This method is not documented.
public setWorkingCopy(ArcanistWorkingCopyIdentity $working_copy)
| parameters | ArcanistWorkingCopyIdentity | $working_copy | |
| return | wild | | |
This method is not documented.
public setWorkingDirectory($working_directory)
| parameters | wild | $working_directory | |
| return | wild | | |
This method is not documented.
private shouldAmend()
This method is not documented.
protected shouldRequireCleanUntrackedFiles()
This method is not documented.
protected shouldShellComplete()
This method is not documented.
final public willRunWorkflow()
This method is not documented.
public static writeGlobalArcConfig(array $options)
| parameters | array | $options | |
| return | wild | | |
This method is not documented.
public writeLocalArcConfig(array $config)
| parameters | array | $config | |
| return | wild | | |
This method is not documented.
protected bool writeScratchFile($path, $data)
| parameters | string | $path | Scratch file name to write. |
| string | $data | Data to write. |
| return | bool | | True on success, false on failure. |
Try to write a scratch file, if there's somewhere to put it and we can
write there.
protected bool writeScratchJSONFile($path, array $data)
| parameters | string | $path | Scratch file name to write. |
| array | $data | Data to write. |
| return | bool | | True on success, false on failure. |
Try to write a scratch JSON file, if there's somewhere to put it and we can
write there.
protected void writeStatusMessage($msg)
| parameters | string | $msg | Message to write to stderr. |
| return | void | | |
Write a message to stderr so that '--json' flags or stdout which is meant
to be piped somewhere aren't disrupted.
public static writeUserConfigurationFile($config)
| parameters | wild | $config | |
| return | wild | | |
This method is not documented.