Skip to content

Commit 4e642e5

Browse files
committed
Alert user about commits in basic mode on default branch
Tell the user that they cannot commit when in basic mode and default branch
1 parent a1662e5 commit 4e642e5

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

cls/SourceControl/Git/Extension.cls

Lines changed: 10 additions & 2 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
@@ -220,8 +229,7 @@ Method OnSourceMenuContextItem(itemName As %String, menuItemName As %String, ByR
220229
} elseif menuItemName = "Commit" {
221230
set Enabled = 1
222231
do ..GetStatus(.itemName, .isInSourceControl, .isEditable,.isCheckedOut,.userCheckedOut)
223-
set defaultBasic = ##class(SourceControl.Git.Utils).InDefaultBranchBasicMode()
224-
if '(##class(SourceControl.Git.Change).IsUncommitted(##class(SourceControl.Git.Utils).FullExternalName(itemName))) || ($username '= userCheckedOut) || (defaultBasic) {
232+
if '(##class(SourceControl.Git.Change).IsUncommitted(##class(SourceControl.Git.Utils).FullExternalName(itemName))) || ($username '= userCheckedOut) {
225233
set Enabled = 0
226234
}
227235
} elseif ##class(SourceControl.Git.Utils).IsInSourceControl(itemName) {

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">

0 commit comments

Comments
 (0)