Skip to content

Commit 17e75d2

Browse files
authored
Merge pull request #565 from intersystems/issue-545
Terminate git pull on error
2 parents 10d2efa + caaad30 commit 17e75d2

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4444
- Fix errors when deleting non-existent files on import (#524)
4545
- Fix errors on commit when a file was added, never committed, then deleted from the repository (#481)
4646
- Fixed issue with saving multiple new no-folder mapping settings at the same time (#533)
47+
- Fixed sending OS error when git pull encounters error (#545)
4748

4849
## [2.6.0] - 2024-10-07
4950

cls/SourceControl/Git/API.cls

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,14 @@ ClassMethod Configure()
4444
}
4545

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

5257
/// Locks the environment to prevent changes to code other than through git pull.

cls/SourceControl/Git/Utils.cls

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ ClassMethod GetCurrentRevision() As %String
612612
quit revision
613613
}
614614

615-
ClassMethod Pull(remote As %String = "origin") As %Status
615+
ClassMethod Pull(remote As %String = "origin", pTerminateOnError As %Boolean=0) As %Status
616616
{
617617
New %gitSCOutputFlag
618618
Set %gitSCOutputFlag = 1
@@ -627,6 +627,10 @@ ClassMethod Pull(remote As %String = "origin") As %Status
627627
write !
628628
do errStream.OutputToDevice()
629629
write !, "Pull ran with return code: " _ returnCode
630+
set err = errStream.Read()
631+
if ($find(err,"error") || $find(err, "fatal") || $find(err, "ERROR")) && pTerminateOnError {
632+
quit $$$ERROR($$$GeneralError, err)
633+
}
630634
quit $$$OK
631635
}
632636

0 commit comments

Comments
 (0)