@@ -74,9 +74,13 @@ Method AfterUserAction(Type As %Integer, Name As %String, InternalName As %Strin
7474 if menu '= " %SourceMenu" , menu '=" %SourceContext" {
7575 quit $$$OK
7676 }
77- set InternalName = ##class (SourceControl.Git.Utils ).NormalizeInternalName (InternalName )
77+ set InternalName = ##class (SourceControl.Git.Utils ).NormalizeInternalName (InternalName , . fromWebApp )
7878 set context = ##class (SourceControl.Git.PackageManagerContext ).ForInternalName (InternalName )
7979 set ec = ##class (SourceControl.Git.Utils ).AfterUserAction (Type , Name , InternalName , .Answer , .Msg , .Reload )
80+ if fromWebApp {
81+ // Force reload and compile of actual item if underlying file has changed
82+ do ..OnBeforeLoad (InternalName ,1 ,1 )
83+ }
8084 quit ec
8185}
8286
@@ -125,6 +129,7 @@ Method OnSourceMenuItem(name As %String, ByRef Enabled As %String, ByRef Display
125129 " Status" : 1 ,
126130 " GitWebUI" : 1 ,
127131 " NewBranch" : 1 ,
132+ " SwitchBranch" : 1 ,
128133 " Sync" : 1 ,
129134 " " : 1 ,
130135 :-1
@@ -234,12 +239,12 @@ Method OnMenuItem(MenuName As %String, InternalName As %String, SelectedText As
234239
235240/// This is called before the actual load of data to give the chance
236241/// to load the item from an external format.
237- Method OnBeforeLoad (InternalName As %String , verbose As %Boolean ) As %Status
242+ Method OnBeforeLoad (InternalName As %String , verbose As %Boolean , compile As %Boolean = 0 ) As %Status
238243{
239244 set context = ##class (SourceControl.Git.PackageManagerContext ).ForInternalName (InternalName )
240245 set InternalName = ##class (SourceControl.Git.Utils ).NormalizeInternalName (InternalName )
241246 if ##class (SourceControl.Git.Utils ).IsInSourceControl (InternalName ) {
242- quit ##class (SourceControl.Git.Utils ).ImportItem (InternalName ,,0 )
247+ quit ##class (SourceControl.Git.Utils ).ImportItem (InternalName ,,0 , compile )
243248 }
244249 quit $$$OK
245250}
@@ -273,14 +278,21 @@ Method OnAfterSave(InternalName As %String, Object As %RegisteredObject = {$$$NU
273278{
274279 set sc = $$$OK
275280 try {
276- set InternalName = ##class (SourceControl.Git.Utils ).NormalizeInternalName (.InternalName )
281+ set InternalName = ##class (SourceControl.Git.Utils ).NormalizeInternalName (.InternalName ,. fromWebApp ,. fullExternalName )
277282 set context = ##class (SourceControl.Git.PackageManagerContext ).ForInternalName (InternalName )
278283 if ##class (SourceControl.Git.Utils ).IsNamespaceInGit () && ..IsInSourceControl (InternalName ) {
279- set filename = ##class (SourceControl.Git.Utils ).FullExternalName (InternalName )
280- $$$ThrowOnError(##class (SourceControl.Git.Utils ).RemoveRoutineTSH (InternalName ))
281- $$$ThrowOnError(##class (SourceControl.Git.Utils ).ExportItem (InternalName ))
282- if '##class (SourceControl.Git.Change ).IsUncommitted (filename ) {
283- $$$ThrowOnError(##class (SourceControl.Git.Change ).SetUncommitted (filename , " edit" , InternalName , $username , " " , 1 , " " , " " , 0 ))
284+ if fromWebApp {
285+ if fullExternalName = ##class (SourceControl.Git.Utils ).FullExternalName (InternalName ) {
286+ // Reimport item into database
287+ $$$ThrowOnError(##class (SourceControl.Git.Utils ).ImportItem (InternalName ,,1 ,1 ))
288+ }
289+ } else {
290+ set filename = ##class (SourceControl.Git.Utils ).FullExternalName (InternalName )
291+ $$$ThrowOnError(##class (SourceControl.Git.Utils ).RemoveRoutineTSH (InternalName ))
292+ $$$ThrowOnError(##class (SourceControl.Git.Utils ).ExportItem (InternalName ))
293+ if '##class (SourceControl.Git.Change ).IsUncommitted (filename ) {
294+ $$$ThrowOnError(##class (SourceControl.Git.Change ).SetUncommitted (filename , " edit" , InternalName , $username , " " , 1 , " " , " " , 0 ))
295+ }
284296 }
285297 }
286298 } catch e {
@@ -403,4 +415,3 @@ Method AddToSourceControl(InternalName As %String, Description As %String = "")
403415}
404416
405417}
406-
0 commit comments