Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15331993
D21202.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D21202.diff
View Options
diff --git a/src/browse/workflow/ArcanistBrowseWorkflow.php b/src/browse/workflow/ArcanistBrowseWorkflow.php
--- a/src/browse/workflow/ArcanistBrowseWorkflow.php
+++ b/src/browse/workflow/ArcanistBrowseWorkflow.php
@@ -234,21 +234,8 @@
$ref_uri = head($ref_uris);
- // TODO: "ArcanistRevisionRef", at least, may return a relative URI.
- // If we get a relative URI, guess the correct absolute URI based on
- // the Conduit URI. This might not be correct for Conduit over SSH.
-
$raw_uri = $ref_uri->getURI();
-
- $raw_uri = new PhutilURI($raw_uri);
- if (!strlen($raw_uri->getDomain())) {
- $base_uri = $this->getConduitEngine()
- ->getConduitURI();
-
- $raw_uri = id(new PhutilURI($base_uri))
- ->setPath($raw_uri->getPath());
- }
- $raw_uri = phutil_string_cast($raw_uri);
+ $raw_uri = $this->getAbsoluteURI($raw_uri);
$uris[] = $raw_uri;
}
diff --git a/src/ref/file/ArcanistFileRef.php b/src/ref/file/ArcanistFileRef.php
--- a/src/ref/file/ArcanistFileRef.php
+++ b/src/ref/file/ArcanistFileRef.php
@@ -37,6 +37,16 @@
return idxv($this->parameters, array('fields', 'size'));
}
+ public function getURI() {
+ $uri = idxv($this->parameters, array('fields', 'uri'));
+
+ if ($uri === null) {
+ $uri = '/'.$this->getMonogram();
+ }
+
+ return $uri;
+ }
+
public function getMonogram() {
return 'F'.$this->getID();
}
diff --git a/src/workflow/ArcanistUploadWorkflow.php b/src/workflow/ArcanistUploadWorkflow.php
--- a/src/workflow/ArcanistUploadWorkflow.php
+++ b/src/workflow/ArcanistUploadWorkflow.php
@@ -23,6 +23,10 @@
return array(
$this->newWorkflowArgument('json')
->setHelp(pht('Output upload information in JSON format.')),
+ $this->newWorkflowArgument('browse')
+ ->setHelp(
+ pht(
+ 'After the upload completes, open the files in a web browser.')),
$this->newWorkflowArgument('temporary')
->setHelp(
pht(
@@ -42,6 +46,7 @@
$is_temporary = $this->getArgument('temporary');
$is_json = $this->getArgument('json');
+ $is_browse = $this->getArgument('browse');
$paths = $this->getArgument('paths');
$conduit = $this->getConduitEngine();
@@ -65,35 +70,68 @@
$files = $uploader->uploadFiles();
- $results = array();
+ $phids = array();
foreach ($files as $file) {
- // TODO: This could be handled more gracefully; just preserving behavior
- // until we introduce `file.query` and modernize this.
+ // TODO: This could be handled more gracefully.
if ($file->getErrors()) {
throw new Exception(implode("\n", $file->getErrors()));
}
- $phid = $file->getPHID();
- $name = $file->getName();
-
- $info = $conduit->resolveCall(
- 'file.info',
- array(
- 'phid' => $phid,
- ));
+ $phids[] = $file->getPHID();
+ }
- $results[$path] = $info;
+ $symbols = $this->getSymbolEngine();
+ $symbol_refs = $symbols->loadFilesForSymbols($phids);
- if (!$is_json) {
- $id = $info['id'];
- echo " F{$id} {$name}: ".$info['uri']."\n\n";
+ $refs = array();
+ foreach ($symbol_refs as $symbol_ref) {
+ $ref = $symbol_ref->getObject();
+ if ($ref === null) {
+ throw new Exception(
+ pht(
+ 'Failed to resolve symbol ref "%s".',
+ $symbol_ref->getSymbol()));
}
+ $refs[] = $ref;
}
if ($is_json) {
- $output = id(new PhutilJSON())->encodeFormatted($results);
- echo $output;
+ $json = array();
+
+ foreach ($refs as $key => $ref) {
+ $uri = $ref->getURI();
+ $uri = $this->getAbsoluteURI($uri);
+
+ $map = array(
+ 'argument' => $paths[$key],
+ 'id' => $ref->getID(),
+ 'phid' => $ref->getPHID(),
+ 'name' => $ref->getName(),
+ 'uri' => $uri,
+ );
+
+ $json[] = $map;
+ }
+
+ echo id(new PhutilJSON())->encodeAsList($json);
} else {
- $this->writeStatus(pht('Done.'));
+ foreach ($refs as $ref) {
+ $uri = $ref->getURI();
+ $uri = $this->getAbsoluteURI($uri);
+ echo tsprintf(
+ '%s',
+ $ref->newDisplayRef()
+ ->setURI($uri));
+ }
+ }
+
+ if ($is_browse) {
+ $uris = array();
+ foreach ($refs as $ref) {
+ $uri = $ref->getURI();
+ $uri = $this->getAbsoluteURI($uri);
+ $uris[] = $uri;
+ }
+ $this->openURIsInBrowser($uris);
}
return 0;
diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php
--- a/src/workflow/ArcanistWorkflow.php
+++ b/src/workflow/ArcanistWorkflow.php
@@ -2421,4 +2421,23 @@
return $stdin->read();
}
+ protected function getAbsoluteURI($raw_uri) {
+ // TODO: "ArcanistRevisionRef", at least, may return a relative URI.
+ // If we get a relative URI, guess the correct absolute URI based on
+ // the Conduit URI. This might not be correct for Conduit over SSH.
+
+ $raw_uri = new PhutilURI($raw_uri);
+ if (!strlen($raw_uri->getDomain())) {
+ $base_uri = $this->getConduitEngine()
+ ->getConduitURI();
+
+ $raw_uri = id(new PhutilURI($base_uri))
+ ->setPath($raw_uri->getPath());
+ }
+
+ $raw_uri = phutil_string_cast($raw_uri);
+
+ return $raw_uri;
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 8, 3:51 PM (3 d, 15 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7383088
Default Alt Text
D21202.diff (5 KB)
Attached To
Mode
D21202: Add "--browse" to "arc upload" and update behavior, particularly "--json"
Attached
Detach File
Event Timeline
Log In to Comment