@@ -3019,15 +3019,23 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status
30193019 return sc
30203020}
30213021
3022- /// Returns the url for the remote repository (censoring the username)
3023- ClassMethod GetConfiguredRemote () As %String
3024- {
3025- d ..RunGitCommand (" remote" ,.err ,.out ," -v" )
3026- set line = out .ReadLine ()
3027- set url = $piece ($piece (line ,$char (9 ),2 )," " ,1 )
3022+ /// Returns the url for the "origin" remote repository
3023+ ClassMethod GetConfiguredRemote (Output remoteExists As %Boolean = 0 ) As %String
3024+ {
3025+ set exitCode = ..RunGitCommand (" remote" ,.err ,.out ," get-url" ," origin" )
3026+ if (exitCode = 0 ) {
3027+ set remoteExists = 1
3028+ set url = out .ReadLine ()
3029+ } elseif (exitCode = 2 ) {
3030+ set remoteExists = 0
3031+ set url = " "
3032+ } else {
3033+ $$$ThrowStatus($$$ERROR($$$GeneralError," git reported failure" ))
3034+ }
30283035 return url
30293036}
30303037
3038+ /// Returns the url for the "origin" remote repository, redacting the username
30313039ClassMethod GetRedactedRemote () As %String
30323040{
30333041 set url = ..GetConfiguredRemote ()
@@ -3038,7 +3046,15 @@ ClassMethod GetRedactedRemote() As %String
30383046
30393047ClassMethod SetConfiguredRemote (url ) As %String
30403048{
3041- do ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" remote" ,,.errStream ,.outStream ," set-url" ," origin" ,url )
3049+ do ..GetConfiguredRemote (.remoteExists )
3050+ set returnCode = $select (
3051+ remoteExists &&(url =" " ): ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" remote" ,,.errStream ,.outStream ," remove" ," origin" ),
3052+ remoteExists &&(url '=" " ): ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" remote" ,,.errStream ,.outStream ," set-url" ," origin" ,url ),
3053+ 'remoteExists &&(url '=" " ): ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" remote" ,,.errStream ,.outStream ," add" ," origin" ,url ),
3054+ 1 : 0 )
3055+ if (returnCode '= 0 ) {
3056+ $$$ThrowStatus($$$ERROR($$$GeneralError," git reported failure" ))
3057+ }
30423058 set output = outStream .ReadLine (outStream .Size )
30433059 quit output
30443060}
@@ -3198,4 +3214,3 @@ ClassMethod IsSchemaStandard(pName As %String = "") As %Boolean [ Internal ]
31983214}
31993215
32003216}
3201-
0 commit comments