Skip to content

Pull request for Issue 709 add locking branch to settings #733

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

Merged
merged 14 commits into from
Apr 11, 2025
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Pull event handler that does an IPM uninstall and load to handle deletes (#631)
- Partial support for production decomposition with the new interoperability editors
- Added Lock Branch setting to prevent switching branches for a protected namespace (#709)
- Tooltips on branch operations in Git UI (#725)

### Fixed
Expand Down
16 changes: 12 additions & 4 deletions cls/SourceControl/Git/Extension.cls
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,22 @@ Method OnSourceMenuItem(name As %String, ByRef Enabled As %String, ByRef Display
quit $$$OK
}

set settings = ##class(SourceControl.Git.Settings).%New()
if settings.lockBranch = 1
{
set BranchLocked = -1
} else {
set BranchLocked = 1
}

if ##class(SourceControl.Git.Utils).BasicMode() {
set Enabled = $CASE(name,
"Status": 1,
"GitWebUI" : 1,
"Import": 1,
"ImportForce": 1,
"NewBranch": 1,
"SwitchBranch": 1,
"NewBranch": BranchLocked,
"SwitchBranch": BranchLocked,
"Sync": 1,
"": 1,
:-1
Expand All @@ -202,8 +210,8 @@ Method OnSourceMenuItem(name As %String, ByRef Enabled As %String, ByRef Display
"ExportForce": 1,
"Import": 1,
"ImportForce": 1,
"NewBranch": 1,
"SwitchBranch": 1,
"NewBranch": BranchLocked,
"SwitchBranch": BranchLocked,
"Push": 1,
"PushForce": 1,
"Fetch": 1,
Expand Down
4 changes: 4 additions & 0 deletions cls/SourceControl/Git/Settings.cls
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ Property warnInstanceWideUncommitted As %Boolean [ InitialExpression = {##class(
/// The name of the environment (DEVELOPMENT, TEST, LIVE)
Property environmentName As %String(MAXLEN = "") [ InitialExpression = {##class(SourceControl.Git.Utils).EnvironmentName()} ];

/// Whether the branch should or should not be locked down from changing namespaces
Property lockBranch As %Boolean [ InitialExpression = {##class(SourceControl.Git.Utils).LockBranch()} ];

Property Mappings [ MultiDimensional ];

Property favoriteNamespaces As %DynamicArray;
Expand Down Expand Up @@ -153,6 +156,7 @@ Method %Save() As %Status
set @storage@("settings", "warnInstanceWideUncommitted") = ..warnInstanceWideUncommitted
set @storage@("settings", "basicMode") = ..systemBasicMode
set @storage@("settings", "environmentName") = ..environmentName
set @storage@("settings", "lockBranch") = ..lockBranch
if ..basicMode = "system" {
kill @storage@("settings", "user", $username, "basicMode")
} else {
Expand Down
9 changes: 7 additions & 2 deletions cls/SourceControl/Git/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ ClassMethod EnvironmentName() As %String
quit $SYSTEM.Version.SystemMode()
}

ClassMethod LockBranch() As %Boolean
{
quit $get(@..#Storage@("settings","lockBranch"),0)
}

ClassMethod IsLIVE() As %Boolean
{
quit ..EnvironmentName()="LIVE"
Expand Down Expand Up @@ -2976,8 +2981,8 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status
try {
write !, "Exporting items..."
set rs = ##class(%Library.RoutineMgr).StudioOpenDialogFunc(
"*.mac,*.int,*.inc,*.cls,*.csp" // Spec
, , ,0 // SystemFiles
"*.mac,*.int,*.inc,*.cls,*.csp"
, , ,0 // SystemFiles
,1 // Flat
,0 // NotStudio
,0 // ShowGenerated
Expand Down
14 changes: 14 additions & 0 deletions csp/gitprojectsettings.csp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ body {
text-align: left;
}


.btn-add {
border:none;
padding:0%;
Expand Down Expand Up @@ -126,6 +127,7 @@ body {
set settings.compileOnImport = ($Get(%request.Data("compileOnImport", 1)) = 1)
set settings.decomposeProductions = ($Get(%request.Data("decomposeProductions", 1)) = 1)
set settings.decomposeProdAllowIDE = ($Get(%request.Data("decomposeProdAllowIDE", 1)) = 1)
set settings.lockBranch = ($Get(%request.Data("lockBranch", 1)) = 1)

if ($Get(%request.Data("basicMode", 1)) = 1) {
set settings.basicMode = 1
Expand Down Expand Up @@ -477,6 +479,18 @@ body {
</div>
</div>
</div>
<div class="form-group row mb-3">
<label for="lockBranch" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top"
title="If true, namespace will not have the option to create a New Branch or Switch Branch in source control menu">
Lock Branch</label>
<div class="col-sm-7">
<div class="custom-control custom-switch custom-switch-no-border">
<input class="custom-control-input" name="lockBranch" type="checkbox"
id="lockBranch" #($select(settings.lockBranch:"checked",1:""))# value="1">
<label class="custom-control-label" for="lockBranch"></label>
</div>
</div>
</div>

<div class="form-group row mb-3 mapping-input-group">
<div class="offset-sm-1 col-sm-3">
Expand Down
Loading