@@ -3,42 +3,43 @@ var HostedGit = require('../index')
33var test = require ( 'tap' ) . test
44
55test ( 'fromUrl(gist url)' , function ( t ) {
6+ var proj = new Array ( 33 ) . join ( '2' )
67 function verify ( host , label , branch ) {
78 var hostinfo = HostedGit . fromUrl ( host )
89 var hash = branch ? '#' + branch : ''
910 t . ok ( hostinfo , label )
1011 if ( ! hostinfo ) return
11- t . is ( hostinfo . https ( ) , 'git+https://gist.github.com/222 .git' + hash , label + ' -> https' )
12- t . is ( hostinfo . git ( ) , 'git://gist.github.com/222 .git' + hash , label + ' -> git' )
13- t . is ( hostinfo . browse ( ) , 'https://gist.github.com/222' + ( branch ? '/' + branch : '' ) , label + ' -> browse' )
14- t . is ( hostinfo . browse ( 'C' ) , 'https://gist.github.com/222' + ( branch ? '/' + branch : '' ) + '#file-c' , label + ' -> browse(path)' )
15- t . is ( hostinfo . browse ( 'C' , 'A' ) , 'https://gist.github.com/222' + ( branch ? '/' + branch : '' ) + '#file-c' , label + ' -> browse(path, fragment)' )
16- t . is ( hostinfo . bugs ( ) , 'https://gist.github.com/222' , label + ' -> bugs' )
17- t . is ( hostinfo . docs ( ) , 'https://gist.github.com/222' + ( branch ? '/' + branch : '' ) , label + ' -> docs' )
18- t . is ( hostinfo . ssh ( ) , '[email protected] :/222 .git' + hash , label + ' -> ssh' ) 19- t . is ( hostinfo . sshurl ( ) , 'git+ssh://[email protected] /222 .git' + hash , label + ' -> sshurl' ) 20- t . is ( hostinfo . shortcut ( ) , 'gist:222' + hash , label + ' -> shortcut' )
12+ t . is ( hostinfo . https ( ) , 'git+https://gist.github.com/' + proj + ' .git' + hash , label + ' -> https' )
13+ t . is ( hostinfo . git ( ) , 'git://gist.github.com/' + proj + ' .git' + hash , label + ' -> git' )
14+ t . is ( hostinfo . browse ( ) , 'https://gist.github.com/' + proj + ( branch ? '/' + branch : '' ) , label + ' -> browse' )
15+ t . is ( hostinfo . browse ( 'C' ) , 'https://gist.github.com/' + proj + ( branch ? '/' + branch : '' ) + '#file-c' , label + ' -> browse(path)' )
16+ t . is ( hostinfo . browse ( 'C' , 'A' ) , 'https://gist.github.com/' + proj + ( branch ? '/' + branch : '' ) + '#file-c' , label + ' -> browse(path, fragment)' )
17+ t . is ( hostinfo . bugs ( ) , 'https://gist.github.com/' + proj , label + ' -> bugs' )
18+ t . is ( hostinfo . docs ( ) , 'https://gist.github.com/' + proj + ( branch ? '/' + branch : '' ) , label + ' -> docs' )
19+ t . is ( hostinfo . ssh ( ) , '[email protected] :/' + proj + ' .git' + hash , label + ' -> ssh' ) 20+ t . is ( hostinfo . sshurl ( ) , 'git+ssh://[email protected] /' + proj + ' .git' + hash , label + ' -> sshurl' ) 21+ t . is ( hostinfo . shortcut ( ) , 'gist:' + proj + hash , label + ' -> shortcut' )
2122 if ( hostinfo . user ) {
22- t . is ( hostinfo . file ( 'C' ) , 'https://gist.githubusercontent.com/111/222 /raw/' + ( branch ? branch + '/' : '' ) + 'C' , label + ' -> file' )
23- t . is ( hostinfo . tarball ( ) , 'https://gist.github.com/111/222 /archive/' + ( branch || 'master' ) + '.tar.gz' , label + ' -> tarball' )
23+ t . is ( hostinfo . file ( 'C' ) , 'https://gist.githubusercontent.com/111/' + proj + ' /raw/' + ( branch ? branch + '/' : '' ) + 'C' , label + ' -> file' )
24+ t . is ( hostinfo . tarball ( ) , 'https://gist.github.com/111/' + proj + ' /archive/' + ( branch || 'master' ) + '.tar.gz' , label + ' -> tarball' )
2425 }
2526 }
2627
27- verify ( '[email protected] :222 .git' , 'git@' ) 28- var hostinfo = HostedGit . fromUrl ( '[email protected] :/ef860c7z5e0de3179341 .git' ) 28+ verify ( '[email protected] :' + proj + ' .git', 'git@' ) 29+ var hostinfo = HostedGit . fromUrl ( '[email protected] :/c2b12db30a49324325a3781302668408 .git' ) 2930 if ( t . ok ( hostinfo , 'git@hex' ) ) {
30- t . is ( hostinfo . https ( ) , 'git+https://gist.github.com/ef860c7z5e0de3179341 .git' , 'git@hex -> https' )
31+ t . is ( hostinfo . https ( ) , 'git+https://gist.github.com/c2b12db30a49324325a3781302668408 .git' , 'git@hex -> https' )
3132 }
32- verify ( '[email protected] :/222 .git' , 'git@/' ) 33- verify ( 'git://gist.github.com/222' , 'git' )
34- verify ( 'git://gist.github.com/222 .git' , 'git.git' )
35- verify ( 'git://gist.github.com/222 #branch' , 'git#branch' , 'branch' )
36- verify ( 'git://gist.github.com/222 .git#branch' , 'git.git#branch' , 'branch' )
33+ verify ( '[email protected] :/' + proj + ' .git', 'git@/' ) 34+ verify ( 'git://gist.github.com/' + proj , 'git' )
35+ verify ( 'git://gist.github.com/' + proj + ' .git', 'git.git' )
36+ verify ( 'git://gist.github.com/' + proj + ' #branch', 'git#branch' , 'branch' )
37+ verify ( 'git://gist.github.com/' + proj + ' .git#branch', 'git.git#branch' , 'branch' )
3738
38- require ( './lib/standard-tests' ) ( verify , 'gist.github.com' , 'gist' )
39+ require ( './lib/standard-tests' ) ( verify , 'gist.github.com' , 'gist' , proj )
3940
40- verify ( HostedGit . fromUrl ( 'gist:111/222' ) . toString ( ) , 'round-tripped shortcut' )
41- verify ( 'gist:222' , 'shortened shortcut' )
41+ verify ( HostedGit . fromUrl ( 'gist:111/' + proj ) . toString ( ) , 'round-tripped shortcut' )
42+ verify ( 'gist:' + proj , 'shortened shortcut' )
4243
4344 t . end ( )
4445} )
0 commit comments