Skip to content

Handling of generated files #712

Closed

Description

@RalphGauer-Paul

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

Activity

  1. added
    customerBased on customer feedback (as opposed to something identified by developers)
    on Feb 25, 2025
  2. RalphGauer-Paul commented on Mar 31, 2025

    @RalphGauer-Paul
    Author

    One more addition to IsReadonly
    quit:((##class(SourceControl.Git.Utils).MappedItemsReadOnly())&&(##class(SourceControl.Git.Utils).FileIsMapped(InternalName))) 1

  3. RalphGauer-Paul commented on Dec 12, 2025

    @RalphGauer-Paul
    Author

    Is isc-ksaduest still busy?

  4. isc-tleavitt commented on Dec 12, 2025

    @isc-tleavitt
    Collaborator

    @RalphGauer-Paul thanks for the nudge.

    @isc-pbarton could we get this in as an optional thing?

  5. RalphGauer-Paul commented on Jan 7, 2026

    @RalphGauer-Paul
    Author

    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.

  6. RalphGauer-Paul commented on Jan 13, 2026

    @RalphGauer-Paul
    Author

    ...and last but not least:
    Shouldn't Extension.cls:IsReadOnly respect the setting of "mappedItemsReadOnly"?
    ...
    || ((settings.mappedItemsReadOnly)&&(##class(SourceControl.Git.Utils).FileIsMapped(InternalName)))
    ...

  7. isc-pbarton commented on Jan 13, 2026

    @isc-pbarton
    Collaborator

    Yes indeed it should. I've raised this as a separate issue: #918
    Thank you for the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

customerBased on customer feedback (as opposed to something identified by developers)good first issueGood for newcomers

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions