@@ -1059,36 +1059,51 @@ describe('git', () => {
1059
1059
} )
1060
1060
} )
1061
1061
1062
- describe ( '.submoduleForPath(path)' , ( ) => {
1063
- beforeEach ( ( ) => {
1064
- const repoDirectory = temp . mkdirSync ( 'node-git-repo-' )
1065
- const submoduleDirectory = temp . mkdirSync ( 'node-git-repo-' )
1066
- wrench . copyDirSyncRecursive ( path . join ( __dirname , 'fixtures' , 'master.git' ) , path . join ( repoDirectory , '.git' ) )
1067
- wrench . copyDirSyncRecursive ( path . join ( __dirname , 'fixtures' , 'master.git' ) , path . join ( submoduleDirectory , '.git' ) )
1062
+ if ( process . env . CI ) {
1063
+ // NOTE: Testing a submodule requires that you be able to add one defined
1064
+ // at a path on disk. This is disallowed by default these days as a
1065
+ // security risk. There's a config setting to allow it, but we don't seem
1066
+ // to be able to opt into it on a per-repo basis.
1067
+ //
1068
+ // So this test is disabled unless we're running in CI, where the
1069
+ // environment is transient and will be thrown away anyway. If you want to
1070
+ // test this locally, save your config value for `protocol.file.allow`
1071
+ // beforehand and restore it when you're done testing.
1072
+ describe ( '.submoduleForPath(path)' , ( ) => {
1073
+ beforeEach ( ( ) => {
1074
+ const repoDirectory = temp . mkdirSync ( 'node-git-repo-' )
1075
+ const submoduleDirectory = temp . mkdirSync ( 'node-git-repo-' )
1076
+ wrench . copyDirSyncRecursive ( path . join ( __dirname , 'fixtures' , 'master.git' ) , path . join ( repoDirectory , '.git' ) )
1077
+ wrench . copyDirSyncRecursive ( path . join ( __dirname , 'fixtures' , 'master.git' ) , path . join ( submoduleDirectory , '.git' ) )
1068
1078
1069
- const gitCommandHandler = jasmine . createSpy ( 'gitCommandHandler' )
1070
- execCommands ( [ `cd ${ repoDirectory } ` , `git submodule add ${ submoduleDirectory } sub` ] , gitCommandHandler )
1079
+ const gitCommandHandler = jasmine . createSpy ( 'gitCommandHandler' )
1080
+ execCommands ( [
1081
+ `git config --global protocol.file.allow always` ,
1082
+ `cd ${ repoDirectory } ` ,
1083
+ `git submodule add ${ submoduleDirectory } sub`
1084
+ ] , gitCommandHandler )
1071
1085
1072
- waitsFor ( ( ) => gitCommandHandler . callCount === 1 )
1086
+ waitsFor ( ( ) => gitCommandHandler . callCount === 1 )
1073
1087
1074
- runs ( ( ) => repo = git . open ( repoDirectory ) )
1075
- } )
1088
+ runs ( ( ) => repo = git . open ( repoDirectory ) )
1089
+ } )
1076
1090
1077
- it ( 'returns the repository for the path' , ( ) => {
1078
- expect ( repo . submoduleForPath ( ) ) . toBe ( null )
1079
- expect ( repo . submoduleForPath ( null ) ) . toBe ( null )
1080
- expect ( repo . submoduleForPath ( '' ) ) . toBe ( null )
1081
- expect ( repo . submoduleForPath ( 'sub1' ) ) . toBe ( null )
1091
+ it ( 'returns the repository for the path' , ( ) => {
1092
+ expect ( repo . submoduleForPath ( ) ) . toBe ( null )
1093
+ expect ( repo . submoduleForPath ( null ) ) . toBe ( null )
1094
+ expect ( repo . submoduleForPath ( '' ) ) . toBe ( null )
1095
+ expect ( repo . submoduleForPath ( 'sub1' ) ) . toBe ( null )
1082
1096
1083
- let submoduleRepoPath = path . join ( repo . getPath ( ) , 'modules' , 'sub/' )
1084
- if ( process . platform === 'win32' ) { submoduleRepoPath = submoduleRepoPath . replace ( / \\ / g, '/' ) }
1097
+ let submoduleRepoPath = path . join ( repo . getPath ( ) , 'modules' , 'sub/' )
1098
+ if ( process . platform === 'win32' ) { submoduleRepoPath = submoduleRepoPath . replace ( / \\ / g, '/' ) }
1085
1099
1086
- expect ( repo . submoduleForPath ( 'sub' ) . getPath ( ) ) . toBe ( submoduleRepoPath )
1087
- expect ( repo . submoduleForPath ( 'sub/' ) . getPath ( ) ) . toBe ( submoduleRepoPath )
1088
- expect ( repo . submoduleForPath ( 'sub/a' ) . getPath ( ) ) . toBe ( submoduleRepoPath )
1089
- expect ( repo . submoduleForPath ( 'sub/a/b/c/d' ) . getPath ( ) ) . toBe ( submoduleRepoPath )
1100
+ expect ( repo . submoduleForPath ( 'sub' ) . getPath ( ) ) . toBe ( submoduleRepoPath )
1101
+ expect ( repo . submoduleForPath ( 'sub/' ) . getPath ( ) ) . toBe ( submoduleRepoPath )
1102
+ expect ( repo . submoduleForPath ( 'sub/a' ) . getPath ( ) ) . toBe ( submoduleRepoPath )
1103
+ expect ( repo . submoduleForPath ( 'sub/a/b/c/d' ) . getPath ( ) ) . toBe ( submoduleRepoPath )
1104
+ } )
1090
1105
} )
1091
- } )
1106
+ }
1092
1107
1093
1108
describe ( '.add(path)' , ( ) => {
1094
1109
beforeEach ( ( ) => {
0 commit comments