Skip to content

Commit 9ef0aeb

Browse files
authored
Merge pull request #877 from intersystems/ssh-config-file
Add setting for SSH client configuration file
2 parents d13a398 + 950b04a commit 9ef0aeb

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Settings page now warns if Embedded Git is not the configured source control extension (#857)
1313
- Settings page now has option to switch namespace (#856)
1414
- SourceControl.Git.Settings is now documented as part of the public API to allow programmatic configuration of settings (#262)
15+
- New setting to define an SSH client configuration file for connections to SSH remotes (#293)
1516

1617
### Fixed
1718
- When cloning a repo with Configure, that repo's embedded-git-config file will overwrite previous settings (#819)

cls/SourceControl/Git/Settings.cls

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ Property Mappings [ MultiDimensional ];
9393
/// (user-level) List of namespaces on this instance to include Embedded Git links in the SMP favorites
9494
Property favoriteNamespaces As %DynamicArray;
9595

96+
/// (Optional) Path to an SSH client configuration file for use with SSH connections to a Git remote
97+
Property sshConfigFile As %String(MAXLEN = "") [ InitialExpression = {##class(SourceControl.Git.Utils).SSHConfigFile()} ];
98+
9699
Method %OnNew() As %Status
97100
{
98101
set mappingsNode = ##class(SourceControl.Git.Utils).MappingsNode()
@@ -183,6 +186,7 @@ Method %Save() As %Status
183186
set @storage@("settings", "environmentName") = ..environmentName
184187
set @storage@("settings", "lockBranch") = ..lockBranch
185188
set @storage@("settings", "mappingsToken") = ..mappingsToken
189+
set @storage@("settings", "sshConfigFile") = ..sshConfigFile
186190
if ..basicMode = "system" {
187191
kill @storage@("settings", "user", $username, "basicMode")
188192
} else {
@@ -551,3 +555,4 @@ Method SaveDefaults() As %Boolean
551555
}
552556

553557
}
558+

cls/SourceControl/Git/Utils.cls

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ ClassMethod MappingsToken() As %String
195195
quit $get(@..#Storage@("settings","mappingsToken"),"")
196196
}
197197

198+
ClassMethod SSHConfigFile() As %String
199+
{
200+
quit $get(@..#Storage@("settings","sshConfigFile"),"")
201+
}
202+
198203
ClassMethod IsLIVE() As %Boolean
199204
{
200205
quit ..EnvironmentName()="LIVE"
@@ -1896,8 +1901,14 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
18961901
set privateKeyFile = $replace(privateKeyFile,"\","\\")
18971902
}
18981903
set newArgs($increment(newArgs)) = "-c"
1904+
set sshConfigFile = ..SSHConfigFile()
1905+
if sshConfigFile="" {
1906+
set sshConfigFile = "/dev/null"
1907+
} elseif $$$isWINDOWS {
1908+
set sshConfigFile = $replace(sshConfigFile,"\","\\")
1909+
}
18991910
// StrictHostKeyChecking=accept-new for good behavior on first connection
1900-
set newArgs($increment(newArgs)) = "core.sshCommand=ssh -F /dev/null -o StrictHostKeyChecking=accept-new -i "_privateKeyFile
1911+
set newArgs($increment(newArgs)) = "core.sshCommand=ssh -F "_sshConfigFile_" -o StrictHostKeyChecking=accept-new -i "_privateKeyFile
19011912
}
19021913

19031914
set username = ""
@@ -3322,3 +3333,4 @@ ClassMethod IsSchemaStandard(pName As %String = "") As %Boolean [ Internal ]
33223333
}
33233334

33243335
}
3336+

csp/gitprojectsettings.csp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ body {
120120

121121
if ('settings.settingsUIReadOnly) {
122122
do ##class(SourceControl.Git.Utils).Locked($get(%request.Data("lockNamespace",1)))
123-
for param="gitBinPath","namespaceTemp","privateKeyFile","pullEventClass","percentClassReplace", "defaultMergeBranch","environmentName","mappingsToken" {
123+
for param="gitBinPath","namespaceTemp","privateKeyFile","pullEventClass","percentClassReplace", "defaultMergeBranch","environmentName","mappingsToken","sshConfigFile" {
124124
set $Property(settings,param) = $Get(%request.Data(param,1))
125125
}
126126

@@ -395,6 +395,13 @@ body {
395395
}
396396
</server>
397397

398+
<div class="form-group row mb-3">
399+
<label for="sshConfigFile" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="(Optional) Path to an SSH client configuration file for use with SSH connections to a Git remote">Path to SSH Config File</label>
400+
<div class="col-sm-7">
401+
<input type="text" class="form-control" id="sshConfigFile" name="sshConfigFile" value='#(..EscapeHTML(settings.sshConfigFile))#' placeholder=""/>
402+
</div>
403+
</div>
404+
398405
<div class="form-group row mb-3">
399406
<label for="pullEventClass" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Handler class for git pull"><b>Pull Event Class</b></label>
400407
<div class="col-sm-7">

0 commit comments

Comments
 (0)