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
F2904599: D25320.1737330705.diff
Sat, Jan 18, 23:51
F2902806: D25320.1737313926.diff
Sat, Jan 18, 19:12
F2902764: D25320.1737312769.diff
Sat, Jan 18, 18:52
F2896071: D25320.1737239369.diff
Fri, Jan 17, 22:29
F2894808: D25320.1737232314.diff
Fri, Jan 17, 20:31
F2872232: D25320.1736885774.diff
Mon, Jan 13, 20:16
F2871570: D25320.1736867233.diff
Mon, Jan 13, 15:07
F2871458: D25320.1736855284.diff
Mon, Jan 13, 11:48

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