@@ -14,25 +14,12 @@ var parse = require('github-url-from-git');
1414var open = require ( 'open' ) ;
1515var copy = require ( 'copy-paste' ) . copy
1616var gitRev = require ( 'git-rev-2' ) ;
17- var process = require ( 'child_process' ) ;
1817
1918function getGitHubLink ( cb ) {
2019 var cwd = workspace . rootPath ;
21- var repoRootDirectory = null ;
22- var repoRelativePath = "" ;
23-
24- try {
25- // determine the associated git repo: if cwd is not a git repo, we will search up until we find one
26- repoRootDirectory = process . execSync ( 'git rev-parse --show-toplevel' , { cwd : cwd } ) . toString ( ) . replace ( '\n' , '' ) ;
27- // if repo root is not cwd, repoRelativePath will be the path relative path to get from repo root to workspace root
28- repoRelativePath = cwd . replace ( repoRootDirectory , "" ) ;
29- } catch ( ex ) {
30- // error: just use cwd
31- repoRootDirectory = cwd ;
32- }
3320
3421 git ( {
35- cwd : repoRootDirectory
22+ cwd : cwd
3623 } , function ( err , config ) {
3724 var rawUri , parseOpts , lineIndex = 0 , parsedUri , branch , editor , selection
3825 , projectName , subdir , gitLink , scUrls , workspaceConfiguration ;
@@ -59,7 +46,7 @@ function getGitHubLink(cb) {
5946 parsedUri = rawUri ;
6047 }
6148
62- gitRev . branch ( repoRootDirectory , function ( branchErr , branch ) {
49+ gitRev . branch ( cwd , function ( branchErr , branch ) {
6350 if ( branchErr || ! branch )
6451 branch = 'master' ;
6552 editor = Window . activeTextEditor ;
@@ -69,7 +56,7 @@ function getGitHubLink(cb) {
6956 lineIndex = selection . active . line + 1 ;
7057 projectName = parsedUri . substring ( parsedUri . lastIndexOf ( "/" ) + 1 , parsedUri . length ) ;
7158
72- subdir = repoRelativePath + editor . document . uri . fsPath . substring ( workspace . rootPath . length ) . replace ( / \" / g, "" ) ;
59+ subdir = editor . document . uri . fsPath . substring ( workspace . rootPath . length ) . replace ( / \" / g, "" ) ;
7360
7461 if ( parsedUri . startsWith ( scUrls . github ) ) {
7562 gitLink = parsedUri + "/blob/" + branch + subdir + "#L" + lineIndex ;
0 commit comments