Skip to content

Commit 59859fe

Browse files
committed
now doesn't prompt for commit msg if no uncomitted files
1 parent 92c5751 commit 59859fe

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

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/Settings.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,4 @@ Method OnAfterConfigure() As %Boolean
210210
}
211211

212212
}
213+

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()
@@ -376,17 +382,32 @@ ClassMethod PreSync() As %String
376382
/// Commits all the files as needed by the Sync operation
377383
ClassMethod SyncCommit(Msg As %String) As %Status
378384
{
379-
set uncommittedFilesWithAction = ##class(SourceControl.Git.Utils).UncommittedWithAction().%Get("user")
380-
set username = ..GitUserName()
381-
set email = ..GitUserEmail()
382-
set author = username_" <"_email_">"
383-
do ..RunGitWithArgs(.errStream, .outStream, "commit", "--author", author, "-m", Msg)
384-
do ..PrintStreams(errStream, outStream)
385-
$$$QuitOnError(..ClearUncommitted(uncommittedFilesWithAction))
386-
$$$QuitOnError(##class(SourceControl.Git.Change).RefreshUncommitted(,,,1))
385+
386+
if ..CheckForUncommittedFiles() {
387+
set uncommittedFilesWithAction = ##class(SourceControl.Git.Utils).UncommittedWithAction().%Get("user")
388+
set username = ..GitUserName()
389+
set email = ..GitUserEmail()
390+
set author = username_" <"_email_">"
391+
do ..RunGitWithArgs(.errStream, .outStream, "commit", "--author", author, "-m", Msg)
392+
do ..PrintStreams(errStream, outStream)
393+
$$$QuitOnError(..ClearUncommitted(uncommittedFilesWithAction))
394+
$$$QuitOnError(##class(SourceControl.Git.Change).RefreshUncommitted(,,,1))
395+
}
396+
387397
quit $$$OK
388398
}
389399

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

0 commit comments

Comments
 (0)