@@ -11,36 +11,40 @@ Property OriginalDevice;
1111
1212ClassMethod Run ()
1313{
14- If %request .Get (" method" ) = " preview" {
15- set branchName = ##class (SourceControl.Git.Utils ).GetCurrentBranch ()
16- do ##class (SourceControl.Git.Utils ).RunGitWithArgs (.errStream , .outStream , " fetch" )
17- kill errStream , outStream
18- do ##class (SourceControl.Git.Utils ).RunGitWithArgs (.errStream , .outStream , " log" , " HEAD..origin" , " --name-status" )
19- do ##class (SourceControl.Git.Utils ).PrintStreams (errStream , outStream )
20- } ElseIf %request .Get (" method" ) = " pull" {
21- Do ##class (SourceControl.Git.API ).Pull ()
22- } ElseIf %request .Get (" method" ) = " init" {
23- Do ##class (SourceControl.Git.Utils ).Init ()
14+ If %request .Get (" method" ) = " preview" {
15+ Set branchName = ##class (SourceControl.Git.Utils ).GetCurrentBranch ()
16+ Write !," Current branch: " ,branchName
17+ Do ##class (SourceControl.Git.Utils ).RunGitWithArgs (.errStream , .outStream , " fetch" )
18+ Kill errStream , outStream
19+ Do ##class (SourceControl.Git.Utils ).RunGitWithArgs (.errStream , .outStream , " log" , " HEAD..origin" , " --name-status" )
20+ Do ##class (SourceControl.Git.Utils ).PrintStreams (errStream , outStream )
21+ If (outStream .Size = 0 ) && (errStream .Size = 0 ) {
22+ Write !," Already up to date."
23+ }
24+ } ElseIf %request .Get (" method" ) = " pull" {
25+ Do ##class (SourceControl.Git.API ).Pull ()
26+ } ElseIf %request .Get (" method" ) = " init" {
27+ Do ##class (SourceControl.Git.Utils ).Init ()
2428 Write !," Done."
25- } ElseIf %request .Get (" method" ) = " clone" {
26- Set remote = %request .Get (" remote" )
27- Do ##class (SourceControl.Git.Utils ).Clone (remote )
29+ } ElseIf %request .Get (" method" ) = " clone" {
30+ Set remote = %request .Get (" remote" )
31+ Do ##class (SourceControl.Git.Utils ).Clone (remote )
2832 Write !," Done."
29- } ElseIf %request .Get (" method" ) = " sshkeygen" {
30- Do ##class (SourceControl.Git.Utils ).GenerateSSHKeyPair ()
33+ } ElseIf %request .Get (" method" ) = " sshkeygen" {
34+ Do ##class (SourceControl.Git.Utils ).GenerateSSHKeyPair ()
3135 Write !," Done."
32- } Else {
33- Write !!," Invalid method selected." ,!!
34- }
36+ } Else {
37+ Write !!," Invalid method selected." ,!!
38+ }
3539}
3640
3741Method OnPreServer () As %Status
3842{
39- If '$System .Security .Check (" %Development" ," USE" ) {
40- Quit $$$ERROR($$$AccessDenied)
41- }
43+ If '$SYSTEM .Security .Check (" %Development" ," USE" ) {
44+ Quit $$$ERROR($$$AccessDenied)
45+ }
4246 If (%request .Get (" $NAMESPACE" ) '= " " ) {
43- Set $Namespace = %request .Get (" $NAMESPACE" )
47+ Set $NAMESPACE = %request .Get (" $NAMESPACE" )
4448 }
4549 Quit $$$OK
4650}
@@ -56,9 +60,11 @@ Method Server() As %Status
5660
5761 // In subclasses: Do Something that produces output to the current device.
5862 // It will be sent back to the client, Base64-encoded, over the web socket connection.
59- Do ..Run ()
63+ Do ..Run ()
6064 } Catch e {
6165 Do e .Log ()
66+ Write !," An error occurred. More details can be found in the Application error log."
67+ Write !,$SYSTEM .Status .GetErrorText (e .AsStatus ())
6268 Set tSC = e .AsStatus ()
6369 }
6470
@@ -77,7 +83,7 @@ Method StartOutputCapture() [ ProcedureBlock = 0 ]
7783 #dim tSC As %Status = $$$OK
7884 #dim tRedirected As %Boolean = 0
7985 Try {
80- Set %server = $this
86+ Set %server = $THIS
8187 Set ..OriginallyRedirected = 0
8288 Set ..OriginalMnemonic = " "
8389 Set ..OriginalDevice = $IO
@@ -107,27 +113,27 @@ Method StartOutputCapture() [ ProcedureBlock = 0 ]
107113 #; Public entry points for I/O redirection
108114wstr (s ) Do write (s )
109115 Quit
110- wchr (a ) Do write ($char (a ))
116+ wchr (a ) Do write ($CHAR (a ))
111117 Quit
112118wnl Do write ($$$EOL)
113119 Set $X = 0
114120 Quit
115121wff Do wnl Quit
116122wtab (n ) New tTab
117- Set tTab = $J (" " ,$S (n >$X :n -$X ,1 :0 ))
123+ Set tTab = $JUSTIFY (" " ,$SELECT (n >$X :n -$X ,1 :0 ))
118124 Do write (tTab )
119125 Quit
120126write (str )
121127 // If there was an argumentless NEW, cache the output and leave it at that.
122128 // This will be output next time there's a write with %server in scope.
123- If '$IsObject ( $Get (%server )) {
124- Set ^||OutputCapture .Cache ($i (^||OutputCapture .Cache )) = str
129+ If '$ISOBJECT ( $GET (%server )) {
130+ Set ^||OutputCapture .Cache ($INCREMENT (^||OutputCapture .Cache )) = str
125131 Quit
126132 }
127133
128134 // Restore previous I/O redirection settings.
129135 New tOriginalDevice ,i
130- Set tOriginalDevice = $io
136+ Set tOriginalDevice = $IO
131137 If ##class (%Library.Device ).ReDirectIO (0 ) {
132138 Use tOriginalDevice
133139 }
@@ -138,8 +144,8 @@ write(str)
138144 Do ##class (%Library.Device ).ReDirectIO (1 )
139145 }
140146
141- If $Data (^||OutputCapture .Cache ) {
142- For i =1 :1 :$Get (^||OutputCapture .Cache ) {
147+ If $DATA (^||OutputCapture .Cache ) {
148+ For i =1 :1 :$GET (^||OutputCapture .Cache ) {
143149 Do reallywrite (^||OutputCapture .Cache (i ))
144150 }
145151 Kill ^||OutputCapture .Cache
@@ -155,7 +161,7 @@ write(str)
155161reallywrite (pString )
156162 New tMsg
157163 Set tMsg = {" content" :(pString )} // This is handy because it handles escaping of newlines, etc.
158- Do %server .Write ($System .Encryption .Base64Encode (tMsg .%ToJSON ()))
164+ Do %server .Write ($SYSTEM .Encryption .Base64Encode (tMsg .%ToJSON ()))
159165 Quit
160166rstr (len , time ) Quit " "
161167rchr (time ) Quit " "
@@ -179,7 +185,7 @@ Method EndOutputCapture()
179185
180186Method SendJSON (pObject As %DynamicAbstractObject )
181187{
182- Set tOriginalDevice = $io
188+ Set tOriginalDevice = $IO
183189 If ##class (%Library.Device ).ReDirectIO (0 ) {
184190 Use tOriginalDevice
185191 }
@@ -189,7 +195,7 @@ Method SendJSON(pObject As %DynamicAbstractObject)
189195 If ..OriginallyRedirected {
190196 Do ##class (%Library.Device ).ReDirectIO (1 )
191197 }
192- Do ..Write ($System .Encryption .Base64Encode (pObject .%ToJSON ()))
198+ Do ..Write ($SYSTEM .Encryption .Base64Encode (pObject .%ToJSON ()))
193199 Do ##class (%Library.Device ).ReDirectIO (1 )
194200 Use tOriginalDevice ::(" ^" _$ZNAME )
195201}
0 commit comments