Nova

Extensions


Readme

My tools for working with GitHub from Nova.

Currently only one command: Open on GitHub.

Open on GitHub

Open the current file (or selected line range) on GitHub.

There are a bunch of these, but none seem to work for me, often because they require the current branch to be tracking a remote, when I ~always want to open a file on the 'origin' repo, so that's what this does. None of the other extensions seem to be maintained, either, so I can't fix them myself.

Assumptions:

  • Consistent remote naming (i.e. origin, the default or upstream, etc.).
  • The latest ref on the current branch is usually available on origin (e.g. in a PR or on a branch)

Uses the gh command-line tool to check if the latest commit is available on origin. If it's not, it will open on HEAD instead.

The idea here is to always browse somewhere, rather than refusing to do anything if it can't guess where to browse, which is what other GitHub extensions seem to choose.

TODO

  • use tracking branch, if defined
  • make requests directly to the GitHub API to check for refs instead of relying on gh (I chose gh because I use it and it avoid)
  • error handling

Usage

Defines the command "Open on GitHub" command, which opens the current file (and selected line range) on GitHub. No default key-bindings, but I use cmd-option-G.


Changelog

Version 1.0

Initial release


License

MIT License

Copyright (c) 2023 Min RK

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.