Skip to content

Fix #371 - now doesn't prompt for commit msg if no uncomitted files #394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Modifications to local repo files are now synced with IRIS (#153)
- Menu items names are properly translated from internal name in VSCode, Management Portal (#372)
- Syncing only prompts users for a commit message if there are uncommitted files (#390)

## [2.3.1] - 2024-04-30

Expand Down
1 change: 1 addition & 0 deletions cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ Method DeleteFile(item As %String) As %Status
}

}

1 change: 1 addition & 0 deletions cls/SourceControl/Git/Settings.cls
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,4 @@ Method OnAfterConfigure() As %Boolean
}

}

43 changes: 32 additions & 11 deletions cls/SourceControl/Git/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,15 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe
set Action = 7
quit $$$OK
} elseif (menuItemName = "Sync") {
set Target = "Enter a commit message for the sync operation"
set Action = 7
set Msg = ..PreSync()
if ..CheckForUncommittedFiles() {
set Target = "Enter a commit message for the sync operation"
set Action = 7
set Msg = ..PreSync()
} else {
do ..Sync("")
}


quit $$$OK
} elseif (menuItemName = "Push") {
quit ..Push()
Expand Down Expand Up @@ -376,17 +382,32 @@ ClassMethod PreSync() As %String
/// Commits all the files as needed by the Sync operation
ClassMethod SyncCommit(Msg As %String) As %Status
{
set uncommittedFilesWithAction = ##class(SourceControl.Git.Utils).UncommittedWithAction().%Get("user")
set username = ..GitUserName()
set email = ..GitUserEmail()
set author = username_" <"_email_">"
do ..RunGitWithArgs(.errStream, .outStream, "commit", "--author", author, "-m", Msg)
do ..PrintStreams(errStream, outStream)
$$$QuitOnError(..ClearUncommitted(uncommittedFilesWithAction))
$$$QuitOnError(##class(SourceControl.Git.Change).RefreshUncommitted(,,,1))

if ..CheckForUncommittedFiles() {
set uncommittedFilesWithAction = ##class(SourceControl.Git.Utils).UncommittedWithAction().%Get("user")
set username = ..GitUserName()
set email = ..GitUserEmail()
set author = username_" <"_email_">"
do ..RunGitWithArgs(.errStream, .outStream, "commit", "--author", author, "-m", Msg)
do ..PrintStreams(errStream, outStream)
$$$QuitOnError(..ClearUncommitted(uncommittedFilesWithAction))
$$$QuitOnError(##class(SourceControl.Git.Change).RefreshUncommitted(,,,1))
}

quit $$$OK
}

ClassMethod CheckForUncommittedFiles() As %Boolean
{
set uncommittedFilesWithAction = ##class(SourceControl.Git.Utils).UncommittedWithAction().%Get("user")
set valInArr = uncommittedFilesWithAction.%Pop()
if valInArr = "" {
return 0
} else {
quit 1
}
}

/// Goes through all the added files and stages them
ClassMethod StageAddedFiles()
{
Expand Down
Loading