Skip to content

Comments

Add repository browser#70

Merged
nelhage merged 3 commits intolivegrep:masterfrom
dropbox:fileview
Jun 10, 2017
Merged

Add repository browser#70
nelhage merged 3 commits intolivegrep:masterfrom
dropbox:fileview

Conversation

@jboning
Copy link
Contributor

@jboning jboning commented Jun 2, 2017

This adds the ability to view source files directly in livegrep, as
an alternative to linking to external viewers configured by
url-pattern. This is desirable for a couple of reasons:

  • It's a common pattern to search for something in the codebase,
    find it, examine its surroundings, and search again for something
    nearby (for example, when following a chain of function calls).

  • The external viewer might be slow (for example, if it's Phabricator),
    and it's valuable to get a snappy response when clicking through to
    view a search result.

The file browser is implemented as part of livegrep, and requires
having git repositories available to the livegrep process. Therefore,
livegrep now accepts an additional config file (in the same format
used by codesearch) specifying where to find repos on disk. If this
config is not provided, we retain the old behaviour where clicking
through to view a search result goes directly to the external site.

Fixes #55.

Credit again to @christoffer for the initial implementation of this in
Dropbox's internal fork; I've made some additional tweaks porting it
here.

}
},
internalUrl: function() {
return "/view/" + this.get('tree') + "/" + this.get('path') + "#L" + this.get('lno');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have a version hash, we should be embedding it here, so that this link, if copied/pasted, continues to point to the right line later on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a bigger question here around link behaviour--we'll need to figure out some story around when we want to permalink a specific version vs when we just want to link to HEAD. It's easy to change the behaviour later, so I'm most interested right now in making sure the URL format is satisfactory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw there's one affordance for handling this right now, which is the -revparse flag to codesearch, which causes it to resolve all commit references into sha1's while indexing, which will then propagate through the system to ensure stable references and links.

I'm a big fan of linking to sha1's in general, but there are definitely a bunch of fiddly UX questions.

<li>Shift + click a second line number to highlight a range</li>
<li>Press <pre class="keyboard-shortcut">/</pre> to start a new search (the selected text will be prefilled)</li>
<li>Select some text and press <pre class="keyboard-shortcut">enter</pre> to perform a new search with the selected text</li>
<li>Press <pre class="keyboard-shortcut">d</pre> to visit this file in diffusion</li>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"diffusion" is a Phabricator-ism. "...to visit this file elsewhere" (as done above) seems handwavy, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops! I changed it to "elsewhere" above, though there's javascript that rewrites it to mention the specific domain. I suppose that's available at template render time, so we might as well do it then.

I'm reminded that I changed the shortcut to "v" and should update this help text.

jboning added 3 commits June 3, 2017 00:29
This adds the ability to view source files directly in livegrep, as
an alternative to linking to external viewers configured by
`url-pattern`. This is desirable for a couple of reasons:

 - It's a common pattern to search for something in the codebase,
   find it, examine its surroundings, and search again for something
   nearby (for example, when following a chain of function calls).

 - The external viewer might be slow (for example, if it's Phabricator),
   and it's valuable to get a snappy response when clicking through to
   view a search result.

The file browser is implemented as part of `livegrep`, and requires
having git repositories available to the `livegrep` process. Therefore,
`livegrep` now accepts an additional config file (in the same format
used by `codesearch`) specifying where to find repos on disk. If this
config is not provided, we retain the old behaviour where clicking
through to view a search result goes directly to the external site.
@jboning
Copy link
Contributor Author

jboning commented Jun 3, 2017

Just rebased onto master and resolved merge conflicts. (@nelhage, do you prefer rebasing feature branches onto master or merging master into branches?)

@nelhage
Copy link
Contributor

nelhage commented Jun 5, 2017

I'm generally in favor of rebasing onto master.

I'll try to take a look at this this week. I've been pretty underwater of late.

@nelhage nelhage merged commit f536b93 into livegrep:master Jun 10, 2017
@jboning jboning deleted the fileview branch June 12, 2017 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants