Skip to content
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

Handling of generated files #712

Open
RalphGauer-Paul opened this issue Feb 25, 2025 · 0 comments
Open

Handling of generated files #712

RalphGauer-Paul opened this issue Feb 25, 2025 · 0 comments
Labels
customer Based on customer feedback (as opposed to something identified by developers) good first issue Good for newcomers

Comments

@RalphGauer-Paul
Copy link

RalphGauer-Paul commented Feb 25, 2025

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

@isc-pbarton isc-pbarton added good first issue Good for newcomers customer Based on customer feedback (as opposed to something identified by developers) labels Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer Based on customer feedback (as opposed to something identified by developers) good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants