Skip to content

Commit 4631654

Browse files
committed
Merge branch 'main' into fix-468
2 parents f0b6b5b + ba7fd7c commit 4631654

File tree

12 files changed

+243
-36
lines changed

12 files changed

+243
-36
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
### Fixed
1818
- Fixed display of other users' username in workspace view on Unix (#530)
19+
- Fix left-sidebar spacing (#525)
1920
- Fixed slowness loading some CSP pages with multiple instances sharing a webserver (#540)
21+
- Prevent direct commits to default merge branch in basic mode (#484)
2022
- Fixed GetContexts utils function to exclude implied namespaces from the list of namespaces(#468)
2123

2224
## [2.6.0] - 2024-10-07

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,18 @@ For those with less experience using source control, we recommend this [page](/d
4141
### Health Connect Cloud
4242
git-source control is the recommended source control for Health Connect Cloud. [This page](/docs/hcc.md) covers HCC specific usage of git-source-control, including the recommended development workflow, initial setup, and CICD pipelining.
4343
44-
### Studio
44+
### VSCode
45+
The same right click menus as in Studio live under "Server Source Control..." when right-clicking in a file (in the editor) or on a file when exploring an isfs folder. The top level "source control" menu is accessible through the command palette or the source control icon in the top right of the editor.
46+
47+
### Studio
48+
49+
Note: Studio has been deprecated. VSCode is the IDE recommended by InterSystems.
50+
4551
Add a file for tracking by right-clicking on it in the workspace/project view and choosing Git > Add.
4652
This same menu also has options to remove (stop tracking the file), discard changes (revert to the index), or commit changes.
4753
4854
You can browse file history and commit changes through a user interface launched from the top level Git > "Launch Git UI" menu item. There is also a page for configuring settings.
4955
50-
### VSCode
51-
The same right click menus as in Studio live under "Server Source Control..." when right-clicking in a file (in the editor) or on a file when exploring an isfs folder. The top level "source control" menu is accessible through the command palette or the source control icon in the top right of the editor.
52-
5356
## Notes
5457
5558
### Menu Options

cls/SourceControl/Git/Extension.cls

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ Method UserAction(Type As %Integer, Name As %String, InternalName As %String, Se
8181
quit $$$OK
8282
}
8383

84+
if (menuItemName = "Commit") {
85+
set defaultBasic = ##class(SourceControl.Git.Utils).InDefaultBranchBasicMode()
86+
if (defaultBasic) {
87+
Set Target = "WARNING: Please create a new branch before committing."
88+
set Action = 6
89+
quit $$$OK
90+
}
91+
}
92+
8493
if (menuItemName = "Commit") || (menuItemName = "Sync") {
8594
if ..CheckCommitterIdentity(settings, .Action, .Target) {
8695
quit $$$OK

cls/SourceControl/Git/Utils.cls

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,11 @@ ClassMethod Sync(Msg As %String, Output alert As %String) As %Status
535535
if '..HasRemoteRepo() {
536536
write "No remote repository configured: skipping fetch, pull and push"
537537
do ..SyncCommit(Msg)
538+
} elseif ..InDefaultBranchBasicMode() {
539+
// Do not commit to default merge branch in basic mode
540+
write "In Basic mode on default merge branch: skipping commit and push"
541+
do ..Fetch()
542+
do ..Pull()
538543
} else {
539544
do ..Fetch()
540545
do ..Pull()
@@ -2843,6 +2848,18 @@ ClassMethod SetConfiguredRemote(url) As %String
28432848
quit output
28442849
}
28452850

2851+
// Returns true if the current branch is the default merge branch and we are in basic mode
2852+
2853+
ClassMethod InDefaultBranchBasicMode() As %Boolean
2854+
{
2855+
set basicMode = ..BasicMode()
2856+
set default = ..DefaultMergeBranch()
2857+
do ##class(SourceControl.Git.Utils).RunGitCommand("branch",.err,.out,"--show-current")
2858+
set current = out.ReadLine()
2859+
if (basicMode && (default = current)) { quit 1 }
2860+
quit 0
2861+
}
2862+
28462863
ClassMethod ConfigureFavoriteNamespaces(username As %String, newNamespaces As %String)
28472864
{
28482865
// Delete all the GIT favorite links for the user

cls/SourceControl/Git/WebUIDriver.cls

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
3232
set responseJSON = {
3333
"environment": (##class(SourceControl.Git.Utils).EnvironmentName())
3434
}
35+
} elseif $extract(pagePath, 6, *) = "basic-and-default" {
36+
set responseJSON = {
37+
"basic-and-default": (##class(SourceControl.Git.Utils).InDefaultBranchBasicMode())
38+
}
3539
} else {
3640
set %response.Status = ##class(%CSP.REST).#HTTP404NOTFOUND
3741
set responseJSON = {"error":("invalid URI: " _ pagePath)}

csp/sync.csp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,32 @@
5757
border-radius: 4px;
5858
}
5959

60+
/* The alert message box */
61+
.alert {
62+
padding: 20px;
63+
background-color: #f44336; /* Red */
64+
color: white;
65+
margin-bottom: 15px;
66+
}
67+
68+
/* The close button */
69+
.closebtn {
70+
margin-left: 15px;
71+
color: white;
72+
font-weight: bold;
73+
float: right;
74+
font-size: 22px;
75+
line-height: 20px;
76+
cursor: pointer;
77+
transition: 0.3s;
78+
}
79+
80+
/* When moving the mouse over the close button */
81+
.closebtn:hover {
82+
color: black;
83+
}
84+
85+
6086
</style>
6187
</head>
6288
<body>
@@ -83,6 +109,16 @@
83109
<h1 class="text-center">Sync Repository</h1>
84110
<div class="row">
85111
<div class="offset-sm-2 col-sm-8">
112+
<server>
113+
if ##class(SourceControl.Git.Utils).InDefaultBranchBasicMode() {
114+
&html<
115+
<div class = "alert">
116+
<span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>
117+
<strong>Warning!</strong> Please change branches to make sure your changes are committed.
118+
</div>
119+
>
120+
}
121+
</server>
86122
<div style="display: #(fileSectionDisplay)#">
87123
<h3 class="section-header">Files to be committed with sync:</h3>
88124
<ul class="list-group">

git-webui/release/share/git-webui/webui/css/git-webui.css

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,12 @@ body {
192192
}
193193
#sidebar #sidebar-content h4 {
194194
vertical-align: baseline;
195-
margin: 0.5em 0 0 0;
195+
margin: 0.25em 0 0 0;
196196
}
197197
#sidebar #sidebar-content > section h4 {
198198
font-size: 125%;
199199
cursor: pointer;
200-
padding: 10px 0;
200+
padding: 5px 0;
201201
}
202202
#sidebar #sidebar-content #sidebar-workspace h4:before {
203203
content: url(../img/computer.svg);
@@ -208,6 +208,9 @@ body {
208208
#sidebar #sidebar-content #sidebarDiscarded h4:before {
209209
content: url(../img/discarded.svg);
210210
}
211+
#sidebar #sidebar-content #sidebarDiscarded h4 {
212+
border-bottom: 1px solid #5e5e5e;
213+
}
211214
#sidebar #sidebar-content #sidebar-remote h4:before {
212215
content: url(../img/daemon.svg);
213216
}
@@ -216,6 +219,9 @@ body {
216219
#sidebar #sidebar-content #sidebar-switch-branches h4:before {
217220
content: url(../img/branch.svg);
218221
}
222+
#sidebar #sidebar-content #space-filler {
223+
padding-bottom: 50px;
224+
}
219225
#sidebar #sidebar-content #sidebar-tags h4:before {
220226
content: url(../img/tag.svg);
221227
}
@@ -224,49 +230,53 @@ body {
224230
}
225231
#sidebar #sidebar-content #sidebar-vscode h4 {
226232
padding: 0px;
233+
margin-bottom: 10px;
227234
}
228235
#sidebar #sidebar-content #sidebar-vscode h4:before {
229236
content: url(../img/file.svg);
230237
}
231238
#sidebar #sidebar-content #sidebar-vscode {
232239
position: absolute;
233-
bottom: 90px;
240+
bottom: 60px;
234241
width: 16.7em;
235242
background-color: #333333;
236243
}
237244
#sidebar #sidebar-content #sidebar-context h4 {
238245
padding: 0px;
246+
margin-bottom: 10px;
239247
}
240248
#sidebar #sidebar-content #sidebar-context h4:before {
241249
content: url(../img/context.svg);
242250
}
243251
#sidebar #sidebar-content #sidebar-context {
244252
position: absolute;
245-
bottom: 50px;
253+
bottom: 30px;
246254
width: 16.7em;
247255
background-color: #333333;
248256
}
249257
#sidebar #sidebar-content #sidebar-settings h4 {
250258
padding: 0px;
259+
margin-bottom: 10px;
251260
}
252261
#sidebar #sidebar-content #sidebar-settings h4:before {
253262
content: url(../img/gear-fill.svg);
254263
}
255264
#sidebar #sidebar-content #sidebar-settings {
256265
position: absolute;
257-
bottom: 10px;
266+
bottom: 0;
258267
width: 16.7em;
259268
background-color: #333333;
260269
}
261270
#sidebar #sidebar-content #sidebar-home h4 {
262271
padding: 0px;
272+
margin-bottom: 10px;
263273
}
264274
#sidebar #sidebar-content #sidebar-home h4:before {
265275
content: url(../img/home.svg);
266276
}
267277
#sidebar #sidebar-content #sidebar-home {
268278
position: absolute;
269-
bottom: 130px;
279+
bottom: 90px;
270280
width: 16.7em;
271281
background-color: #333333;
272282
}
Lines changed: 1 addition & 1 deletion
Loading

git-webui/release/share/git-webui/webui/js/git-webui.js

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -994,20 +994,21 @@ webui.SideBarView = function(mainView, noEventHandlers) {
994994
'<h4>Discarded Files</h4>' +
995995
'</section>' +
996996
'<section id="sidebar-local-branches">' +
997-
'<h4 class="mt-3">Local Branches' +
997+
'<h4 class="mt-1">Local Branches' +
998998
'<button type="button" class="btn btn-default btn-sidebar-icon btn-add shadow-none" >' +
999999
webui.circlePlusIcon+
10001000
'</button>' + '</h4>' +
10011001
'</section>' +
10021002
'<section id="sidebar-remote-branches">' +
1003-
'<h4 class="mt-3">Remote Branches' +
1003+
'<h4 class="mt-1">Remote Branches' +
10041004
'<button type="button" class="btn btn-default btn-sidebar-icon btn-prune-remote-branches shadow-none" >'+
10051005
webui.refreshIcon+
10061006
'</button>' +'</h4>' +
10071007
'</section>' +
10081008
'<section id="sidebar-tags">' +
10091009
'<h4>Tags</h4>' +
10101010
'</section>' +
1011+
'<section id="space-filler"></section>'+
10111012
'<section id="sidebar-settings">' +
10121013
'<h4>Settings</h4>' +
10131014
'</section>' +
@@ -2600,13 +2601,20 @@ webui.NewChangedFilesView = function(workspaceView) {
26002601
});
26012602
$("#commitBtn").off("click");
26022603
$("#commitBtn").on("click", function() {
2603-
if (selectedItemsFromOtherUser.length > 0) {
2604-
self.confirmActionOnOtherUsersChanges("commit");
2605-
} else {
2606-
var commitMessage = $('#commitMsg').val();
2607-
self.commit(commitMessage, $("#commitMsgDetail").val());
2608-
}
2609-
2604+
// Make sure we are not commiting to default merge branch in basic mode
2605+
$.get("api/basic-and-default", function (data) {
2606+
var basicAndDefault = JSON.parse(data)["basic-and-default"]
2607+
if (basicAndDefault == "1") {
2608+
self.noCommitsOnDefault();
2609+
} else {
2610+
if (selectedItemsFromOtherUser.length > 0) {
2611+
self.confirmActionOnOtherUsersChanges("commit");
2612+
} else {
2613+
var commitMessage = $('#commitMsg').val();
2614+
self.commit(commitMessage, $("#commitMsgDetail").val());
2615+
}
2616+
}
2617+
})
26102618
});
26112619

26122620
$("#amendBtn").off("click");
@@ -2751,6 +2759,55 @@ webui.NewChangedFilesView = function(workspaceView) {
27512759
});
27522760
}
27532761

2762+
// Popup for when trying to commit to default merge branch in basic mode
2763+
self.noCommitsOnDefault = function () {
2764+
function removePopup(popup) {
2765+
$(popup).children(".modal-fade").modal("hide");
2766+
$(".modal-backdrop").remove();
2767+
$("#noCommitsDefault").remove();
2768+
}
2769+
2770+
var popup = $(
2771+
'<div class="modal fade" tabindex="-1" id="noCommitsDefault" role="dialog" data-backdrop="static">' +
2772+
'<div class="modal-dialog modal-md" role="document">' +
2773+
'<div class="modal-content">' +
2774+
'<div class="modal-header">' +
2775+
'<h5 class="modal-title">Cannot commit to Default Branch</h5>' +
2776+
'<button type="button" class="btn btn-default close" data-dismiss="modal">' + webui.largeXIcon + '</button>' +
2777+
'</div>' +
2778+
'<div class="modal-body">' +
2779+
'<div class="row">' +
2780+
'<div class="col-sm-1">' +
2781+
webui.warningIcon +
2782+
'</div>' +
2783+
'<div class="col-sm-11">' +
2784+
'<p>You cannot commit directly to the default merge branch while using basic mode. Please switch to another branch.</p>' +
2785+
'</div>' +
2786+
'</div>' +
2787+
'</div>' +
2788+
'<div class="modal-footer"></div>' +
2789+
'</div>' +
2790+
'</div>' +
2791+
'</div>'
2792+
)[0];
2793+
2794+
$("body").append(popup);
2795+
2796+
var popupFooter = $(".modal-footer", popup)[0];
2797+
webui.detachChildren(popupFooter);
2798+
2799+
$(
2800+
'<button class="btn btn-sm btn-secondary action-btn" id="noCommitDefaultButton">Ok</button>'
2801+
).appendTo(popupFooter);
2802+
2803+
$(popup).modal('show');
2804+
2805+
$("#noCommitsDefault").find(".close, #noCommitDefaultButton").click(function() {
2806+
removePopup(popup);
2807+
})
2808+
2809+
};
2810+
27542811
self.confirmActionOnOtherUsersChanges = function(action) {
27552812
function removeWarningModal(popup) {
27562813
$(popup).children(".modal-fade").modal("hide");

0 commit comments

Comments
 (0)