Add feature to resolve URL local file, open in editor of choice
Sometimes I have a GitLab URL that I want to investigate on my local repo with my editor of choice. Currently, I have to copy and paste the relevant file path, and then open my editor manually.
This change will allow parsing the URL and resolving to a local file in the repository, and open in the editor of choice, at the line number(s) specified in the URL. If the ref in the URL is different to what is checked out currently, you will be asked to checkout the required ref to view the file.
Your PWD
must be within the repository's path for this to resolve. Otherwise, nothing will be returned.
Editor of choice is either the :edit
CLI option (-e
), or the $EDITOR
environment variable, in that order.
To do:
-
Use parsed ref to open file at specific ref (commit sha, branch, tag, etc). Currently file is opened at current HEAD. -
Allow selection of line ranges in editors. Currently only first line is selected. -
Support more editors. Currently onlyvim
andcode
are supported. -
Support branch refs with forward slash in name. Hard to determine where branch name ends and file path begins in a URL. -
Error handling for unknown refs, eg deleted branches
Screenshots
- Open file via URL with ref as tag (when
$EDITOR
is set to vim)
- Open file via URL with ref as branch, specifying editor with
-e
option:
Edited by Michael Trainor