Skip to content

Commit 527745a

Browse files
committed
Merge branch 'main' into production-change-control
2 parents 6cd7b3b + 93ebd68 commit 527745a

File tree

7 files changed

+192
-77
lines changed

7 files changed

+192
-77
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Files in uncommitted queue in any namespace warn users when opened except for in VSCode (#370)
1313
- Added link back to IRIS management portal from Settings, Git WebUI pages (#449)
1414
- Added Import all and Import All (Force) to basic mode menu (#498)
15+
- Improved behavior for commits when attribution settings are not configured (#450)
1516

1617
### Fixed
1718
- Changed prompts in configure from 0/1 to no/yes (#461)
1819
- Added warnings when user is using incompatible git version (#488)
1920
- Fixed the back button navigation between WebUI and Settings page (#361)
21+
- Fixed issues with HL7 file extension inconsistencies (#495)
2022
- Basic mode Sync operation now imports items changed on the remote merge branch (#506)
2123
- Fetch diff output uses correct remote branch (#509)
24+
- Properly handle more cases of truncated filenames from git pull (#511)
25+
- Made git-source-control backwards compatible with IRIS 2021.1 (#513)
26+
- Sync, pull properly handle more change edge cases for import (#517, #496)
2227

2328
## [2.5.0] - 2024-09-24
2429

cls/SourceControl/Git/Change.cls

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -82,29 +82,25 @@ ClassMethod GetOtherDeveloperChanges() As %Boolean
8282
{
8383
set numEntries = 0
8484
set fileToOtherDevelopers = {}
85-
set query = "Select ItemFile, ChangedBy FROM SourceControl_Git.Change WHERE Committed = '0' AND ChangedBy <> ?"
86-
set statement = ##class(%SQL.Statement).%New()
87-
set status = statement.%Prepare(query, 0)
88-
$$$ThrowOnError(status)
89-
set rset = statement.%Execute($username)
90-
if (rset.%SQLCODE < 0) {
91-
throw ##class(%Exception.SQL).CreateFromSQLCODE(rset.%SQLCODE,rset.%Message)
92-
}
93-
set tempFolder = ##class(SourceControl.Git.Utils).TempFolder()
94-
while rset.%Next(.sc) {
95-
$$$ThrowOnError(sc)
9685

97-
if $FIND(rset.ItemFile, tempFolder) {
98-
set filePath = $PIECE(rset.ItemFile, tempFolder, 2)
99-
} else {
100-
continue
86+
set username = $username
87+
&sql(DECLARE DeveloperCursor CURSOR FOR SELECT ItemFile, ChangedBy into :itemFile, :changedBy from SourceControl_Git.Change WHERE Committed = 0 and ChangedBy <> :username)
88+
&sql(OPEN DeveloperCursor)
89+
throw:SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, %msg)
90+
&sql(FETCH DeveloperCursor)
91+
set tempFolder = ##class(SourceControl.Git.Utils).TempFolder()
92+
while(SQLCODE = 0) {
93+
if $FIND(itemFile, tempFolder) {
94+
set filePath = $PIECE(itemFile, tempFolder, 2)
95+
set otherDevelopers = fileToOtherDevelopers.%Get(filePath, [])
96+
do otherDevelopers.%Push(changedBy)
97+
do fileToOtherDevelopers.%Set(filePath, otherDevelopers)
10198
}
10299

103-
set otherDevelopers = fileToOtherDevelopers.%Get(filePath, [])
104-
do otherDevelopers.%Push(rset.ChangedBy)
105-
do fileToOtherDevelopers.%Set(filePath, otherDevelopers)
100+
&sql(FETCH DeveloperCursor)
106101
}
107-
$$$ThrowOnError(sc)
102+
&sql(CLOSE DeveloperCursor)
103+
108104
return fileToOtherDevelopers
109105
}
110106

@@ -193,6 +189,7 @@ Query InstanceUncommitted() As %Query(ROWSPEC = "InternalName:%String,User:%Stri
193189
ClassMethod InstanceUncommittedExecute(ByRef qHandle As %Binary) As %Status
194190
{
195191
set qHandle("q") = "SELECT InternalName, ChangedBy FROM SourceControl_Git.Change"
192+
&sql(DECLARE InstanceCursor CURSOR FOR SELECT InternalName, ChangedBy into :internalName, :changedBy from SourceControl_Git.Change)
196193
set namespaces = ##class(SourceControl.Git.Utils).GetGitEnabledNamespaces()
197194
set tPtr = 0
198195
set qHandle("i") = 1
@@ -201,16 +198,17 @@ ClassMethod InstanceUncommittedExecute(ByRef qHandle As %Binary) As %Status
201198
set namespace = $ZCONVERT(tValue, "U")
202199
if '(namespace [ "^") {
203200
set $NAMESPACE = namespace
204-
set statement = ##class(%SQL.Statement).%New()
205-
$$$ThrowOnError(statement.%Prepare(qHandle("q"), 0))
206-
set resultSet = statement.%Execute()
207-
throw:resultSet.%SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(resultSet.%SQLCODE,resultSet.%Message)
208-
while resultSet.%Next(.sc) {
209-
$$$ThrowOnError(sc)
210-
set qHandle("changes", $increment(qHandle("changes")), "InternalName") = resultSet.%GetData(1)
211-
set qHandle("changes", qHandle("changes"), "User") = resultSet.%GetData(2)
212-
set qHandle("changes", qHandle("changes"), "Namespace") = namespace
213-
}
201+
202+
&sql(OPEN InstanceCursor)
203+
throw:SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, %msg)
204+
&sql(FETCH InstanceCursor)
205+
while(SQLCODE = 0) {
206+
set qHandle("changes", $increment(qHandle("changes")), "InternalName") = internalName
207+
set qHandle("changes", qHandle("changes"), "User") = changedBy
208+
set qHandle("changes", qHandle("changes"), "Namespace") = namespace
209+
&sql(FETCH InstanceCursor)
210+
}
211+
&sql(CLOSE InstanceCursor)
214212
}
215213
}
216214

@@ -283,4 +281,3 @@ Storage Default
283281
}
284282

285283
}
286-

cls/SourceControl/Git/DiscardState.cls

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,21 @@ ClassMethod DiscardStatesInBranch() As %DynamicArray
7777
{
7878
set currentBranch = ##class(SourceControl.Git.Utils).GetCurrentBranch()
7979

80-
set query = "SELECT ID FROM SourceControl_Git.DiscardState WHERE branch = ?"
81-
set statement = ##class(%SQL.Statement).%New()
82-
set status = statement.%Prepare(query, 0)
83-
$$$ThrowOnError(status)
84-
set resultSet = statement.%Execute(currentBranch)
85-
if (resultSet.%SQLCODE < 0) {
86-
throw ##class(%Exception.SQL).CreateFromSQLCODE(resultSet.%SQLCODE,resultSet.%Message)
87-
}
88-
80+
// Use embedded SQL for backwards compatability
81+
&sql(DECLARE DiscardCursor CURSOR FOR SELECT ID into :id from SourceControl_Git.DiscardState WHERE branch = :currentBranch)
82+
&sql(OPEN DiscardCursor)
83+
throw:SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, %msg)
84+
&sql(FETCH DiscardCursor)
8985
set discardStates = []
90-
while resultSet.%Next() {
91-
set discardState = ..%OpenId(resultSet.ID)
86+
while(SQLCODE = 0) {
87+
set discardState = ..%OpenId(id)
9288
do discardState.%JSONExportToString(.JSONStr)
9389
set discardStateObject = ##class(%DynamicAbstractObject).%FromJSON(JSONStr)
94-
set discardStateObject.Id = resultSet.ID
90+
set discardStateObject.Id = id
9591
do discardStates.%Push(discardStateObject)
92+
&sql(FETCH DiscardCursor)
9693
}
94+
&sql(CLOSE DiscardCursor)
9795

9896
quit discardStates
9997
}

cls/SourceControl/Git/Extension.cls

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ Method UserAction(Type As %Integer, Name As %String, InternalName As %String, Se
4949
if Type = 1, Name = 5 {
5050
// reroute to Status menu option
5151
set Name = "%SourceMenu,Status"
52-
}
52+
do ..CheckCommitterIdentity(settings, .Action, .Target)
53+
}
5354

5455
if (Type = 1) && (Name = 3) {
5556
if settings.warnInstanceWideUncommitted {
@@ -74,10 +75,17 @@ Method UserAction(Type As %Integer, Name As %String, InternalName As %String, Se
7475

7576
#dim ec as %Status = $$$OK
7677
#dim menu as %Status = $piece(Name, ",", 1)
78+
#dim menuItemName as %String = $piece(Name,",",2)
7779
if menu '= "%SourceMenu", menu'="%SourceContext" {
7880
quit $$$OK
7981
}
8082

83+
if (menuItemName = "Commit") || (menuItemName = "Sync") {
84+
if ..CheckCommitterIdentity(settings, .Action, .Target) {
85+
quit $$$OK
86+
}
87+
}
88+
8189
set InternalName = ##class(SourceControl.Git.Utils).NormalizeInternalName(InternalName)
8290
set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(InternalName)
8391
set ec = ##class(SourceControl.Git.Utils).UserAction(InternalName, Name, .Target, .Action, .Reload, .Msg)
@@ -482,5 +490,16 @@ Method AddToSourceControl(InternalName As %String, Description As %String = "")
482490
Quit ##class(SourceControl.Git.Utils).AddToSourceControl(InternalName)
483491
}
484492

493+
/// Called to check if committer identity is configured.
494+
Method CheckCommitterIdentity(Settings As SourceControl.Git.Settings, ByRef Action As %String, ByRef Target As %String) As %Boolean
495+
{
496+
if ((Settings.gitUserName = "") || (Settings.gitUserEmail = "")) {
497+
set Target = "Git committer name or email is not configured. Go to the Settings page in the Source Control menu to fix this."
498+
set Action = 6
499+
return 1
500+
}
501+
return 0
502+
}
503+
485504
}
486505

0 commit comments

Comments
 (0)