Skip to content

Commit 8325c3e

Browse files
committed
Support GitHub Copilot enterprise
1 parent dbbb30c commit 8325c3e

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

Core/Sources/HostApp/AccountSettings/GitHubCopilotView.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct GitHubCopilotView: View {
1919
@AppStorage(\.gitHubCopilotProxyUsername) var gitHubCopilotProxyUsername
2020
@AppStorage(\.gitHubCopilotProxyPassword) var gitHubCopilotProxyPassword
2121
@AppStorage(\.gitHubCopilotUseStrictSSL) var gitHubCopilotUseStrictSSL
22+
@AppStorage(\.gitHubCopilotEnterpriseURI) var gitHubCopilotEnterpriseURI
2223
@AppStorage(\.gitHubCopilotIgnoreTrailingNewLines)
2324
var gitHubCopilotIgnoreTrailingNewLines
2425
@AppStorage(\.disableGitHubCopilotSettingsAutoRefreshOnAppear)
@@ -275,6 +276,17 @@ struct GitHubCopilotView: View {
275276
.dynamicHeightTextInFormWorkaround()
276277
Toggle("Verbose Log", isOn: $settings.gitHubCopilotVerboseLog)
277278
}
279+
280+
SettingsDivider("Enterprise")
281+
282+
Form {
283+
TextField(
284+
text: $settings.gitHubCopilotEnterpriseURI,
285+
prompt: Text("Leave it blank if non is available.")
286+
) {
287+
Text("Auth Provider URL")
288+
}
289+
}
278290

279291
SettingsDivider("Proxy")
280292

Tool/Sources/GitHubCopilotService/GitHubCopilotRequest.swift

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,26 @@ enum GitHubCopilotRequest {
8080
])
8181
}
8282
}
83+
84+
var editorConfiguration: JSONValue? {
85+
var dict: [String: JSONValue] = [:]
86+
if let networkProxy {
87+
dict["http"] = networkProxy
88+
}
89+
90+
let enterpriseURI = UserDefaults.shared.value(for: \.gitHubCopilotEnterpriseURI)
91+
if !enterpriseURI.isEmpty {
92+
dict["github-enterprise"] = .hash([
93+
"uri": .string(enterpriseURI)
94+
])
95+
}
96+
97+
if dict.isEmpty { return nil }
98+
return .hash(dict)
99+
}
83100

84101
var request: ClientRequest {
85-
if let networkProxy {
102+
if let editorConfiguration {
86103
return .custom("setEditorInfo", .hash([
87104
"editorInfo": .hash([
88105
"name": "Xcode",
@@ -92,7 +109,7 @@ enum GitHubCopilotRequest {
92109
"name": "Copilot for Xcode",
93110
"version": "",
94111
]),
95-
"networkProxy": networkProxy,
112+
"editorConfiguration": editorConfiguration,
96113
]))
97114
}
98115

Tool/Sources/Preferences/Keys.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ public extension UserDefaultPreferenceKeys {
163163
var gitHubCopilotProxyPort: PreferenceKey<String> {
164164
.init(defaultValue: "", key: "GitHubCopilotProxyPort")
165165
}
166+
167+
var gitHubCopilotEnterpriseURI: PreferenceKey<String> {
168+
.init(defaultValue: "", key: "GitHubCopilotEnterpriseURI")
169+
}
166170

167171
var gitHubCopilotUseStrictSSL: PreferenceKey<Bool> {
168172
.init(defaultValue: true, key: "GitHubCopilotUseStrictSSL")

0 commit comments

Comments
 (0)