Skip to content

Commit 5ee26a9

Browse files
authored
Merge pull request #769 from intersystems/fix-display-remote
Fix settings page remote input if git repo not initialized
2 parents 7b9913d + 347b104 commit 5ee26a9

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
@@ -3031,17 +3031,18 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status
30313031
}
30323032

30333033
/// Returns the url for the "origin" remote repository
3034-
ClassMethod GetConfiguredRemote(Output remoteExists As %Boolean = 0) As %String
3034+
ClassMethod GetConfiguredRemote(Output remoteExists As %Boolean = 0, Output sc As %Status = {$$$OK}) As %String
30353035
{
30363036
set exitCode = ..RunGitCommand("remote",.err,.out,"get-url","origin")
30373037
if (exitCode = 0) {
30383038
set remoteExists = 1
30393039
set url = out.ReadLine()
3040-
} elseif (exitCode = 2) {
3040+
} else {
30413041
set remoteExists = 0
30423042
set url = ""
3043-
} else {
3044-
$$$ThrowStatus($$$ERROR($$$GeneralError,"git reported failure"))
3043+
if '$listfind($listbuild(2,3),exitCode) {
3044+
set sc = $$$ERROR($$$GeneralError,"git reported failure")
3045+
}
30453046
}
30463047
return url
30473048
}

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)