Page MenuHomePhorge

Locate File: allow to search './path/to/something.txt'
ClosedPublic

Authored by valerio.bozzolan on Jul 1 2023, 00:49.
Tags
None
Referenced Files
F4118010: D25320.1747009929.diff
Sun, May 11, 00:32
F4034150: D25320.1746717185.diff
Wed, May 7, 15:13
F3979442: D25320.1746537457.diff
Mon, May 5, 13:17
F3979441: D25320.1746537438.diff
Mon, May 5, 13:17
F3979439: D25320.1746537403.diff
Mon, May 5, 13:16
F3979437: D25320.1746537348.diff
Mon, May 5, 13:15
F3946037: D25320.1746446126.diff
Sun, May 4, 11:55
F3850709: D25320.1746115732.diff
Wed, Apr 30, 16:08

Details

Summary

Before this change, if you search a file using Locate File,
this was the only accepted syntax for a full-path:

path/to/something.txt

After this change, some relative/absolute Unix-like variants
are also accepted:

./path/to/something.txt
/path/to/something.txt

Similar prefixes can be frequent when you quickly copy-paste things
from shell commands like 'grep' or 'find' etc.

Ref T15508

Test Plan

Visit a lovely repository like Phorge and use Locate File with these:

  1. src/applications/maniphest/editor/ManiphestEditEngine.php
  2. /src/applications/maniphest/editor/ManiphestEditEngine.php
  3. ./src/applications/maniphest/editor/ManiphestEditEngine.php

After this change, also 2. and 3. return the expected file.

Diff Detail

Repository
rP Phorge
Branch
locate-allow-ghanooo-linux-prefix
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 616
Build 616: arc lint + arc unit

Event Timeline

avivey added inline comments.
webroot/rsrc/js/application/diffusion/DiffusionLocateFileSource.js
104

try this - it's how we often write regexps that contain /.

webroot/rsrc/js/application/diffusion/DiffusionLocateFileSource.js
104

Unfortunately, in the proposed way it does not receive a RegExp object, so it does not work as expected.

"./teest/".replace('@^\.?\/@', '') // it returns ./teest/
"@^\.?\/@".replace('@^\.?\/@', '') // it returns an empty string

Also it seems to me that using the RegExp constructor directly also does not offer any native way to use a different delimiter.

Nice to see that even in 2023 JavaScript is terrible.

avivey added inline comments.
webroot/rsrc/js/application/diffusion/DiffusionLocateFileSource.js
104

Oh, it's javascript. Sure.

This revision is now accepted and ready to land.Jul 3 2023, 08:03