@@ -1204,6 +1204,9 @@ exports.userGitHubImportScriptPage = function (aReq, aRes, aNext) {
1204
1204
var authedUser = aReq . session . user ;
1205
1205
var githubUserId = null ;
1206
1206
var githubRepoName = null ;
1207
+ var githubDefaultBranch = null ;
1208
+ var githubPathName = null ;
1209
+ var githubPathExt = null ;
1207
1210
var githubBlobPath = null ;
1208
1211
1209
1212
// Session
@@ -1218,6 +1221,9 @@ exports.userGitHubImportScriptPage = function (aReq, aRes, aNext) {
1218
1221
options . isOwnRepo = authedUser . ghUsername && authedUser . ghUsername === options . githubUserId ;
1219
1222
1220
1223
options . githubRepoName = githubRepoName = aReq . body . repo || aReq . query . repo ;
1224
+ options . githubDefaultBranch = githubDefaultBranch = aReq . body . default_branch || aReq . query . default_branch ;
1225
+ options . githubPathName = githubPathName = aReq . body . pathname || aReq . query . pathname ;
1226
+ options . githubPathExt = githubPathExt = aReq . body . pathext || aReq . query . pathext ;
1221
1227
options . githubBlobPath = githubBlobPath = aReq . body . path || aReq . query . path ;
1222
1228
1223
1229
if ( ! ( githubUserId && githubRepoName && githubBlobPath ) ) {
@@ -1284,7 +1290,17 @@ exports.userGitHubImportScriptPage = function (aReq, aRes, aNext) {
1284
1290
if ( aErr ) {
1285
1291
statusCodePage ( aReq , aRes , aNext , {
1286
1292
statusCode : aErr . status . code ,
1287
- statusMessage : aErr . status . message
1293
+ statusMessage : aErr . status . message ,
1294
+ isCustomView : true ,
1295
+ statusData : {
1296
+ isGHImport : true ,
1297
+ utf_pathname : githubPathName ,
1298
+ utf_pathext : githubPathExt ,
1299
+ user : encodeURIComponent ( githubUserId ) ,
1300
+ repo : encodeURIComponent ( githubRepoName ) ,
1301
+ default_branch : encodeURIComponent ( githubDefaultBranch ) ,
1302
+ path : encodeURIComponent ( githubBlobPath )
1303
+ }
1288
1304
} ) ;
1289
1305
return ;
1290
1306
}
@@ -1329,7 +1345,21 @@ exports.userGitHubImportScriptPage = function (aReq, aRes, aNext) {
1329
1345
}
1330
1346
scriptStorage . storeScript ( authedUser , blocks , aBlobUtf8 , false , onScriptStored ) ;
1331
1347
} else {
1332
- aCallback ( 'Specified file does not contain the proper metadata blocks.' ) ;
1348
+ statusCodePage ( aReq , aRes , aNext , {
1349
+ statusCode : 400 ,
1350
+ statusMessage : 'Specified file does not contain the proper metadata blocks.' ,
1351
+ isCustomView : true ,
1352
+ statusData : {
1353
+ isGHImport : true ,
1354
+ utf_pathname : githubPathName ,
1355
+ utf_pathext : githubPathExt ,
1356
+ user : encodeURIComponent ( githubUserId ) ,
1357
+ repo : encodeURIComponent ( githubRepoName ) ,
1358
+ default_branch : encodeURIComponent ( githubDefaultBranch ) ,
1359
+ path : encodeURIComponent ( githubBlobPath )
1360
+ }
1361
+ } ) ;
1362
+ return ;
1333
1363
}
1334
1364
1335
1365
} else if ( options . javascriptBlob . isJSLibrary ) {
@@ -1360,11 +1390,23 @@ exports.userGitHubImportScriptPage = function (aReq, aRes, aNext) {
1360
1390
}
1361
1391
scriptStorage . storeScript ( authedUser , blocks , aBlobUtf8 , false , onScriptStored ) ;
1362
1392
} else {
1363
- aCallback ( 'Specified file does not contain the proper metadata blocks.' ) ;
1393
+ statusCodePage ( aReq , aRes , aNext , {
1394
+ statusCode : 400 ,
1395
+ statusMessage : 'Specified file does not contain the proper metadata blocks.' ,
1396
+ isCustomView : true ,
1397
+ statusData : {
1398
+ isGHImport : true ,
1399
+ utf_pathname : githubPathName ,
1400
+ utf_pathext : githubPathExt ,
1401
+ user : encodeURIComponent ( githubUserId ) ,
1402
+ repo : encodeURIComponent ( githubRepoName ) ,
1403
+ default_branch : encodeURIComponent ( githubDefaultBranch ) ,
1404
+ path : encodeURIComponent ( githubBlobPath )
1405
+ }
1406
+ } ) ;
1407
+ return ;
1364
1408
}
1365
1409
1366
-
1367
-
1368
1410
} else {
1369
1411
aCallback ( 'Invalid filetype.' ) ;
1370
1412
}
@@ -1373,8 +1415,11 @@ exports.userGitHubImportScriptPage = function (aReq, aRes, aNext) {
1373
1415
var script = null ;
1374
1416
1375
1417
if ( aErr ) {
1376
- console . error ( aErr ) ;
1377
- console . error ( githubUserId , githubRepoName , githubBlobPath ) ;
1418
+ console . error ( [
1419
+ aErr ,
1420
+ authedUser . name + ' ' + githubUserId + ' ' + githubRepoName + ' ' + githubBlobPath
1421
+
1422
+ ] . join ( '\n' ) ) ;
1378
1423
statusCodePage ( aReq , aRes , aNext , {
1379
1424
statusCode : 400 ,
1380
1425
statusMessage : aErr
0 commit comments