Skip to content

Commit 3c853be

Browse files
committed
replace installation ID with boolean private indicator
1 parent dacf88b commit 3c853be

File tree

5 files changed

+21
-19
lines changed

5 files changed

+21
-19
lines changed

Sources/UnidocDB/Packages/Unidoc.PackageRepo (ext).swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ extension Unidoc.PackageRepo
1212
{
1313
@inlinable public static
1414
func github(_ repo:GitHub.Repo,
15-
crawled:UnixMillisecond,
16-
installation:Int32? = nil) throws -> Self
15+
crawled:UnixMillisecond) throws -> Self
1716
{
1817
/// We clip this to Midnights because we use this as a shard key, and also because
1918
/// Midnights are Swifty.
@@ -46,6 +45,7 @@ extension Unidoc.PackageRepo
4645
created: .init(created),
4746
updated: updated,
4847
license: repo.license.map { .init(spdx: $0.id, name: $0.name) },
48+
private: repo.visibility == .private,
4949
topics: repo.topics,
5050
master: repo.master,
5151
origin: .github(.init(
@@ -59,8 +59,7 @@ extension Unidoc.PackageRepo
5959
size: repo.size,
6060
archived: repo.archived,
6161
disabled: repo.disabled,
62-
fork: repo.fork,
63-
installation: installation)),
62+
fork: repo.fork)),
6463
forks: repo.forks,
6564
stars: repo.stars)
6665
}

Sources/UnidocRecords/Origins/Unidoc.GitHubOrigin.swift

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ extension Unidoc
3838
public
3939
var fork:Bool
4040

41-
/// A GitHub App installation, currently only set for private repositories.
42-
public
43-
var installation:Int32?
44-
4541
@inlinable public
4642
init(id:Int32,
4743
owner:String,
@@ -53,8 +49,7 @@ extension Unidoc
5349
size:Int,
5450
archived:Bool,
5551
disabled:Bool,
56-
fork:Bool,
57-
installation:Int32?)
52+
fork:Bool)
5853
{
5954
self.id = id
6055
self.pushed = pushed
@@ -67,7 +62,6 @@ extension Unidoc
6762
self.archived = archived
6863
self.disabled = disabled
6964
self.fork = fork
70-
self.installation = installation
7165
}
7266
}
7367
}
@@ -107,6 +101,8 @@ extension Unidoc.GitHubOrigin
107101
case archived = "X"
108102
case disabled = "D"
109103
case fork = "K"
104+
105+
@available(*, unavailable)
110106
case installation = "L"
111107
}
112108
}
@@ -129,7 +125,6 @@ extension Unidoc.GitHubOrigin:BSONDocumentEncodable
129125
bson[.archived] = self.archived
130126
bson[.disabled] = self.disabled
131127
bson[.fork] = self.fork
132-
bson[.installation] = self.installation
133128
}
134129
}
135130
extension Unidoc.GitHubOrigin:BSONDocumentDecodable
@@ -147,7 +142,6 @@ extension Unidoc.GitHubOrigin:BSONDocumentDecodable
147142
size: try bson[.size].decode(),
148143
archived: try bson[.archived].decode(),
149144
disabled: try bson[.disabled].decode(),
150-
fork: try bson[.fork].decode(),
151-
installation: try bson[.installation]?.decode())
145+
fork: try bson[.fork].decode())
152146
}
153147
}

Sources/UnidocRecords/Packages/Unidoc.PackageRepo.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ extension Unidoc
3333
/// The repo’s license. All software repos have the concept of a license.
3434
public
3535
var license:PackageLicense?
36+
37+
/// Indicates if the repo is private, and therefore cannot be cloned without
38+
/// authentication.
39+
public
40+
var `private`:Bool
41+
3642
/// The repo’s topic memberships. Both GitHub and GitLab have topics.
3743
public
3844
var topics:[String]
@@ -57,6 +63,7 @@ extension Unidoc
5763
created:UnixMillisecond,
5864
updated:UnixMillisecond,
5965
license:PackageLicense?,
66+
private:Bool,
6067
topics:[String],
6168
master:String?,
6269
origin:PackageOrigin,
@@ -69,6 +76,7 @@ extension Unidoc
6976
self.created = created
7077
self.updated = updated
7178
self.license = license
79+
self.private = `private`
7280
self.topics = topics
7381
self.master = master
7482
self.origin = origin
@@ -95,6 +103,7 @@ extension Unidoc.PackageRepo
95103
case updated = "U"
96104

97105
case license = "L"
106+
case `private` = "X"
98107
case topics = "T"
99108
case master = "M"
100109

@@ -115,6 +124,7 @@ extension Unidoc.PackageRepo:BSONDocumentEncodable
115124
bson[.updated] = self.updated
116125

117126
bson[.license] = self.license
127+
bson[.private] = self.private
118128
bson[.topics] = self.topics.isEmpty ? nil : self.topics
119129
bson[.master] = self.master
120130

@@ -140,6 +150,8 @@ extension Unidoc.PackageRepo:BSONDocumentDecodable
140150
created: try bson[.created].decode(),
141151
updated: try bson[.updated].decode(),
142152
license: try bson[.license]?.decode(),
153+
// TODO: deoptionalize
154+
private: try bson[.private]?.decode() ?? false,
143155
topics: try bson[.topics]?.decode() ?? [],
144156
master: try bson[.master]?.decode(),
145157
origin: origin,

Sources/UnidocServer/Operations/Interactions/Unidoc.WebhookOperation.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ extension Unidoc.WebhookOperation
132132
in db:Unidoc.Database,
133133
at time:UnixMillisecond) async throws -> HTTP.ServerResponse
134134
{
135-
let repo:Unidoc.PackageRepo = try .github(event.repo,
136-
crawled: time,
137-
installation: event.repo.visibility == .private ? event.installation : nil)
135+
let repo:Unidoc.PackageRepo = try .github(event.repo, crawled: time)
138136

139137
let indexEligible:Bool
140138
let repoWebhook:String

Sources/UnidocServer/Operations/Procedures/Unidoc.BuilderUploadOperation.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ extension Unidoc.BuilderUploadOperation:Unidoc.BlockingOperation
6464
/// hazard, because the logs contain secrets, and the log URLs are easily
6565
/// predicted. For now, we just discard the logs for private repositories.
6666
let _logsIncluded:Bool
67-
if case .github(let origin)? = _metadata?.repo?.origin,
68-
case _? = origin.installation
67+
if case true? = _metadata?.repo?.private
6968
{
7069
_logsIncluded = false
7170
}

0 commit comments

Comments
 (0)