@@ -11,36 +11,40 @@ Property OriginalDevice;
11
11
12
12
ClassMethod Run ()
13
13
{
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 ()
24
28
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 )
28
32
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 ()
31
35
Write !," Done."
32
- } Else {
33
- Write !!," Invalid method selected." ,!!
34
- }
36
+ } Else {
37
+ Write !!," Invalid method selected." ,!!
38
+ }
35
39
}
36
40
37
41
Method OnPreServer () As %Status
38
42
{
39
- If '$System .Security .Check (" %Development" ," USE" ) {
40
- Quit $$$ERROR($$$AccessDenied)
41
- }
43
+ If '$SYSTEM .Security .Check (" %Development" ," USE" ) {
44
+ Quit $$$ERROR($$$AccessDenied)
45
+ }
42
46
If (%request .Get (" $NAMESPACE" ) '= " " ) {
43
- Set $Namespace = %request .Get (" $NAMESPACE" )
47
+ Set $NAMESPACE = %request .Get (" $NAMESPACE" )
44
48
}
45
49
Quit $$$OK
46
50
}
@@ -56,9 +60,11 @@ Method Server() As %Status
56
60
57
61
// In subclasses: Do Something that produces output to the current device.
58
62
// It will be sent back to the client, Base64-encoded, over the web socket connection.
59
- Do ..Run ()
63
+ Do ..Run ()
60
64
} Catch e {
61
65
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 ())
62
68
Set tSC = e .AsStatus ()
63
69
}
64
70
@@ -77,7 +83,7 @@ Method StartOutputCapture() [ ProcedureBlock = 0 ]
77
83
#dim tSC As %Status = $$$OK
78
84
#dim tRedirected As %Boolean = 0
79
85
Try {
80
- Set %server = $this
86
+ Set %server = $THIS
81
87
Set ..OriginallyRedirected = 0
82
88
Set ..OriginalMnemonic = " "
83
89
Set ..OriginalDevice = $IO
@@ -107,27 +113,27 @@ Method StartOutputCapture() [ ProcedureBlock = 0 ]
107
113
#; Public entry points for I/O redirection
108
114
wstr (s ) Do write (s )
109
115
Quit
110
- wchr (a ) Do write ($char (a ))
116
+ wchr (a ) Do write ($CHAR (a ))
111
117
Quit
112
118
wnl Do write ($$$EOL)
113
119
Set $X = 0
114
120
Quit
115
121
wff Do wnl Quit
116
122
wtab (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 ))
118
124
Do write (tTab )
119
125
Quit
120
126
write (str )
121
127
// If there was an argumentless NEW, cache the output and leave it at that.
122
128
// 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
125
131
Quit
126
132
}
127
133
128
134
// Restore previous I/O redirection settings.
129
135
New tOriginalDevice ,i
130
- Set tOriginalDevice = $io
136
+ Set tOriginalDevice = $IO
131
137
If ##class (%Library.Device ).ReDirectIO (0 ) {
132
138
Use tOriginalDevice
133
139
}
@@ -138,8 +144,8 @@ write(str)
138
144
Do ##class (%Library.Device ).ReDirectIO (1 )
139
145
}
140
146
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 ) {
143
149
Do reallywrite (^||OutputCapture .Cache (i ))
144
150
}
145
151
Kill ^||OutputCapture .Cache
@@ -155,7 +161,7 @@ write(str)
155
161
reallywrite (pString )
156
162
New tMsg
157
163
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 ()))
159
165
Quit
160
166
rstr (len , time ) Quit " "
161
167
rchr (time ) Quit " "
@@ -179,7 +185,7 @@ Method EndOutputCapture()
179
185
180
186
Method SendJSON (pObject As %DynamicAbstractObject )
181
187
{
182
- Set tOriginalDevice = $io
188
+ Set tOriginalDevice = $IO
183
189
If ##class (%Library.Device ).ReDirectIO (0 ) {
184
190
Use tOriginalDevice
185
191
}
@@ -189,7 +195,7 @@ Method SendJSON(pObject As %DynamicAbstractObject)
189
195
If ..OriginallyRedirected {
190
196
Do ##class (%Library.Device ).ReDirectIO (1 )
191
197
}
192
- Do ..Write ($System .Encryption .Base64Encode (pObject .%ToJSON ()))
198
+ Do ..Write ($SYSTEM .Encryption .Base64Encode (pObject .%ToJSON ()))
193
199
Do ##class (%Library.Device ).ReDirectIO (1 )
194
200
Use tOriginalDevice ::(" ^" _$ZNAME )
195
201
}
0 commit comments