boyter / searchcode-server

The offical home of searchcode-server where you can run searchcode locally. Note that master is generally unstable in the sense that it is not a release. Check releases for release versions https://github.com/boyter/searchcode-server/releases

Home Page:https://searchcodeserver.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enable clickthrough to original repo

issmirnov opened this issue · comments

Currently, when you run a search the file is displayed as a local snapshot from searchcode. When you click on a line number, this updates the url with a #NN for the line number.

It would be useful to have the ability to click on a line number and have the original repo open. In etsy/hound it's possible to specify a url-pattern tokenized into "{url}/{path}{anchor}", which lets users open custom deeplinks into various hosting platforms (gitea, gitlab, bitbucket)

100% something I agree with and something I am looking to integrate. As you say I just need to come up with a flexible url-pattern matcher which makes it easy per source. I am actually going to be defining those soon actually so that if you have 2 sources you can filter accordingly. IE you may want to index code from github, bitbucket and gitlab and should be able to filer on each accordingly.

With the above in place the click though to the actual file is possible. It is on the list of things to do.

Moved up in priority as it is a requirement for searchcode.com

So this functionality now exists in master if you need it urgently. However you need to manually add the repository using the Repository Add screen in admin.

The source are defined in ./include/source/database.json and look like the following,

https://github.com/{user}/{project}/blob/{branch}/{filepath}

NB You can update the file as required to get new sources and the like. It should be refreshed every time the add page is loaded. However the name value should be unique.

There are 3 new fields to help with this when adding a repository.

Source = Contains the names from the database JSON file mentioned above. I have only included replacements that would work for GitHub/BitBucket/GitLab. I will have a look at other types later but this covers the majority.
Source User = {user} is replaced with this value
Source Project = {project} is replaced with this value

Existing field of Repository Branch is used to get {branch}
{filepath} comes from the actual path of the file.

TODO

  1. Add the above to the API endpoints to allow mass insertion.
  2. Display the above values on the list page.
  3. Consider making these values in the repository editable.
  4. Consider adding API to allow editing of the values.
  5. Add source output to UI as a filter (mostly done)

screen shot 2017-11-07 at 8 58 32 am

Looks great, thanks!

Still need to fix up the API to support this but most of it is there now. The ability to filter by source is rather neat though.

  1. Add the above to the API endpoints to allow mass insertion. DONE
  2. Display the above values on the list page. DONE
  3. Consider making these values in the repository editable. WILLNOTFIX
  4. Consider adding API to allow editing of the values. WILLNOTFIX
  5. Add source output to UI as a filter (mostly done) DONE

Just needs additional testing at this point. Going to move into test.

To further this, for file system source it would be nice to have a direct link to the file. So for example, if my files system repo path is /code/test and the file is /code/test/folder/myfile.js , but I enter in a repository source of file://fileserver/code/test/, then it would link to file://fileserver/code/test/folder/myfile.js so that it can open directly from within the browser in the default editor of choice.

@MaxDiOrio So that would only work if whoever is browsing the page has the code on their local machine at the same file location. However it is still possible to do.

Edit the ./include/source/database.json file and define your own source like the below,

{
    "name": "File",
    "url": "file://",
    "link": "file://{filepath}"
  }

Then when adding the repository select the source "File" and it all should work for you. Of course after the file:// portion you will need to add the full path.

I am still working on the edit screen for the repositories so you can set this up after the fact but it should hit master in a week or two.

You can now add the click through to existing projects through the UI. Not going to add it to the API because if you are using that it shouldn't be a huge issue to delete everything and add it again. Merged into master. Going to move this into done as it has passed all internal tests as well.