Skip to content

Commit ef48baf

Browse files
committed
Fix some error handling
1 parent e4c989a commit ef48baf

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed

cls/SourceControl/Git/API.cls

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ ClassMethod Configure()
3939

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

5151
/// Imports all items from the Git repository into IRIS.
5252
/// - pForce: if true, will import an item even if the last updated timestamp in IRIS is later than that of the file on disk.
53-
ClassMethod ImportAll(pForce As %Boolean = 0) as %Status
53+
ClassMethod ImportAll(pForce As %Boolean = 0) As %Status
5454
{
5555
return ##class(SourceControl.Git.Utils).ImportAll(pForce)
5656
}

cls/SourceControl/Git/Settings.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,4 +625,5 @@ ClassMethod GetRemoteType(remoteURL As %String) As %String
625625
{
626626
return $select(remoteURL [ "https": "HTTPS",1:"SSH")
627627
}
628+
628629
}

cls/SourceControl/Git/Utils.cls

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,8 @@ ClassMethod Clone(remote As %String) As %Status
712712
// TODO: eventually use /ENV flag with GIT_TERMINAL_PROMPT=0. (This isn't doc'd yet and is only in really new versions.)
713713
set rc = ..RunGitWithArgs(.errStream, .outStream, "clone", remote, settings.namespaceTemp)
714714
if rc '= 0 {
715-
quit $$$ERROR($$$GeneralError, "Git clone failed: "_errStream.Read())
715+
set errMsg = errStream.Read()
716+
quit $$$ERROR($$$GeneralError, "Git clone failed: "_errMsg)
716717
}
717718
// can I substitute this with the new print method?
718719
$$$NewLineIfNonEmptyStream(errStream)
@@ -1956,12 +1957,18 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
19561957
set email = ..GitUserEmail()
19571958
}
19581959

1959-
set newArgs($increment(newArgs)) = "-c"
1960-
set newArgs($increment(newArgs)) = "user.name="_username
1961-
set newArgs($increment(newArgs)) = "-c"
1962-
set newArgs($increment(newArgs)) = "user.email="_email
1963-
set newArgs($increment(newArgs)) = "-c"
1964-
set newArgs($increment(newArgs)) = "credential.interactive=false"
1960+
if username '= "" {
1961+
set newArgs($increment(newArgs)) = "-c"
1962+
set newArgs($increment(newArgs)) = "user.name="_username
1963+
}
1964+
if email '= "" {
1965+
set newArgs($increment(newArgs)) = "-c"
1966+
set newArgs($increment(newArgs)) = "user.email="_email
1967+
}
1968+
if ('..UsingOAuth()) {
1969+
set newArgs($increment(newArgs)) = "-c"
1970+
set newArgs($increment(newArgs)) = "credential.interactive=false"
1971+
}
19651972
}
19661973

19671974
set newArgs($increment(newArgs)) = command
@@ -2127,7 +2134,7 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
21272134

21282135
set baseArgs = "/STDOUT="_$$$QUOTE(outLog)_" /STDERR="_$$$QUOTE(errLog)_$case(inFile, "":"", :" /STDIN="_$$$QUOTE(inFile))
21292136
// Use OAuth Authentication if needed (TODO: Should this be done always, or only for certain commands?)
2130-
if ((..UsingOAuth())) {
2137+
if (..UsingOAuth()) {
21312138
set token = ##class(SourceControl.Git.OAuth2).GetToken()
21322139
if (token '= "") {
21332140
if ($$$isWINDOWS) {

cls/SourceControl/Git/WebUIDriver.cls

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,6 @@ ClassMethod GetOAuthURL(%request As %CSP.Request) As %SystemBase
445445
set oauthURL = "/isc/studio/usertemplates/gitsourcecontrol/oauth2.csp?CSPSHARE=1&Namespace="_$namespace_"&Username="_$username
446446
set oauthURL = ..GetURLPrefix(%request, oauthURL)
447447
#; }
448-
set ^mtempdc = oauthURL
449448
quit {"url": (oauthURL)}
450449
}
451450

cls/_zpkg/isc/sc/git/Socket.cls

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ ClassMethod Run()
3939
do ##class(SourceControl.Git.Utils).RunGitCommandWithInput("config",,,,"--global", "--add", "safe.directory", root)
4040
}
4141

42-
Do ##class(SourceControl.Git.Utils).Init()
42+
$$$ThrowOnError(##class(SourceControl.Git.Utils).Init())
4343
Write !,"Done."
4444
} ElseIf %request.Get("method") = "clone" {
4545
Set remote = %request.Get("remote")
46-
Do ##class(SourceControl.Git.Utils).Clone(remote)
46+
$$$ThrowOnError(##class(SourceControl.Git.Utils).Clone(remote))
4747
Write !,"Done."
4848
} ElseIf %request.Get("method") = "sshkeygen" {
49-
Do ##class(SourceControl.Git.Utils).GenerateSSHKeyPair()
49+
$$$ThrowOnError(##class(SourceControl.Git.Utils).GenerateSSHKeyPair())
5050
Write !,"Done."
5151
} Else {
5252
Write !!,"Invalid method selected.",!!

0 commit comments

Comments
 (0)