@@ -180,11 +180,7 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe
180
180
// cleanup items info
181
181
kill @..#Storage@(" items" )
182
182
kill @..#Storage@(" TSH" )
183
- do ..RunGitCommand (" init" ,.errStream ,.outStream )
184
- $$$NewLineIfNonEmptyStream(errStream )
185
- do errStream .OutputToDevice ()
186
- $$$NewLineIfNonEmptyStream(outStream )
187
- do outStream .OutputToDevice ()
183
+ do ..Init ()
188
184
} else {
189
185
set ec = ..MakeError (" Unable to create folder " _..TempFolder ())
190
186
}
@@ -271,6 +267,16 @@ ClassMethod AfterUserAction(Type As %Integer, Name As %String, InternalName As %
271
267
quit $$$OK
272
268
}
273
269
270
+ ClassMethod Init () As %Status
271
+ {
272
+ do ..RunGitCommand (" init" ,.errStream ,.outStream )
273
+ $$$NewLineIfNonEmptyStream(errStream )
274
+ do errStream .OutputToDevice ()
275
+ $$$NewLineIfNonEmptyStream(outStream )
276
+ do outStream .OutputToDevice ()
277
+ quit $$$OK
278
+ }
279
+
274
280
ClassMethod Revert (InternalName As %String ) As %Status
275
281
{
276
282
set filename = ..FullExternalName (.InternalName )
@@ -342,7 +348,7 @@ ClassMethod Fetch(ByRef diffFiles) As %Status
342
348
quit $$$OK
343
349
}
344
350
345
- ClassMethod Pull (remote As %String = " origin" ) As %Status
351
+ ClassMethod Pull (remote As %String = " origin" , preview As %Boolean = 0 ) As %Status
346
352
{
347
353
#define Force 1
348
354
do ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" branch" ,,.errStream ,.outStream ," --show-current" )
@@ -376,7 +382,12 @@ ClassMethod Pull(remote As %String = "origin") As %Status
376
382
}
377
383
if ('$data (files )) {
378
384
write !, ?4 , " None"
379
- write !, " Already up to date. Git Pull will not be executed."
385
+ if preview {
386
+ quit $$$OK
387
+ }
388
+ write !, " Already up to date."
389
+ quit $$$OK
390
+ } elseif preview {
380
391
quit $$$OK
381
392
}
382
393
@@ -423,6 +434,52 @@ ClassMethod Pull(remote As %String = "origin") As %Status
423
434
quit event .OnPull ()
424
435
}
425
436
437
+ ClassMethod Clone (remote As %String ) As %Status
438
+ {
439
+ set settings = ##class (SourceControl.Git.Settings ).%New ()
440
+ // TODO: eventually use /ENV flag with GIT_TERMINAL_PROMPT=0. (This isn't doc'd yet and is only in really new versions.)
441
+ set sc = ..RunGitWithArgs (.errStream , .outStream , " clone" , remote , settings .namespaceTemp )
442
+ $$$NewLineIfNonEmptyStream(errStream )
443
+ while 'errStream .AtEnd {
444
+ write errStream .ReadLine (),!
445
+ }
446
+ $$$NewLineIfNonEmptyStream(outStream )
447
+ while 'outStream .AtEnd {
448
+ write outStream .ReadLine (),!
449
+ }
450
+ quit $$$OK
451
+ }
452
+
453
+ ClassMethod GenerateSSHKeyPair () As %Status
454
+ {
455
+ set settings = ##class (SourceControl.Git.Settings ).%New ()
456
+ set filename = settings .privateKeyFile
457
+ set email = settings .gitUserEmail
458
+ set dir = ##class (%File ).GetDirectory (filename )
459
+ if ##class (%File ).Exists (filename ) {
460
+ Throw ##class (%Exception.General ).%New (" File " _filename _" already exists" )
461
+ }
462
+ do ##class (%File ).CreateDirectoryChain (dir )
463
+ set outLog = ##class (%Library.File ).TempFilename ()
464
+ set errLog = ##class (%Library.File ).TempFilename ()
465
+ do $zf (-100 ," /SHELL /STDOUT=" _$$$QUOTE(outLog )_" /STDERR=" _$$$QUOTE(errLog ),
466
+ " ssh-keygen" ,
467
+ " -t" ," ed25519" ,
468
+ " -C" ,email ,
469
+ " -f" ,filename ,
470
+ " -N" ," " )
471
+
472
+ set errStream = ##class (%Stream.FileCharacter ).%OpenId (errLog ,,.sc )
473
+ set outStream = ##class (%Stream.FileCharacter ).%OpenId (outLog ,,.sc )
474
+ set outStream .TranslateTable =" UTF8"
475
+ for stream =errStream ,outStream {
476
+ set stream .RemoveOnClose = 1
477
+ }
478
+ do outStream .OutputToDevice ()
479
+ do errStream .OutputToDevice ()
480
+ quit $$$OK
481
+ }
482
+
426
483
ClassMethod IsNamespaceInGit () As %Boolean [ CodeMode = expression ]
427
484
{
428
485
##class (%File ).Exists (..TempFolder ()_" .git" )
@@ -1789,15 +1846,22 @@ ClassMethod ConfigureWeb()
1789
1846
set installNamespace = $Namespace
1790
1847
new $Namespace
1791
1848
set $Namespace = " %SYS"
1792
- write !," Adding favorite for all users... "
1849
+ write !," Adding favorites for all users: "
1793
1850
set sql = " insert or update into %SYS_Portal.Users (Username, Page, Data) " _
1794
1851
" select ID,?,? from Security.Users"
1795
1852
set caption = " Git: " _installNamespace
1796
1853
set link = " /isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/" _installNamespace _" /"
1797
- do ##class (%SQL.Statement ).%ExecDirect (,sql ,caption ,link ).%Display ()
1854
+ write !," Adding Git favorite... "
1855
+ set statement = ##class (%SQL.Statement ).%New ()
1856
+ set statement .%SelectMode = 0
1857
+ do ##class (%SQL.Statement ).%ExecDirect (statement ,sql ,caption ,link ).%Display ()
1858
+ set caption = " Git Pull: " _installNamespace
1859
+ set link = " /isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE=" _installNamespace
1860
+ write !," Adding Git Pull favorite... "
1861
+ do ##class (%SQL.Statement ).%ExecDirect (statement ,sql ,caption ,link ).%Display ()
1798
1862
write !," Setting GroupById to %ISCMgtPortal for /isc/studio/usertemplates... "
1799
1863
set sql = " update Security.Applications set GroupById='%ISCMgtPortal' where ID = '/isc/studio/usertemplates'"
1800
- do ##class (%SQL.Statement ).%ExecDirect (,sql ).%Display ()
1864
+ do ##class (%SQL.Statement ).%ExecDirect (statement ,sql ).%Display ()
1801
1865
}
1802
1866
1803
1867
ClassMethod CheckInitialization ()
@@ -1919,4 +1983,3 @@ ClassMethod BuildCEInstallationPackage(ByRef destination As %String) As %Status
1919
1983
}
1920
1984
1921
1985
}
1922
-
0 commit comments