Skip to content

Terminate git pull on error #565

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

Merged
merged 6 commits into from
Oct 25, 2024
Merged
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 @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix errors when deleting non-existent files on import (#524)
- Fix errors on commit when a file was added, never committed, then deleted from the repository (#481)
- Fixed issue with saving multiple new no-folder mapping settings at the same time (#533)
- Fixed sending OS error when git pull encounters error (#545)

## [2.6.0] - 2024-10-07

Expand Down
9 changes: 7 additions & 2 deletions cls/SourceControl/Git/API.cls
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ ClassMethod Configure()
}

/// API for git pull - just wraps Utils
ClassMethod Pull()
/// - pTerminateOnError: if set to 1, this will terminate on error if there are any errors in the pull, otherwise will return status
ClassMethod Pull(pTerminateOnError As %Boolean = 0)
{
quit ##class(SourceControl.Git.Utils).Pull()
set st = ##class(SourceControl.Git.Utils).Pull(,pTerminateOnError)
if pTerminateOnError && $$$ISERR(st) {
Do $System.Process.Terminate($Job,1)
}
quit st
}

/// Locks the environment to prevent changes to code other than through git pull.
Expand Down
6 changes: 5 additions & 1 deletion cls/SourceControl/Git/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ ClassMethod GetCurrentRevision() As %String
quit revision
}

ClassMethod Pull(remote As %String = "origin") As %Status
ClassMethod Pull(remote As %String = "origin", pTerminateOnError As %Boolean=0) As %Status
{
New %gitSCOutputFlag
Set %gitSCOutputFlag = 1
Expand All @@ -627,6 +627,10 @@ ClassMethod Pull(remote As %String = "origin") As %Status
write !
do errStream.OutputToDevice()
write !, "Pull ran with return code: " _ returnCode
set err = errStream.Read()
if ($find(err,"error") || $find(err, "fatal") || $find(err, "ERROR")) && pTerminateOnError {
quit $$$ERROR($$$GeneralError, err)
}
quit $$$OK
}

Expand Down
Loading