Skip to content

Commit e1584c6

Browse files
authored
Merge pull request #733 from intersystems/Issue-#709
Pull request for Issue 709 add locking branch to settings
2 parents a147078 + fc9d6d0 commit e1584c6

File tree

5 files changed

+38
-6
lines changed

5 files changed

+38
-6
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111
- Pull event handler that does an IPM uninstall and load to handle deletes (#631)
1212
- Partial support for production decomposition with the new interoperability editors
13+
- Added Lock Branch setting to prevent switching branches for a protected namespace (#709)
1314
- Tooltips on branch operations in Git UI (#725)
1415

1516
### Fixed

Diff for: cls/SourceControl/Git/Extension.cls

+12-4
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,22 @@ Method OnSourceMenuItem(name As %String, ByRef Enabled As %String, ByRef Display
181181
quit $$$OK
182182
}
183183

184+
set settings = ##class(SourceControl.Git.Settings).%New()
185+
if settings.lockBranch = 1
186+
{
187+
set BranchLocked = -1
188+
} else {
189+
set BranchLocked = 1
190+
}
191+
184192
if ##class(SourceControl.Git.Utils).BasicMode() {
185193
set Enabled = $CASE(name,
186194
"Status": 1,
187195
"GitWebUI" : 1,
188196
"Import": 1,
189197
"ImportForce": 1,
190-
"NewBranch": 1,
191-
"SwitchBranch": 1,
198+
"NewBranch": BranchLocked,
199+
"SwitchBranch": BranchLocked,
192200
"Sync": 1,
193201
"": 1,
194202
:-1
@@ -202,8 +210,8 @@ Method OnSourceMenuItem(name As %String, ByRef Enabled As %String, ByRef Display
202210
"ExportForce": 1,
203211
"Import": 1,
204212
"ImportForce": 1,
205-
"NewBranch": 1,
206-
"SwitchBranch": 1,
213+
"NewBranch": BranchLocked,
214+
"SwitchBranch": BranchLocked,
207215
"Push": 1,
208216
"PushForce": 1,
209217
"Fetch": 1,

Diff for: cls/SourceControl/Git/Settings.cls

+4
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ Property warnInstanceWideUncommitted As %Boolean [ InitialExpression = {##class(
6262
/// The name of the environment (DEVELOPMENT, TEST, LIVE)
6363
Property environmentName As %String(MAXLEN = "") [ InitialExpression = {##class(SourceControl.Git.Utils).EnvironmentName()} ];
6464

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

6770
Property favoriteNamespaces As %DynamicArray;
@@ -153,6 +156,7 @@ Method %Save() As %Status
153156
set @storage@("settings", "warnInstanceWideUncommitted") = ..warnInstanceWideUncommitted
154157
set @storage@("settings", "basicMode") = ..systemBasicMode
155158
set @storage@("settings", "environmentName") = ..environmentName
159+
set @storage@("settings", "lockBranch") = ..lockBranch
156160
if ..basicMode = "system" {
157161
kill @storage@("settings", "user", $username, "basicMode")
158162
} else {

Diff for: cls/SourceControl/Git/Utils.cls

+7-2
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ ClassMethod EnvironmentName() As %String
185185
quit $SYSTEM.Version.SystemMode()
186186
}
187187

188+
ClassMethod LockBranch() As %Boolean
189+
{
190+
quit $get(@..#Storage@("settings","lockBranch"),0)
191+
}
192+
188193
ClassMethod IsLIVE() As %Boolean
189194
{
190195
quit ..EnvironmentName()="LIVE"
@@ -2976,8 +2981,8 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status
29762981
try {
29772982
write !, "Exporting items..."
29782983
set rs = ##class(%Library.RoutineMgr).StudioOpenDialogFunc(
2979-
"*.mac,*.int,*.inc,*.cls,*.csp" // Spec
2980-
, , ,0 // SystemFiles
2984+
"*.mac,*.int,*.inc,*.cls,*.csp"
2985+
, , ,0 // SystemFiles
29812986
,1 // Flat
29822987
,0 // NotStudio
29832988
,0 // ShowGenerated

Diff for: csp/gitprojectsettings.csp

+14
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ body {
2222
text-align: left;
2323
}
2424

25+
2526
.btn-add {
2627
border:none;
2728
padding:0%;
@@ -126,6 +127,7 @@ body {
126127
set settings.compileOnImport = ($Get(%request.Data("compileOnImport", 1)) = 1)
127128
set settings.decomposeProductions = ($Get(%request.Data("decomposeProductions", 1)) = 1)
128129
set settings.decomposeProdAllowIDE = ($Get(%request.Data("decomposeProdAllowIDE", 1)) = 1)
130+
set settings.lockBranch = ($Get(%request.Data("lockBranch", 1)) = 1)
129131

130132
if ($Get(%request.Data("basicMode", 1)) = 1) {
131133
set settings.basicMode = 1
@@ -477,6 +479,18 @@ body {
477479
</div>
478480
</div>
479481
</div>
482+
<div class="form-group row mb-3">
483+
<label for="lockBranch" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top"
484+
title="If true, namespace will not have the option to create a New Branch or Switch Branch in source control menu">
485+
Lock Branch</label>
486+
<div class="col-sm-7">
487+
<div class="custom-control custom-switch custom-switch-no-border">
488+
<input class="custom-control-input" name="lockBranch" type="checkbox"
489+
id="lockBranch" #($select(settings.lockBranch:"checked",1:""))# value="1">
490+
<label class="custom-control-label" for="lockBranch"></label>
491+
</div>
492+
</div>
493+
</div>
480494

481495
<div class="form-group row mb-3 mapping-input-group">
482496
<div class="offset-sm-1 col-sm-3">

0 commit comments

Comments
 (0)