Skip to content

Commit 974e2b6

Browse files
committed
Merge remote-tracking branch 'origin/only-commit-msg-when-changes' into fix-production-conflicts
2 parents be5a51d + ae774d0 commit 974e2b6

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
- Menu items names are properly translated from internal name in VSCode, Management Portal (#372)
2828
- Now has proper locking behavior in `##class(SourceControl.Git.WebUIDriver).HandleRequest()`(#385)
2929
- Git operations from the WebUI now don't unlock the session if they aren't read-only
30+
- Syncing only prompts users for a commit message if there are uncommitted files (#390)
3031

3132
## [2.3.1] - 2024-04-30
3233

cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@ Method DeleteFile(item As %String) As %Status
7171
}
7272

7373
}
74+

cls/SourceControl/Git/Utils.cls

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,15 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe
253253
set Action = 7
254254
quit $$$OK
255255
} elseif (menuItemName = "Sync") {
256-
set Target = "Enter a commit message for the sync operation"
257-
set Action = 7
258-
set Msg = ..PreSync()
256+
if ..CheckForUncommittedFiles() {
257+
set Target = "Enter a commit message for the sync operation"
258+
set Action = 7
259+
set Msg = ..PreSync()
260+
} else {
261+
do ..Sync("")
262+
}
263+
264+
259265
quit $$$OK
260266
} elseif (menuItemName = "Push") {
261267
quit ..Push()
@@ -379,17 +385,32 @@ ClassMethod PreSync() As %String
379385
/// Commits all the files as needed by the Sync operation
380386
ClassMethod SyncCommit(Msg As %String) As %Status
381387
{
382-
set uncommittedFilesWithAction = ##class(SourceControl.Git.Utils).UncommittedWithAction().%Get("user")
383-
set username = ..GitUserName()
384-
set email = ..GitUserEmail()
385-
set author = username_" <"_email_">"
386-
do ..RunGitWithArgs(.errStream, .outStream, "commit", "--author", author, "-m", Msg)
387-
do ..PrintStreams(errStream, outStream)
388-
$$$QuitOnError(..ClearUncommitted(uncommittedFilesWithAction))
389-
$$$QuitOnError(##class(SourceControl.Git.Change).RefreshUncommitted(,,,1))
388+
389+
if ..CheckForUncommittedFiles() {
390+
set uncommittedFilesWithAction = ##class(SourceControl.Git.Utils).UncommittedWithAction().%Get("user")
391+
set username = ..GitUserName()
392+
set email = ..GitUserEmail()
393+
set author = username_" <"_email_">"
394+
do ..RunGitWithArgs(.errStream, .outStream, "commit", "--author", author, "-m", Msg)
395+
do ..PrintStreams(errStream, outStream)
396+
$$$QuitOnError(..ClearUncommitted(uncommittedFilesWithAction))
397+
$$$QuitOnError(##class(SourceControl.Git.Change).RefreshUncommitted(,,,1))
398+
}
399+
390400
quit $$$OK
391401
}
392402

403+
ClassMethod CheckForUncommittedFiles() As %Boolean
404+
{
405+
set uncommittedFilesWithAction = ##class(SourceControl.Git.Utils).UncommittedWithAction().%Get("user")
406+
set valInArr = uncommittedFilesWithAction.%Pop()
407+
if valInArr = "" {
408+
return 0
409+
} else {
410+
quit 1
411+
}
412+
}
413+
393414
/// Goes through all the added files and stages them
394415
ClassMethod StageAddedFiles()
395416
{

0 commit comments

Comments
 (0)