Skip to content

Commit 2898bff

Browse files
committed
Add useful error
1 parent 9438c32 commit 2898bff

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

cls/SourceControl/Git/OAuth2.cls

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ ClassMethod SetRemoteURLWithToken(remote As %String) As %String
4242
{
4343
set token = ##class(SourceControl.Git.Util.CredentialManager).GetToken($username, .err, .code)
4444
if ('(remote [ token)) {
45-
set post = $piece($piece(remote,"https://",2),"@",2)
45+
set post = $piece(remote,"https://",2)
46+
if (post [ "@") {
47+
set post = $piece(post, "@",2)
48+
}
4649
set remote = "https://oauth2:"_token_"@"_post
4750

4851
}

cls/SourceControl/Git/Utils.cls

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,6 +1876,12 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
18761876
set newArgs($increment(newArgs)) = command
18771877

18781878
if ((..GitRemoteType() = "HTTPS") && ((command = "pull") || (command = "push") || (command = "fetch"))) {
1879+
set token = ##class(SourceControl.Git.Util.CredentialManager).GetToken($username, .err, .code)
1880+
if ((token = "") || (token = "key does not exist")) {
1881+
set errStream = ##class(%Stream.FileCharacter).%New()
1882+
do errStream.Write("Error: Please authenticate your https connection before attempting to use git")
1883+
return 128
1884+
}
18791885
// Need to use token
18801886
set remote = ..GetConfiguredRemote()
18811887
set tokenURL = ##class(SourceControl.Git.OAuth2).SetRemoteURLWithToken(remote)

0 commit comments

Comments
 (0)