File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,22 @@ function getGithubURLPrefix(root) {
16
16
var head = fs . readFileSync ( path . join ( root , '.git' , 'HEAD' ) , 'utf8' ) ;
17
17
var branch = head . match ( / r e f \: ( .* ) / ) ;
18
18
if ( branch ) {
19
- var sha = fs . readFileSync ( path . join ( root , '.git' , branch [ 1 ] ) , 'utf8' ) ;
19
+ var branchFileName = path . join ( root , '.git' , branch [ 1 ] ) ;
20
+ var packedRefsName = path . join ( root , '.git' , 'packed-refs' ) ;
21
+ var sha ;
22
+ if ( fs . existsSync ( branchFileName ) ) {
23
+ sha = fs . readFileSync ( branchFileName , 'utf8' ) ;
24
+ } else if ( fs . existsSync ( packedRefsName ) ) {
25
+ sha = fs . readFileSync ( packedRefsName , 'utf8' )
26
+ . split ( / \n / )
27
+ . filter ( function ( line ) {
28
+ return line [ 0 ] !== '#' && line [ 0 ] !== '^' ;
29
+ } )
30
+ . reduce ( function ( memo , line ) {
31
+ memo [ line . split ( ' ' ) [ 1 ] ] = line . split ( ' ' ) [ 0 ] ;
32
+ return memo ;
33
+ } , { } ) [ branch [ 1 ] ] ;
34
+ }
20
35
} else {
21
36
sha = head ;
22
37
}
You can’t perform that action at this time.
0 commit comments