Giter VIP home page Giter VIP logo

vscode-open-in-github's Introduction

vscode-open-in-github

Supports : GitHub, GitLab, Gitea, Bitbucket, and Visualstudio.com.

Extension for Visual Studio Code which can be used to jump to a source code line in GitHub, GitLab, Gitea, Bitbucket and Visualstudio.com

Build Status All Contributors

Install

Tested with VsCode 0.10.1

Press F1 and narrow down the list commands by typing extension. Pick Extensions: Install Extension.

installation

Simply pick the Open in GitHub / Bitbucket extension from the list

Install Manual

Mac & Linux

cd $HOME/.vscode/extensions
git clone https://github.com/ziyasal/vscode-open-in-github.git
cd vscode-open-in-github
npm install

Windows

cd %USERPROFILE%\.vscode\extensions
git clone https://github.com/ziyasal/vscode-open-in-github.git
cd vscode-open-in-github
npm install

Usage

Command

Press F1 and type Open in GitHub.

open

Press F1 and type Copy GitHub link to clipboard.

copy

(The URL for GitHub will also include line ranges if there are lines selected in the editor)

Press F1 and type Open Pull Request.

copy

Keybord Shortcut

Press Ctrl+L G to activate. Press Ctrl+L C to copy active line link to clipboard.

Context menu

Right click on explorer item and choose Open in GitHub or Copy GitHub link to clipboard.

context

Configure custom github domain

Add following line into workspace settings;

{
  "openInGitHub.gitHubDomain": "your custom github domain here",
  "openInGitHub.requireSelectionForLines": false,   // If enabled, the copied or opened URL won't include line number(s) unless there's an active selection
  "openInGitHub.useCommitSHAInURL": false,
  "openInGitHub.providerType": "gitlab", // github, gitlab, gitea, bitbucket, ...
  "openInGitHub.providerProtocol": "https" // https, http. Useful for custom domains that don't support https. Defaults to https.
}

Custom Settings

{
  "openInGitHub.providerType": "custom", // important, otherwise the following settings will not be read
  "openInGitHub.customProviderPath": "https://your-git-repo-hosting-domain:port/path-to-the-repo",
  "openInGitHub.customBlobPath": "+", // for example, this is `blob` in gitlab
  "openInGitHub.customLinePrefix": "#", // for example, this is `#L12` instead of just `#12` in most git hosting service
  "openInGitHub.defaultPullRequestBranch": "master", // for example, this could be `development`
  // optional
  "openInGitHub.alwaysOpenInDefaultBranch": true // if you always work on your local branch, and checking it online will always get 404
}

Have fun..

Debug Travis CI locally

  cd $your_vscode_open_in_github_local_directory_path

  BUILD_ID="build-$RANDOM" && \
  LATEST_GARNET_TAG_ID="1515445631-7dfb2e1" && \
  MAPPED_DOCKER_PATH=/home/travis/vscode-open-in-github && \
  docker run \
    -name $BUILD_ID
    -v $(pwd):$MAPPED_DOCKER_PATH \
    -dit "travisci/ci-garnet:packer-$LATEST_GARNET_TAG_ID" /sbin/init && \
  docker exec -it $BUILDID bash -l
  # to rerun last command: look for the last container with docker ps

  su - travis # to use nvm and npm

  cd /vscode-open-in-github

  # replicate steps in either A) .travis.yml B) worker log in Travis CI

Reference: Stackoverflow

Known Limitations

  • Extension doesn't currently works with Git worktrees

Contributors

Thanks goes to these wonderful people (emoji key):


Brady Holt

๐Ÿ’ป ๐Ÿ“– โš ๏ธ

Grzegorz Dziadkiewicz

๐Ÿ’ป ๐Ÿ“– โš ๏ธ

Yuichi Tanikawa

๐Ÿ’ป ๐Ÿ“– โš ๏ธ

Suan Yeo

๐Ÿ’ป

Benjamin Pasero

๐Ÿ’ป

Stuart Leeks

๐Ÿ’ป

Marvin Hagemeister

๐Ÿ’ป

linarnan

๐Ÿ’ป โš ๏ธ

Dan Seethaler

๐Ÿ’ป โš ๏ธ

John Arthur

๐Ÿ’ป

Eduardo Diaz

๐Ÿ’ป

Tom Esterez

๐Ÿ’ป

Anthony Brown

๐Ÿ’ป

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT ยฉ Ziya SARIKAYA @ziyasal & Contributors

vscode-open-in-github's People

Contributors

abinavseelan avatar alankyshum avatar bolinfest avatar bpasero avatar bradymholt avatar bugthesystem avatar cologler avatar daiyunxu-stripe avatar danseethaler avatar dependabot[bot] avatar enure avatar gdziadkiewicz avatar hua03 avatar iakio avatar iferc avatar itiut avatar johnpaularthur avatar jwulf avatar linarnan avatar marocchino avatar martynchamberlin avatar marvinhagemeister avatar orta avatar ron23 avatar singingwolfboy avatar skyjur avatar stuartleeks avatar suan avatar testerez avatar ziluvatar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

vscode-open-in-github's Issues

Locate or specify github server name

It would be great if this extension allowed you to use another domain for the project. I'm unsure how vscode's git integration works, but I believe the url for the remote system is in the git config; git config --get remote.origin.url should return it, but I think that depends on 'origin' as the name.

Either way, this would let you specify a custom github server (like GitHub enterprise accounts).

[Bug] ".git" removed if repository name is <user>.github.io

Bug - ".git" removed if repository name is .github.io

First of all, love the extension โค๏ธ ๐Ÿ˜„

Context

I have a repository abinavseelan.github.io. When I use the extension to go to a specific line, the final url that I'm taken to is https://github.com/abinavseelan/abinavseelanhub.io/blob/master/index.html#L16-L24

The .git in abinavseelan.github.io is removed.

Potential fix

Looks like the bug is originating from here https://github.com/ziyasal/vscode-open-in-github/blob/master/src/gitProvider.js#L13 ๐Ÿ™‚

I can raise a PR for this in a couple of hours ๐Ÿ™‚

Support SSH alias

I have a .ssh/config like

Host github
  User git
  HostName github.com
  IdentityFile ~/.ssh/github

so my remote is just github:felixfbecker/whatever. I'm getting the error Unknown git provider

Open/copy URL WITHOUT line number

It would be great to have the ability to do this - often you just want to call out a file as a whole, and not a particular part of it.

I like how fugitive.vim handles it - if any lines are highlighted, you get the URL with the line range. If none are selected, you just get the plain URL - thus if you just want the current line, you just have to select the current line

Cannot read property 'branch "master"' of undefined

I'm getting this error in the dev tools. This only seems to occur on my repositories that are git submodules.

[ziyasal.vscode-open-in-github] Cannot read property 'branch "master"' of undefined: TypeError: Cannot read property 'branch "master"' of undefined
	at ~/.vscode/extensions/ziyasal.vscode-open-in-github-1.2.8/src/extension.js:38:50
	at ~/.vscode/extensions/ziyasal.vscode-open-in-github-1.2.8/node_modules/git-rev-2/index.js:9:5
	at ChildProcess.exithandler (child_process.js:209:7)
	at emitTwo (events.js:106:13)
	at ChildProcess.emit (events.js:194:7)
	at maybeClose (internal/child_process.js:899:16)
	at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Support to copy URL to clipboard

I love this extension but often I use it only to get the URL such that I can send it, comment with it etc. I think it would be awesome if, in addition to opening a browser, I could have a command that copies the target to the clipboard.

No handler found for the command 'openInGitHub'

I have latest VSCode and I have installed the open in git hub extension.
When I do the "Open in GitHub" action I get the "No handler found for the command 'openInGitHub'"

Might it be that this extension is not working with latest VS Code?

Does not work

When I click on "Open in GitHub" nothing happend.
I am using a Mac

Opens only origin remote URL, not actually checked out fork

I have a project that has both the origin/master (local: origin) and a fork/master (local: master) checked out. Although master is the active branch in my project, it opens the URL of origin in the browser.

Am I missing something or is this not supported?

Setting to open file in current commit instead of branch?

@ziyasal thanks for building this extension, much appreciated!

When opening a file in GitHub, the URL that gets opened is in the format:

https://github.com/USER/REPO/blob/BRANCH/PATH/FILENAME#LINENUMBER

I would like the following instead (canonical format):

https://github.com/USER/REPO/blob/COMMIT_HASH/PATH/FILENAME#LINENUMBER

That way I can easily share the link with others (maybe a copy link to clipboard option?). It's not a big deal since pressing y in GitHub's UI switches to the canonical format. Would you accept a PR for this feature?

Does Not Integrate Correctly on VSCode 1.17.1

The extension does not show on my installed list and trying to use it gives the "extension.openInGitHub' not found error.

image

If, after installing it, I search for the extension in the extensions list it does appear to be installed by that listing:

image

Make it possible to just go the project page

Right now the default behavior is to open the current line of the current file in the browser.

But most of the time I just want to go the project page. It would be great I could go just to the project page, just like when there is no open document.

Functions bound to the commands do not return anything meaningful.

Commands called programmatic, using commands.executeCommand api, have the possibility to return something. It is not widely used and even the built-in commands of vscode often do not return anything, but IMO it would be an good idea to return promise which will resolve on completion of the command. This way timeouts in tests could be removed.

Support sub-directory workspaces

When opening a sub-directory of a git repository in vscode, this extension is not able to resolve the git repository information and therefore fails to open files in the browser.

There needs to be support for finding the root repository from relative to the vscode workspace root.

Parametrize Git remote

Currently the plugin expect remote with name origin to be present and assumes, that user wants to retrieve a link for the project, specified in this remote.

But this is not always the case. The idea is to make user able to choose, relatively to which remote he wants URL to be constructed.

Keyboard Shortcut/Context Menu

Is it possible to have either a keyboard shortcut for this command, or an entry in the Context Menu when you right click on a file?

Often it doesn't do anything

Exception from the Developer tools window:

//Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:136 [Extension Host] TypeError: Cannot read property 'url' of undefined
    at /Users/dragos/.vscode/extensions/ziyasal.vscode-open-in-github-1.2.3/src/extension.js:27:51
    at /Users/dragos/.vscode/extensions/ziyasal.vscode-open-in-github-1.2.3/node_modules/parse-git-config/index.js:31:5
    at /Users/dragos/.vscode/extensions/ziyasal.vscode-open-in-github-1.2.3/node_modules/parse-git-config/index.js:49:7
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)

Sometimes it picks up the wrong repository, probably based on some other workspace (if I have multiple windows open). Not sure what's going on.

Doesn't do anything

I have tried both reloading the window and restarting VS Code entirely. Neither the "Open in Github" nor "Copy Github link" commands do anything. I don't see any output in the console.

I'm using v1.3.1 of the extension, and v1.21.1 of VS Code.

Fails to open when checked out to custom folder name

I am on Mac using version 0.6.0 and when I open a file from my workspace with a path like this:

/Users/bpasero/Development/monaco/appveyor.yml

It ends up opening this in the browser:

https://github.com/Microsoft/vscode/blob/master:///Users/bpasero/Development/monaco/appveyor.yml#L14

Any ideas?

Doesn't work with bitbucket URLs

Hi,

was looking forward to using this!

I've set the provider to be bitbucket, and when calling Open in Github I get this url:

https://bitbucket.org/team/project/src/branchfolder/branchname/dir1/dir2/sourcefile.swift#cl-142

which produces an error page (see below).

It looks like it needs to produce:

https://bitbucket.org/team/project/src/a285d517f4b9db31acacfee01018ace7577e939cdir1/dir2/sourcefile.swift#sourcefile.swift-142

or

https://bitbucket.org/team/project/commits/b6eac64dbc5e2859d78bb53d16c19cc561a15511

Ideally both.

More power to you!

bitbucket failure

No support for subdirectory workspaces

When opening a sub-directory of a git repository in vscode, this extension is not able to resolve the git repository information and therefore fails to open files in the browser.

There needs to be support for finding the root repository from relative to the vscode workspace root.

Worked was done to support this in: #27 but was subsequently reverted after merged and I am not sure why.

Extensions: Install Extension does not exist

In the latest version of Visual Studio Code, I do not see command options for "extensions." Is it possible that they no longer support this? Doesn't make sense, I'm sure I am doing something wrong.

Link not copied on Linux

I'm using Ubuntu 16.10 and VSCode 1.11.2 while opening on GitHub works ok, copying the link does nothing.

don't bind Ctrl+O

Ctrl+O is used in VS Code to open a different file/folder which this extension override by registering Ctrl+O Ctrl+G. The recommended plane is Ctrl+L

Go to repo homepage if no active text editor

It would be nice if, when running the command when there's no active text editor (ie, when you first open a folder, or close editors), the extension would just open the repo's home page. Currently it just does nothing in this case.

Would love the ability to open to latest commit instead of current branch

Love this extension! I'm coming from PHPStorm though and there's one feature it had that I would love to see with this.

Very often, I use this feature because I'm in a fresh branch, one that's not yet been pushed to Github, and I've made changes to a file and I want to see how it compares to how it originally was. I guess the "right" way to do this would be to run a git diff <filename> in Terminal, but I like Github's interface. The problem is that when I do this, I get a 404 on Github because it doesn't recognize the branch. If instead it just used the latest commit though, that would solve this problem, because the "latest commit" on a fresh branch is going to be a commit that Github already has on its server (assuming Github has the latest master, or whatever branch the current one is based from).

How hard would it be to make this change?

Support GitLab CE/EE

At the office we use a on-premise GitLab CE. It would be great if the extension could support this.

I have added this gitHubDomain setting to my workspace settings.json, but that doesn't help:

"openInGitHub.gitHubDomain": "https://gitlab.domain.local"

Obviously I put in the proper domain name, that matches the git remote. I tried with and without https. I keep getting the warning Unknown Git provider.

On-premise GitLab has exactly the same structure as GitLab.com, just the domain name is different.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.