Skip to content

Commit 1051b04

Browse files
authored
Merge branch 'main' into sync-iris-codebase-change
2 parents 5063ca0 + 4834974 commit 1051b04

File tree

6 files changed

+55
-5
lines changed

6 files changed

+55
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- Now skips files belonging to other git enabled packages in `##class(SourceControl.Git.Change).RefreshUncommitted()` (#347)
1818
- Added a new "Branch" parameter to `##class(SourceControl.Git.PullEventHandler)` (#351)
1919
- Command-line utility to do a baseline export of items in a namespace
20+
- 'New Branch' menu option in basic now will create new branches from the configured default merge branch (#366)
21+
- Merging back with the default merge branch is now a part of the basic mode's Sync flow (#366)
2022

2123
### Fixed
22-
- Modifications to local repo files are now synced with IRIS
23-
24+
- Modifications to local repo files are now synced with IRIS (#153)
25+
- Menu items names are properly translated from internal name in VSCode, Management Portal (#372)
2426

2527
## [2.3.1] - 2024-04-30
2628

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ It is important for the namespace temp folder to be owned by the user IRIS runs
8686
If you want to interact with remotes from VSCode/Studio directly (e.g., to push/pull), you must use ssh (rather than https), create a public/private key pair to identify the instance (not yourself), configure the private key file for use in Settings, and configure the public key as a deploy key in the remote(s).
8787
8888
#### IRIS Privileges
89-
For developers to be able to run this extension, they'll need the USE privilege on %System_Callout.
89+
For developers to be able to run this extension, they'll need the following privileges:
90+
- the USE privilege on %System_Callout
91+
- SQL SELECT privileges on %Studio_SourceControl.Change and SourceControl_Git.Change
9092
9193
### Setting up multiple GitHub deploy keys on one machine
9294

cls/SourceControl/Git/Extension.cls

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ Method LocalizeName(name As %String) As %String
106106

107107
Method OnSourceMenuItem(name As %String, ByRef Enabled As %String, ByRef DisplayName As %String, InternalName As %String) As %Status
108108
{
109-
110109
if name = "Settings" {
111110
set Enabled = 1
112111
quit $$$OK
@@ -125,6 +124,7 @@ Method OnSourceMenuItem(name As %String, ByRef Enabled As %String, ByRef Display
125124
set Enabled = $CASE(name,
126125
"Status": 1,
127126
"GitWebUI" : 1,
127+
"NewBranch": 1,
128128
"Sync": 1,
129129
"": 1,
130130
:-1
@@ -159,6 +159,9 @@ Method OnSourceMenuItem(name As %String, ByRef Enabled As %String, ByRef Display
159159
} else {
160160
set Enabled = -1
161161
}
162+
if (name '= "") {
163+
set DisplayName = ..LocalizeName(name)
164+
}
162165
quit $$$OK
163166
}
164167

@@ -187,6 +190,9 @@ Method OnSourceMenuContextItem(itemName As %String, menuItemName As %String, ByR
187190
} else {
188191
set Enabled = $case(menuItemName, "AddToSC":1,:-1)
189192
}
193+
if (menuItemName '= "") {
194+
set DisplayName = ..LocalizeName(menuItemName)
195+
}
190196
quit $$$OK
191197
}
192198

cls/SourceControl/Git/Settings.cls

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ Property userBasicMode As %String [ InitialExpression = {##class(SourceControl.G
4141
/// The system's default mode. If true, the system defaults to basic mode
4242
Property systemBasicMode As %Boolean [ InitialExpression = {##class(SourceControl.Git.Utils).SystemBasicMode()} ];
4343

44+
/// In Basic mode, Sync will merge changes from this remote branch
45+
Property defaultMergeBranch As %String [ InitialExpression = {##class(SourceControl.Git.Utils).DefaultMergeBranch()} ];
46+
4447
Property Mappings [ MultiDimensional ];
4548

4649
Method %OnNew() As %Status
@@ -93,6 +96,7 @@ Method %Save() As %Status
9396
set @storage@("settings","percentClassReplace") = ..percentClassReplace
9497
set @storage@("settings","settingsUIReadOnly") = ..settingsUIReadOnly
9598
set @storage@("settings", "mappedItemsReadOnly") = ..mappedItemsReadOnly
99+
set @storage@("settings", "defaultMergeBranch") = ..defaultMergeBranch
96100
set @storage@("settings", "basicMode") = ..systemBasicMode
97101
if ..basicMode = "system" {
98102
kill @storage@("settings", "user", $username, "basicMode")

cls/SourceControl/Git/Utils.cls

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ ClassMethod SystemBasicMode() As %Boolean
128128
quit $get(@..#Storage@("settings", "basicMode"), 0)
129129
}
130130

131+
ClassMethod DefaultMergeBranch() As %String
132+
{
133+
quit $get(@..#Storage@("settings", "defaultMergeBranch"), "")
134+
}
135+
131136
ClassMethod MappedItemsReadOnly() As %Boolean
132137
{
133138
quit $get(@..#Storage@("settings", "mappedItemsReadOnly"), 1)
@@ -335,6 +340,16 @@ ClassMethod Commit(InternalName As %String, Message As %String = "example commit
335340

336341
ClassMethod NewBranch(newBranchName As %String) As %Status
337342
{
343+
set settings = ##class(SourceControl.Git.Settings).%New()
344+
if (settings.basicMode) && (settings.defaultMergeBranch '= ""){
345+
do ..RunGitWithArgs(.errStream, .outStream, "checkout", settings.defaultMergeBranch)
346+
do ..PrintStreams(errStream, outStream)
347+
kill errStream, outStream
348+
do ..RunGitWithArgs(.errStream, .outStream, "pull")
349+
do ..PrintStreams(errStream, outStream)
350+
kill errStream, outStream
351+
}
352+
338353
do ..RunGitWithArgs(.errStream, .outStream, "checkout", "-b", newBranchName)
339354
do ..PrintStreams(errStream, outStream)
340355
quit $$$OK
@@ -379,6 +394,17 @@ ClassMethod StageAddedFiles()
379394
}
380395
}
381396

397+
/// Merges the files from the configured branch as part of the Sync operation
398+
ClassMethod MergeDefaultRemoteBranch()
399+
{
400+
set settings = ##class(SourceControl.Git.Settings).%New()
401+
set defaultMergeBranch = settings.defaultMergeBranch
402+
if defaultMergeBranch '= "" {
403+
do ..RunGitWithArgs(.errStream, .outStream, "rebase", defaultMergeBranch)
404+
do ..PrintStreams(errStream, outStream)
405+
}
406+
}
407+
382408
/// Converts the DynamicArray into a list and calls the SourceControl.Git.Change RemoveUncommitted method on the newly created list
383409
ClassMethod ClearUncommitted(filesWithActions) As %Status
384410
{
@@ -405,6 +431,9 @@ ClassMethod Sync(Msg As %String) As %Status
405431
do ..Pull()
406432
do ..SyncCommit(Msg)
407433
do ..Push()
434+
do ..MergeDefaultRemoteBranch()
435+
do ..Push()
436+
408437
}
409438

410439
quit $$$OK

csp/gitprojectsettings.csp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ body {
8080
set $Property(settings,param) = $Get(%request.Data(param,1))
8181
}
8282
if ('settings.settingsUIReadOnly) {
83-
for param="gitBinPath","namespaceTemp","privateKeyFile","pullEventClass","percentClassReplace" {
83+
for param="gitBinPath","namespaceTemp","privateKeyFile","pullEventClass","percentClassReplace", "defaultMergeBranch" {
8484
set $Property(settings,param) = $Get(%request.Data(param,1))
8585
}
8686

@@ -308,6 +308,13 @@ body {
308308

309309

310310
</div>
311+
312+
<div class="form-group row mb-3">
313+
<label for="defaultMergeBranch" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="In basic mode, the Sync operation will merge changes from this remote branch (leave blank for no branch)">Default merge branch</label>
314+
<div class="col-sm-7">
315+
<input type="text" class="form-control" id="defaultMergeBranch" name="defaultMergeBranch" value='#(..EscapeHTML(settings.defaultMergeBranch))#' placeholder="sample-remote-branch">
316+
</div>
317+
</div>
311318

312319
<div class="form-group row mb-3">
313320
<label for="mappedItemsReadOnly" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Whether items mapped from a database other than this namespace's default routine database should be read-only. If enabled, mapped items won't be saved to source control or exported. NOTE: These are different from the mappings configured in this settings page"> Treat Mapped Items as Read-only</label>

0 commit comments

Comments
 (0)