Skip to content

Fixes to instance-wide uncommitted queue #674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed errors on production page when item settings need to be XML escaped (#667)
- Fixed push button not appearing after commit (#654)
- Fixed merge conflict resolution on stash popping (#531)
- Improvements to the performance of the instance-wide uncommitted check (#674)
- Fix "Max $ZF String" error when committing lots of files (#617)

## [2.8.0] - 2024-12-06

### Added
Expand Down
17 changes: 9 additions & 8 deletions cls/SourceControl/Git/Change.cls
Original file line number Diff line number Diff line change
Expand Up @@ -202,24 +202,25 @@ Query InstanceUncommitted() As %Query(ROWSPEC = "InternalName:%String,User:%Stri

ClassMethod InstanceUncommittedExecute(ByRef qHandle As %Binary) As %Status
{
set qHandle("q") = "SELECT InternalName, ChangedBy FROM SourceControl_Git.Change"
set initNS = $namespace
&sql(DECLARE InstanceCursor CURSOR FOR SELECT InternalName, ChangedBy into :internalName, :changedBy from SourceControl_Git.Change)
set namespaces = ##class(SourceControl.Git.Utils).GetGitEnabledNamespaces()
set tPtr = 0
set qHandle("i") = 1
new $namespace
kill ^||InstanceUncommitted
while $LISTNEXT(namespaces, tPtr, tValue) {
set namespace = $ZCONVERT(tValue, "U")
if '(namespace [ "^") {
if '(namespace [ "^") && (namespace '= initNS) {
set $NAMESPACE = namespace

&sql(OPEN InstanceCursor)
throw:SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, %msg)
&sql(FETCH InstanceCursor)
while(SQLCODE = 0) {
set qHandle("changes", $increment(qHandle("changes")), "InternalName") = internalName
set qHandle("changes", qHandle("changes"), "User") = changedBy
set qHandle("changes", qHandle("changes"), "Namespace") = namespace
set ^||InstanceUncommitted("changes", $increment(^||InstanceUncommitted("changes")), "InternalName") = internalName
set ^||InstanceUncommitted("changes", ^||InstanceUncommitted("changes"), "User") = changedBy
set ^||InstanceUncommitted("changes", ^||InstanceUncommitted("changes"), "Namespace") = namespace
&sql(FETCH InstanceCursor)
}
&sql(CLOSE InstanceCursor)
Expand All @@ -232,10 +233,10 @@ ClassMethod InstanceUncommittedExecute(ByRef qHandle As %Binary) As %Status
ClassMethod InstanceUncommittedFetch(ByRef qHandle As %Binary, ByRef Row As %List, ByRef AtEnd As %Integer = 0) As %Status [ PlaceAfter = InstanceUncommittedExecute ]
{
set i = qHandle("i")
if $data(qHandle("changes",i))=10 {
set Row = $listbuild(qHandle("changes", i, "InternalName"), qHandle("changes", i, "User"), qHandle("changes", i, "Namespace"))
if $data(^||InstanceUncommitted("changes",i))=10 {
set Row = $listbuild(^||InstanceUncommitted("changes", i, "InternalName"), ^||InstanceUncommitted("changes", i, "User"), ^||InstanceUncommitted("changes", i, "Namespace"))
}
if i >= $get(qHandle("changes"),0) {
if i >= $get(^||InstanceUncommitted("changes"),0) {
set AtEnd = 1
} else {
set qHandle("i") = $increment(qHandle("i"))
Expand Down
34 changes: 17 additions & 17 deletions cls/SourceControl/Git/Extension.cls
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,23 @@ Method UserAction(Type As %Integer, Name As %String, InternalName As %String, Se
}

if (Type = 1) && (Name = 3) {
if settings.warnInstanceWideUncommitted {
// if item is being edited in a different namespace, opening it will display an alert. Editing in this namespace will remove the alert.
set filename = ##class(SourceControl.Git.Utils).FullExternalName(.InternalName)
do ##class(SourceControl.Git.Change).GetUncommitted(filename,.tAction)
do ..GetStatus(.InternalName, .isInSourceControl, .isEditable,.isCheckedOut,.userCheckedOut)
if '$data(tAction) {
set user = "", inNamespace = ""
if 'isEditable || ##class(SourceControl.Git.Utils).Locked() {
set Target = "Warning: Attempting to edit read-only file"
write !, Target
set Action = 6
} elseif ##class(SourceControl.Git.Utils).InstanceWideUncommittedCheck(InternalName, .user, .inNamespace) {
set Target = "Warning: Item " _ InternalName _ " is currently being modified by " _ user _ " in namespace " _ inNamespace _ "."
write !, Target
set Action = 6
}
}
set filename = ##class(SourceControl.Git.Utils).FullExternalName(.InternalName)
do ##class(SourceControl.Git.Change).GetUncommitted(filename,.tAction)
do ..GetStatus(.InternalName, .isInSourceControl, .isEditable,.isCheckedOut,.userCheckedOut)
if '$data(tAction) {
set user = "", inNamespace = ""
if 'isEditable || ##class(SourceControl.Git.Utils).Locked() {
set Target = "Warning: Attempting to edit read-only file"
write !, Target
set Action = 6
} elseif settings.warnInstanceWideUncommitted
&& '(##class(SourceControl.Git.Utils).ItemIsProductionToDecompose(InternalName))
&& ##class(SourceControl.Git.Utils).InstanceWideUncommittedCheck(InternalName, .user, .inNamespace) {
// if item is being edited in a different namespace, opening it will display an alert. Editing in this namespace will remove the alert.
set Target = "Warning: Item " _ InternalName _ " is currently being modified by " _ user _ " in namespace " _ inNamespace _ "."
write !, Target
set Action = 6
}
}
}

Expand Down
Loading