diff --git a/CHANGELOG.md b/CHANGELOG.md index 94069088..29cb8f48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - IRIS Business Intelligence items are mapped to the /dfi subdirectory by default (#428) - Intelligent merge conflict auto-resolution works for the common Business Rule case as well (#391) - All git commands run on the server, their output, and any associated sync output, are logged to a table for diagnostic purposes (#454) +- Added API method to automatically add proper %ALL mappings for git-source-control (#214) ### Fixed - Fixed display of other users' username in workspace view on Unix (#530) diff --git a/README.md b/README.md index ba2eeeb5..8ccade6d 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,14 @@ Embedded Git support for InterSystems platforms, supporting unified source contr } ``` +### Making available instance-wide via %ALL namespace + +To make git-source-control available to all namespaces on an instance without manually installing it in each, you can run: + +`do ##class(SourceControl.Git.API).MapEverywhere()` + +This will create the appropriate mappings to have all namespaces on the system use the version in the current namespace. Note, namespaces still must be configured independently. To undo this, you can delete the mappings from the %ALL namespace. + ## Basic Use ### Source Control diff --git a/cls/SourceControl/Git/API.cls b/cls/SourceControl/Git/API.cls index 558b3d68..4a2a9239 100644 --- a/cls/SourceControl/Git/API.cls +++ b/cls/SourceControl/Git/API.cls @@ -76,4 +76,9 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status quit ##class(SourceControl.Git.Utils).BaselineExport(pCommitMessage, pPushToRemote) } +ClassMethod MapEverywhere() +{ + Quit ##class(SourceControl.Git.Installer).MapEverywhere() +} + } diff --git a/cls/SourceControl/Git/Installer.cls b/cls/SourceControl/Git/Installer.cls new file mode 100644 index 00000000..387bfdd5 --- /dev/null +++ b/cls/SourceControl/Git/Installer.cls @@ -0,0 +1,57 @@ +/// Mostly used from SourceControl.Git.API:MapEverywhere +Class SourceControl.Git.Installer +{ + +ClassMethod MapEverywhere() +{ + set sc = $$$OK + try { + set ns = $namespace + set locDBDir = ##class(%SYS.Namespace).GetGlobalDest(ns,$Name(^IRIS.Msg("Studio"))) + set vars("LocalizationDB") = ..DatabaseDirToName(locDBDir) + set codeDBDir = ##class(%SYS.Namespace).GetPackageDest(ns,"SourceControl.Git") + set vars("RoutineDB") = ..DatabaseDirToName(codeDBDir) + $$$ThrowOnError(..RunMapEverywhere(.vars)) + } catch e { + set sc = e.AsStatus() + if '$quit { + write !,$System.Status.GetErrorText(sc) + } + } + quit sc +} + +ClassMethod DatabaseDirToName(dbDir As %String) As %String [ Private ] +{ + New $Namespace + Set $Namespace = "%SYS" + Set tSC = ##class(Config.Databases).DatabasesByDirectory($Piece(dbDir,"^"),$Piece(dbDir,"^",2),.tDBList) + $$$ThrowOnError(tSC) + If ($ListLength(tDBList) '= 1) { + // This is highly unexpected, but worth checking for anyway. + $$$ThrowStatus($$$ERROR($$$GeneralError,$$$FormatText("Could not find database name for '%1'",tDBDir))) + } + $$$ThrowOnError(tSC) + Quit $ListGet(tDBList) +} + +/// This is a method generator whose code is generated by XGL. +ClassMethod RunMapEverywhere(ByRef pVars, pLogLevel As %Integer = 3, pInstaller As %Installer.Installer, pLogger As %Installer.AbstractLogger) As %Status [ CodeMode = objectgenerator, Internal, Private ] +{ + quit ##class(%Installer.Manifest).%Generate(%compiledclass, %code, "MapEverywhere") +} + +XData MapEverywhere [ XMLNamespace = INSTALLER ] +{ + + + + + + + + + +} + +}