Skip to content

Commit 234b1af

Browse files
committed
XML -> UDL
1 parent 8babd6d commit 234b1af

File tree

6 files changed

+239
-332
lines changed

6 files changed

+239
-332
lines changed

Diff for: isc/git/Diff.cls.xml renamed to isc/git/Diff.cls

+28-39
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<Export generator="Cache" version="25">
3-
<Class name="isc.git.Diff">
4-
<Super>isc.util.OSUtils</Super>
5-
<TimeCreated>64700,69295.723984</TimeCreated>
1+
Class isc.git.Diff Extends isc.util.OSUtils
2+
{
63

7-
<Method name="buildDiff">
8-
<Description>
9-
Get diff between two points in repository
10-
repo - repository root directory
11-
sha1, commitEnd - poins of history in repository
12-
modified - list of modified files
13-
added - list of added files
14-
deleted - list of deleted files
15-
16-
Internal diff statuses:
17-
M modified - File has been modified
18-
C copy-edit - File has been copied and modified //3-arg form
19-
R rename-edit - File has been renamed and modified //3-arg form
20-
A added - File has been added
21-
D deleted - File has been deleted
22-
U unmerged - File has conflicts after a merge
23-
24-
do ##class(isc.git.Diff).buildDiff("C:\\temp\GitLab\", "HEAD~10", "HEAD", .modified, .added, .deleted)</Description>
25-
<ClassMethod>1</ClassMethod>
26-
<FormalSpec>repo:%String,commitBegin:%String,commitEnd:%String,*modified:%List,*added:%List,*deleted:%List</FormalSpec>
27-
<Implementation><![CDATA[
4+
/// Get diff between two points in repository
5+
/// repo - repository root directory
6+
/// sha1, commitEnd - poins of history in repository
7+
/// modified - list of modified files
8+
/// added - list of added files
9+
/// deleted - list of deleted files
10+
///
11+
/// Internal diff statuses:
12+
/// M modified - File has been modified
13+
/// C copy-edit - File has been copied and modified //3-arg form
14+
/// R rename-edit - File has been renamed and modified //3-arg form
15+
/// A added - File has been added
16+
/// D deleted - File has been deleted
17+
/// U unmerged - File has conflicts after a merge
18+
///
19+
/// do ##class(isc.git.Diff).buildDiff("C:\\temp\GitLab\", "HEAD~10", "HEAD", .modified, .added, .deleted)
20+
ClassMethod buildDiff(repo As %String, commitBegin As %String, commitEnd As %String, Output modified As %List, Output added As %List, Output deleted As %List)
21+
{
2822
#include %occCPTJSgen
2923
set (modified, added, deleted) = ""
3024
$$$TOE(sc, ..createFile(.tempFile))
@@ -62,19 +56,14 @@ do ##class(isc.git.Diff).buildDiff("C:\\temp\GitLab\", "HEAD~10", "HEAD", .modif
6256
throw ##class(%Exception.General).%New("INVALID DIFF LINE: " _ element)
6357
}
6458
}
65-
]]></Implementation>
66-
</Method>
59+
}
6760

68-
<Method name="isRelevantFile">
69-
<Description>
70-
Determine if the file is neede for git diff </Description>
71-
<ClassMethod>1</ClassMethod>
72-
<FormalSpec>dir:%String,file:%String</FormalSpec>
73-
<ReturnType>%Boolean</ReturnType>
74-
<Implementation><![CDATA[
61+
/// Determine if the file is neede for git diff
62+
ClassMethod isRelevantFile(dir As %String, file As %String) As %Boolean
63+
{
7564
set ext = $select($length(file, ".")=1:"", 1:$piece(file, ".", *))
7665
quit $lf(##class(isc.git.Settings).getSetting("ext"), ext)>0
77-
]]></Implementation>
78-
</Method>
79-
</Class>
80-
</Export>
66+
}
67+
68+
}
69+
+70-113
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<Export generator="Cache" version="25">
3-
<Class name="isc.git.GitLab">
4-
<TimeCreated>64700,73518.498808</TimeCreated>
5-
6-
<Method name="getDir">
7-
<ClassMethod>1</ClassMethod>
8-
<CodeMode>expression</CodeMode>
9-
<Implementation><![CDATA[##class(%File).NormalizeDirectory($system.Util.GetEnviron("CI_PROJECT_DIR"))
10-
]]></Implementation>
11-
</Method>
12-
13-
<Method name="getCommit">
14-
<Description>
15-
For CI build - get current commit</Description>
16-
<ClassMethod>1</ClassMethod>
17-
<CodeMode>expression</CodeMode>
18-
<Implementation><![CDATA[$system.Util.GetEnviron("CI_COMMIT_SHA")
19-
]]></Implementation>
20-
</Method>
21-
22-
<Method name="load">
23-
<Description>
24-
Do a full load
25-
do ##class(isc.git.GitLab).load()</Description>
26-
<ClassMethod>1</ClassMethod>
27-
<Implementation><![CDATA[
1+
Class isc.git.GitLab
2+
{
3+
4+
ClassMethod getDir() [ CodeMode = expression ]
5+
{
6+
##class(%File).NormalizeDirectory($system.Util.GetEnviron("CI_PROJECT_DIR"))
7+
}
8+
9+
/// For CI build - get current commit
10+
ClassMethod getCommit() [ CodeMode = expression ]
11+
{
12+
$system.Util.GetEnviron("CI_COMMIT_SHA")
13+
}
14+
15+
/// Do a full load
16+
/// do ##class(isc.git.GitLab).load()
17+
ClassMethod load()
18+
{
2819
try {
2920
set dir = ..getDir()
3021
do ..log("Importing dir " _ dir)
@@ -40,15 +31,12 @@ do ##class(isc.git.GitLab).load()</Description>
4031
write !,$System.Status.GetErrorText(ex.AsStatus()),!
4132
do $system.Process.Terminate(, 1)
4233
}
43-
]]></Implementation>
44-
</Method>
34+
}
4535

46-
<Method name="loadDiff">
47-
<Description>
48-
Do a diff load
49-
do ##class(isc.git.GitLab).loadDiff()</Description>
50-
<ClassMethod>1</ClassMethod>
51-
<Implementation><![CDATA[
36+
/// Do a diff load
37+
/// do ##class(isc.git.GitLab).loadDiff()
38+
ClassMethod loadDiff()
39+
{
5240
try {
5341
#dim sc,sc1 As %Status = $$$OK
5442
set oldCommit = ##class(isc.git.Settings).getSetting("commit")
@@ -98,27 +86,22 @@ do ##class(isc.git.GitLab).loadDiff()</Description>
9886
do ..logException(ex)
9987
do $system.Process.Terminate(, 1)
10088
}
101-
]]></Implementation>
102-
</Method>
89+
}
10390

104-
<Method name="init">
105-
<ClassMethod>1</ClassMethod>
106-
<Implementation><![CDATA[
91+
ClassMethod init()
92+
{
10793
set init = ##class(isc.git.Settings).getSetting("init")
10894
if (init'="") {
10995
do ..log("Running init code: " _ init)
11096
do $classmethod($p(init, ":"), $p(init, ":", 2))
11197
} else {
11298
do ..log("No init code")
11399
}
114-
]]></Implementation>
115-
</Method>
100+
}
116101

117-
<Method name="test">
118-
<Description>
119-
do ##class(isc.git.GitLab).test()</Description>
120-
<ClassMethod>1</ClassMethod>
121-
<Implementation><![CDATA[
102+
/// do ##class(isc.git.GitLab).test()
103+
ClassMethod test()
104+
{
122105
try {
123106
set tests = ##class(isc.git.Settings).getSetting("tests")
124107
if (tests'="") {
@@ -134,14 +117,11 @@ do ##class(isc.git.GitLab).test()</Description>
134117
do ..logException(ex)
135118
do $system.Process.Terminate(, 1)
136119
}
137-
]]></Implementation>
138-
</Method>
120+
}
139121

140-
<Method name="package">
141-
<Description>
142-
do ##class(GitLab.Main).package()</Description>
143-
<ClassMethod>1</ClassMethod>
144-
<Implementation><![CDATA[
122+
/// do ##class(GitLab.Main).package()
123+
ClassMethod package()
124+
{
145125
try {
146126
set dir = ..getDir()
147127
// TODO
@@ -152,12 +132,10 @@ do ##class(GitLab.Main).package()</Description>
152132
do ..logException(ex)
153133
do $system.Process.Terminate(, 1)
154134
}
155-
]]></Implementation>
156-
</Method>
135+
}
157136

158-
<Method name="writeTestHTML">
159-
<ClassMethod>1</ClassMethod>
160-
<Implementation><![CDATA[
137+
ClassMethod writeTestHTML()
138+
{
161139
set text = ##class(%Dictionary.XDataDefinition).IDKEYOpen($classname(), "html").Data.Read()
162140
set text = $replace(text, "!!!", ..getURL())
163141

@@ -166,49 +144,38 @@ do ##class(GitLab.Main).package()</Description>
166144
do file.LinkToFile(name)
167145
do file.Write(text)
168146
quit file.%Save()
169-
]]></Implementation>
170-
</Method>
147+
}
171148

172-
<Method name="getURL">
173-
<ClassMethod>1</ClassMethod>
174-
<Implementation><![CDATA[
149+
ClassMethod getURL()
150+
{
175151
set url = ##class(isc.git.Settings).getSetting("url")
176152
set url = url _ $system.CSP.GetDefaultApp("%SYS")
177153
set url = url_"/%25UnitTest.Portal.Indices.cls?Index="_ $g(^UnitTest.Result, 1) _ "&$NAMESPACE=" _ $zconvert($namespace,"O","URL")
178154
quit url
179-
]]></Implementation>
180-
</Method>
155+
}
181156

182-
<Method name="getExtWildcard">
183-
<Description>
184-
Get extensions as wildcard for import</Description>
185-
<ClassMethod>1</ClassMethod>
186-
<ReturnType>%String</ReturnType>
187-
<Implementation><![CDATA[
157+
/// Get extensions as wildcard for import
158+
ClassMethod getExtWildcard() As %String
159+
{
188160
set extList = ##class(isc.git.Settings).getSetting("ext")
189161
set ext = "*." _ $lts(##class(isc.git.Settings).getSetting("ext"), ";*.")
190162
quit ext
191-
]]></Implementation>
192-
</Method>
163+
}
193164

194-
<Method name="isLastTestOk">
195-
<Description>
196-
w ##class(GitLab.Main).isLastTestOk()</Description>
197-
<ClassMethod>1</ClassMethod>
198-
<ReturnType>%Boolean</ReturnType>
199-
<Implementation><![CDATA[
165+
/// w ##class(GitLab.Main).isLastTestOk()
166+
ClassMethod isLastTestOk() As %Boolean
167+
{
200168
set in = ##class(%UnitTest.Result.TestInstance).%OpenId(^UnitTest.Result)
201169
for i=1:1:in.TestSuites.Count() {
202170
#dim suite As %UnitTest.Result.TestSuite
203171
set suite = in.TestSuites.GetAt(i)
204172
return:suite.Status=0 $$$NO
205173
}
206174
quit $$$YES
207-
]]></Implementation>
208-
</Method>
175+
}
209176

210-
<XData name="html">
211-
<Data><![CDATA[
177+
XData html
178+
{
212179
<html lang="en-US">
213180
<head>
214181
<meta charset="UTF-8"/>
@@ -221,14 +188,10 @@ window.location.href = "!!!"
221188
If you are not redirected automatically, follow this <a href='!!!'>link to tests</a>.
222189
</body>
223190
</html>
224-
]]></Data>
225-
</XData>
191+
}
226192

227-
<Method name="logVar">
228-
<ClassMethod>1</ClassMethod>
229-
<FormalSpec>var="",name:%String=""</FormalSpec>
230-
<ReturnType>%String</ReturnType>
231-
<Implementation><![CDATA[
193+
ClassMethod logVar(var = "", name As %String = "") As %String
194+
{
232195
do ..log("Variable " _ name)
233196
zw var
234197
/*if $isObject(var) {
@@ -238,28 +201,22 @@ If you are not redirected automatically, follow this <a href='!!!'>link to tests
238201
} else {
239202
write var
240203
}*/
241-
]]></Implementation>
242-
</Method>
204+
}
205+
206+
ClassMethod logException(ex As %Exception.AbstractException)
207+
{
208+
do ..logStatus(ex.AsStatus())
209+
}
210+
211+
ClassMethod logStatus(sc As %Status)
212+
{
213+
do ..log($System.Status.GetErrorText(sc))
214+
}
243215

244-
<Method name="logException">
245-
<ClassMethod>1</ClassMethod>
246-
<FormalSpec>ex:%Exception.AbstractException</FormalSpec>
247-
<Implementation><![CDATA[ do ..logStatus(ex.AsStatus())
248-
]]></Implementation>
249-
</Method>
216+
ClassMethod log(msg As %String)
217+
{
218+
write !, $$$FormatText("[%1] %2", $zdatetime($ztimestamp, 3, 1, 3), msg), !
219+
}
250220

251-
<Method name="logStatus">
252-
<ClassMethod>1</ClassMethod>
253-
<FormalSpec>sc:%Status</FormalSpec>
254-
<Implementation><![CDATA[ do ..log($System.Status.GetErrorText(sc))
255-
]]></Implementation>
256-
</Method>
221+
}
257222

258-
<Method name="log">
259-
<ClassMethod>1</ClassMethod>
260-
<FormalSpec>msg:%String</FormalSpec>
261-
<Implementation><![CDATA[ write !, $$$FormatText("[%1] %2", $zdatetime($ztimestamp, 3, 1, 3), msg), !
262-
]]></Implementation>
263-
</Method>
264-
</Class>
265-
</Export>

Diff for: isc/git/Settings.cls

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Include %syPrompt
2+
3+
Class isc.git.Settings
4+
{
5+
6+
/// List of extensions relevant to code load
7+
Parameter EXT As List = {$lb("xml", "cls", "csp", "csr", "mac", "int", "bas", "inc", "gbl", "prj", "obj", "pkg", "gof", "dfi", "pivot", "dashboard")};
8+
9+
Parameter URL = "http://127.0.0.1:57772";
10+
11+
Parameter GLVN = "^isc.git.Settings";
12+
13+
/// Get setting
14+
/// Получить настойку
15+
/// write ##class(isc.git.Settings).getSetting("ext")
16+
ClassMethod getSetting(name As %String) As %String [ CodeMode = expression ]
17+
{
18+
$get(@..#GLVN@($zcvt(name, "l")), $parameter(,$zcvt(name, "U")))
19+
}
20+
21+
/// Get setting
22+
/// Установить настройку
23+
/// write ##class(isc.git.Settings).setSetting("ext")
24+
ClassMethod setSetting(name As %String = "", value As %String = "") As %Status
25+
{
26+
#dim sc As %Status = $$$OK
27+
28+
if name = "tests" {
29+
// Path relative from the repo root to test suite
30+
} elseif name = "ext" {
31+
set:'$listValid(value) sc = $$$ERROR($$$GeneralError, "Extension list should be in $lb format.")
32+
} elseif name = "commit" {
33+
// TO-DO commit validation.
34+
} elseif name = "init" {
35+
set:$length(value, ":")'=2 sc = $$$ERROR($$$GeneralError, "Init should be in a format: 'class:method'")
36+
} elseif name = "delete" {
37+
set:$length(value, ":")'=2 sc = $$$ERROR($$$GeneralError, "Delete should be in a format: 'class:method'")
38+
} elseif name = "url" {
39+
// TO-DO url validation.
40+
// "http://127.0.0.1:57772"
41+
} else {
42+
set sc = $$$ERROR($$$GeneralError, $$$FormatText("Setting '%1' does not exist", name))
43+
}
44+
45+
set:$$$ISOK(sc) @..#GLVN@($zcvt(name, "l")) = value
46+
return sc
47+
}
48+
49+
}
50+

0 commit comments

Comments
 (0)