Skip to content

Commit 72cb7c7

Browse files
committed
enable GitHub integration to run in either passive or active mode
1 parent 6505292 commit 72cb7c7

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

Sources/SwiftinitServer/Main.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,16 @@ extension Main
159159
authority: self.authority.init(tls: try .init(configuration: configuration)))
160160

161161
let assets:FilePath = "Assets"
162-
if self.github
162+
do
163163
{
164-
options.github = try .load(secrets: assets / "secrets")
164+
options.github = try .load(secrets: assets / "secrets", active: self.github)
165165
}
166+
catch let error
167+
{
168+
// Temporary workaround for bypassing backtrace collection.
169+
Log[.debug] = "GitHub integration disabled (\(error))"
170+
}
171+
166172
if self.authority is Localhost.Type
167173
{
168174
options.mode = .development(.init(source: assets), self.development)
@@ -225,7 +231,8 @@ extension Main
225231
{
226232
plugins.append(Swiftinit.PolicyPlugin.init())
227233
}
228-
if let github:GitHub.Integration = options.github
234+
if let github:GitHub.Integration = options.github,
235+
github.active
229236
{
230237
plugins.append(GitHub.CrawlerPlugin<GitHub.RepoTelescope>.init(
231238
api: github.api,

Sources/SwiftinitServer/Plugins/GitHub.Integration.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ extension GitHub
55
{
66
struct Integration:Sendable
77
{
8+
let active:Bool
89
let oauth:GitHub.OAuth
910
let app:GitHub.App
1011
let pat:String
1112

12-
init(oauth:GitHub.OAuth, app:GitHub.App, pat:String)
13+
init(active:Bool, oauth:GitHub.OAuth, app:GitHub.App, pat:String)
1314
{
15+
self.active = active
1416
self.oauth = oauth
1517
self.app = app
1618
self.pat = pat
@@ -20,9 +22,10 @@ extension GitHub
2022
extension GitHub.Integration
2123
{
2224
static
23-
func load(secrets:FilePath) throws -> Self
25+
func load(secrets:FilePath, active:Bool) throws -> Self
2426
{
2527
.init(
28+
active: active,
2629
oauth: .init(
2730
client: "2378cacaed3ace362867",
2831
secret: try (secrets / "github-oauth-secret").readLine()),

0 commit comments

Comments
 (0)