]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Fix `arc browse path:line`
authorepriestley <git@epriestley.com>
Mon, 25 Aug 2014 19:45:49 +0000 (12:45 -0700)
committerepriestley <git@epriestley.com>
Mon, 25 Aug 2014 19:45:49 +0000 (12:45 -0700)
Summary: Ref T5781. This was broken in some earlier changes in T5781.

Test Plan: Ran `arc browse README`, `arc browse README:10`.

Reviewers: chad, btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5781

Differential Revision: https://secure.phabricator.com/D10346

src/workflow/ArcanistBrowseWorkflow.php

index d80430f36c79fad76a69d46dec4620abe824c7d4..1c144cfc8da9a4ca27e7b1d8fd70aa89eea4fd07 100644 (file)
@@ -144,7 +144,13 @@ EOTEXT
       // If we fail, try to resolve them as paths.
 
       foreach ($things as $key => $path) {
-        $path = preg_replace('/:([0-9]+)$/', '$\1', $path);
+        $line = null;
+        $parts = explode(':', $path);
+        if (count($parts) > 1) {
+          $line = (int)array_pop($parts);
+        }
+        $path = implode(':', $parts);
+
         $full_path = Filesystem::resolvePath($path);
 
         if (!$is_force && !Filesystem::pathExists($full_path)) {
@@ -165,7 +171,13 @@ EOTEXT
         }
 
         $base_uri = $this->getBaseURI();
-        $uris[] = $base_uri.$path;
+        $uri = $base_uri.$path;
+
+        if ($line) {
+          $uri = $uri.'$'.$line;
+        }
+
+        $uris[] = $uri;
       }
     } else {
       if ($things) {