Repository navigation
Labels
customerBased on customer feedback (as opposed to something identified by developers)Based on customer feedback (as opposed to something identified by developers)good first issueGood for newcomersGood for newcomers
Description
I searched for an option to make generated files in VSCode readonly.
My first attempt was to contact the maintainers of vscode-objectscript if there was an option to achieve this.
intersystems-community/vscode-objectscript#1478
The result of this discussion lead to a change I made to Extension.cls of the installed git-source-control version 2.9.0:
diff --git a/cls/SourceControl/Git/Extension.cls b/cls/SourceControl/Git/Extension.cls
index 69fdaaa..2a6fd66 100644
+++ b/cls/SourceControl/Git/Extension.cls
@@ -432,8 +432,39 @@ ClassMethod FullExternalName(InternalName As %String) As %String
quit ##class(SourceControl.Git.Utils).FullExternalName(InternalName)
}
+ClassMethod IsGenerated(InternalName As %String) As %String
+{
+ Set name=##class(SourceControl.Git.Utils).NormalizeInternalName(InternalName),nm=$piece(name,".",1,*-1)
+ If nm="" Quit 0
+ /* // would make a loop?
+ Set generated=##class(%Studio.SourceControl.Interface).IsGenerated(name)
+ If generated'="" Quit generated
+ */
+ Set ext=$zconvert($piece(name,".",*),"U")
+ If ..IsCSPName(name) {
+ Quit 0
+ } ElseIf ext="CLS" {
+ Quit +$listget($get(^rINDEXCLASS($zconvert(nm,"U"))),10,0)
+ } ElseIf $$$rtnIsMAC(ext) {
+ Quit +$get(^rMAC(nm,0,"GENERATED"))
+ } ElseIf $$$rtnIsINT(ext) {
+ Quit +$get(^ROUTINE(nm,0,"GENERATED"))
+ } ElseIf $$$rtnIsINC(ext) {
+ Quit +$get(^rINC(nm,0,"GENERATED"))
+ } ElseIf ext="PRJ" {
+ Quit 0
+ } /*ElseIf ..UserType(name,.cls) {
+ Quit +$classmethod(cls,"IsGenerated",name)
+ } */
+ Quit 0
+}
+
+ClassMethod IsCSPName(name As %String) As %Boolean
+{
+ Quit $$IsCSPName^%occXMLExport(name)
+}
+
Method IsReadOnly(InternalName As %String) As %Boolean
{
+ quit:..IsGenerated(InternalName) 1
set settings = ##class(SourceControl.Git.Settings).%New()
quit (##class(SourceControl.Git.Utils).Locked()
&& '$get(^IRIS.Temp("sscProd",$job,"bypassLock")))
@@ -507,7 +538,8 @@ Method GetStatus(ByRef InternalName As %String, ByRef IsInSourceControl As %Bool
}
} else {
// If it doesn't show up in git status, there are no uncommitted changes so it should not be locked or checked out by any user
- set Editable=1, IsCheckedOut=0, UserCheckedOut=""
+ //set Editable=1
+ set IsCheckedOut=0, UserCheckedOut=""
if ##class(SourceControl.Git.Change).IsUncommitted(filename){
#; Remove the item from the list of uncommitted changes;
set sc=##class(SourceControl.Git.Change).RemoveUncommitted(filename,1,1)
Maybe this could be made an option just like "Treat Mapped Items as Read-only" in the settings of git-source-control
as an enhancement.
The "IsGenerated"/"IsCSPName" part is a modified excerpt of %Library.RoutineMgr.cls
Metadata
Metadata
Assignees
Labels
customerBased on customer feedback (as opposed to something identified by developers)Based on customer feedback (as opposed to something identified by developers)good first issueGood for newcomersGood for newcomers
Activity
RalphGauer-Paul commentedon Mar 31, 2025
One more addition to
IsReadonlyquit:((##class(SourceControl.Git.Utils).MappedItemsReadOnly())&&(##class(SourceControl.Git.Utils).FileIsMapped(InternalName))) 1RalphGauer-Paul commentedon Dec 12, 2025
Is isc-ksaduest still busy?
isc-tleavitt commentedon Dec 12, 2025
@RalphGauer-Paul thanks for the nudge.
@isc-pbarton could we get this in as an optional thing?
RalphGauer-Paul commentedon Jan 7, 2026
You seem to have forgotten to remove "set Editable=1" from Extension.cls:GetStatus in the program path for files that don't have an internal name.
Thus generated files that are not in source control will still be editable and these files aren't in source control normally.
RalphGauer-Paul commentedon Jan 13, 2026
...and last but not least:
Shouldn't Extension.cls:IsReadOnly respect the setting of "mappedItemsReadOnly"?
...
|| ((settings.mappedItemsReadOnly)&&(##class(SourceControl.Git.Utils).FileIsMapped(InternalName)))...
isc-pbarton commentedon Jan 13, 2026
Yes indeed it should. I've raised this as a separate issue: #918
Thank you for the feedback!