Skip to content

Commit 347b104

Browse files
committed
fix: settings page no longer errors if git repo is not initialized
1 parent 1b8317d commit 347b104

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

cls/SourceControl/Git/Utils.cls

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3020,17 +3020,18 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status
30203020
}
30213021

30223022
/// Returns the url for the "origin" remote repository
3023-
ClassMethod GetConfiguredRemote(Output remoteExists As %Boolean = 0) As %String
3023+
ClassMethod GetConfiguredRemote(Output remoteExists As %Boolean = 0, Output sc As %Status = {$$$OK}) As %String
30243024
{
30253025
set exitCode = ..RunGitCommand("remote",.err,.out,"get-url","origin")
30263026
if (exitCode = 0) {
30273027
set remoteExists = 1
30283028
set url = out.ReadLine()
3029-
} elseif (exitCode = 2) {
3029+
} else {
30303030
set remoteExists = 0
30313031
set url = ""
3032-
} else {
3033-
$$$ThrowStatus($$$ERROR($$$GeneralError,"git reported failure"))
3032+
if '$listfind($listbuild(2,3),exitCode) {
3033+
set sc = $$$ERROR($$$GeneralError,"git reported failure")
3034+
}
30343035
}
30353036
return url
30363037
}

csp/gitprojectsettings.csp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,6 @@ body {
119119
set settings.mappedItemsReadOnly = 0
120120
}
121121

122-
set newRemote = $Get(%request.Data("remoteRepo",1))
123-
// If entry was modified, set new remote repo
124-
if (newRemote '= ##class(SourceControl.Git.Utils).GetRedactedRemote()) {
125-
do ##class(SourceControl.Git.Utils).SetConfiguredRemote(newRemote)
126-
}
127122

128123
set settings.compileOnImport = ($Get(%request.Data("compileOnImport", 1)) = 1)
129124
set settings.decomposeProductions = ($Get(%request.Data("decomposeProductions", 1)) = 1)
@@ -188,6 +183,14 @@ body {
188183
kill buffer
189184
throw err
190185
}
186+
set newRemote = $Get(%request.Data("remoteRepo",1))
187+
// If entry was modified and git repo is initialized, set new remote repo
188+
set dir = ##class(%File).NormalizeDirectory(settings.namespaceTemp)
189+
if (settings.namespaceTemp '= "") && ##class(%File).DirectoryExists(dir_".git") {
190+
if (newRemote '= ##class(SourceControl.Git.Utils).GetRedactedRemote()) {
191+
do ##class(SourceControl.Git.Utils).SetConfiguredRemote(newRemote)
192+
}
193+
}
191194
set successfullySavedSettings = 1
192195
}
193196
set remote = ##class(SourceControl.Git.Utils).GetRedactedRemote()

0 commit comments

Comments
 (0)