Skip to content

Commit 338556e

Browse files
committed
feat: instance wide uncommitted queue check for opened file
1 parent b401960 commit 338556e

File tree

4 files changed

+64
-29
lines changed

4 files changed

+64
-29
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.5.0] - Unreleased
9+
10+
### Added
11+
- Files in uncommitted queue in any namespace warn users when opened except for in VSCode (#370)
12+
813
## [2.4.1] - Unreleased
914

1015
### Fixed

cls/SourceControl/Git/Change.cls

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,46 @@ ClassMethod RefreshUncommitted(Display = 0, IncludeRevert = 0, Output gitFiles,
185185
quit sc
186186
}
187187

188+
Query InstanceUncommitted() As %Query(ROWSPEC = "InternalName:%String,User:%String")
189+
{
190+
}
191+
192+
ClassMethod InstanceUncommittedExecute(ByRef qHandle As %Binary) As %Status
193+
{
194+
set qHandle("q") = "SELECT InternalName, ChangedBy FROM SourceControl_Git.Change"
195+
set namespaces = ##class(SourceControl.Git.Utils).GetGitEnabledNamespaces()
196+
set tPtr = 0
197+
set qHandle("i") = 1
198+
while $LISTNEXT(namespaces, tPtr, tValue) {
199+
set namespace = $ZCONVERT(tValue, "U")
200+
set $NAMESPACE = namespace
201+
set resultSet = ##class(%SQL.Statement).%ExecDirect(, qHandle("q"))
202+
while resultSet.%Next() {
203+
set qHandle("changes", $increment(qHandle("changes")), "InternalName") = resultSet.%GetData(1)
204+
set qHandle("changes", qHandle("changes"), "User") = resultSet.%GetData(2)
205+
}
206+
}
207+
208+
Quit $$$OK
209+
}
210+
211+
ClassMethod InstanceUncommittedFetch(ByRef qHandle As %Binary, ByRef Row As %List, ByRef AtEnd As %Integer = 0) As %Status [ PlaceAfter = InstanceUncommittedExecute ]
212+
{
213+
set i = qHandle("i")
214+
set Row = $listbuild(qHandle("changes", i, "InternalName"), qHandle("changes", i, "User"))
215+
if i = qHandle("changes") {
216+
set AtEnd = 1
217+
} else {
218+
set qHandle("i") = $increment(qHandle("i"))
219+
}
220+
Quit $$$OK
221+
}
222+
223+
ClassMethod InstanceUncommittedClose(ByRef qHandle As %Binary) As %Status [ PlaceAfter = InstanceUncommittedFetch ]
224+
{
225+
Quit $$$OK
226+
}
227+
188228
Storage Default
189229
{
190230
<Data name="ChangeDefaultData">

cls/SourceControl/Git/Extension.cls

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ Method UserAction(Type As %Integer, Name As %String, InternalName As %String, Se
5050
set Name = "%SourceMenu,Status"
5151
}
5252

53+
if (Type = 1) && (Name = 3) {
54+
set user = ""
55+
if ##class(SourceControl.Git.Utils).FileIsUncommitted(InternalName, .user) && (user '= $USERNAME){
56+
set Target = InternalName _ " is currently being modified by " _ user
57+
write !, Target
58+
set Action = 6
59+
}
60+
}
61+
5362
if (Type = 1) && ((Name = 1) || (Name = 7)) {
5463
do ..AddToSourceControl(InternalName)
5564
}

cls/SourceControl/Git/Utils.cls

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,7 +2423,7 @@ ClassMethod GetGitEnabledNamespaces() As %String
24232423
{
24242424
// Get all namespaces
24252425
set allNamespaces = ""
2426-
do ##class(%SYS.Namespace).GetList(.allNamespaces)
2426+
do ##class(%SYS.Namespace).ListAll(.allNamespaces)
24272427

24282428
set enabledNamespaces = ""
24292429

@@ -2460,38 +2460,19 @@ ClassMethod GetGitEnabledNamespaces() As %String
24602460
quit enabledNamespaces
24612461
}
24622462

2463-
2464-
Query InstanceUncommitted() As %Query()
2463+
ClassMethod FileIsUncommitted(InternalName As %String, Output User) As %Boolean
24652464
{
2466-
}
2467-
2468-
ClassMethod InstanceUncommittedExecute(ByRef qHandle As %Binary) As %Status {
2469-
set qHandle("q") = "SELECT InternalName FROM SourceControl_Git.Change"
2470-
set namespaces = ..GetGitEnabledNamespaces()
2471-
set tPtr = 0
2472-
while $LISTNEXT(namespaces, tPtr, tValue) {
2473-
set qHandle("n", $increment(qHandle("n"))) = $ZCONVERT(tValue, "U")
2474-
}
2475-
2476-
Quit $$$OK
2477-
}
2478-
2479-
ClassMethod InstanceUncommittedFetch(ByRef qHandle As %Binary, ByRef Row As %List, ByRef AtEnd As %Integer = 0) As %Status [PlaceAfter = InstanceUncommittedExecute]{
2480-
#dim tResult as %SQL.StatementResult
2481-
New $Namespace
2482-
set tSC = $$$OK
2483-
try {
2484-
set namespace = ""
2485-
for {
2486-
set namespace = $ORDER(
2465+
set isUncommitted = 0
2466+
set resultSet = ##class(SourceControl.Git.Change).InstanceUncommittedFunc()
2467+
while resultSet.%Next() {
2468+
set fileName = resultSet.InternalName
2469+
if InternalName = fileName {
2470+
set isUncommitted = 1
2471+
set User = resultSet.User
24872472
}
2488-
} catch e {
2489-
set tSC = e.AsStatus()
24902473
}
2491-
}
2492-
2493-
ClassMethod InstanceUncommittedClose(ByRef qHandle As %Binary) As %Status [PlaceAfter = InstanceUncommittedFetch] {
24942474

2475+
quit isUncommitted
24952476
}
24962477

24972478
ClassMethod BuildCEInstallationPackage(ByRef destination As %String) As %Status

0 commit comments

Comments
 (0)