Skip to content

Commit dfd7698

Browse files
committed
move the SHA1 commit field from the VolumeMetadata to Vertex.Global
1 parent eddc7b0 commit dfd7698

File tree

7 files changed

+19
-14
lines changed

7 files changed

+19
-14
lines changed

Sources/SwiftinitPages/Surfaces/Vertices/Swiftinit.Docs.Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ extension Swiftinit.Docs.Package:Swiftinit.VersionedPage
302302
$0[.dt] = "Symbol Graph ABI"
303303
$0[.dd] = "\(self.vertex.snapshot.abi)"
304304

305-
if let commit:SHA1 = self.volume.commit
305+
if let commit:SHA1 = self.vertex.snapshot.commit
306306
{
307307
$0[.dt] = "Git Revision"
308308
$0[.dd]

Sources/UnidocDB/UnidocDatabase.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,6 @@ extension UnidocDatabase
556556
dependencies: dependencies,
557557
display: snapshot.metadata.display,
558558
refname: snapshot.metadata.commit?.refname,
559-
commit: snapshot.metadata.commit?.hash,
560559
symbol: .init(
561560
// We want the version component of the volume symbol to be stable,
562561
// so we only encode the patch version, even if the symbol graph is

Sources/UnidocLinker/Linker/DynamicLinker.Mesh.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ extension DynamicLinker.Mesh
6161
}
6262

6363
var snapshot:Unidoc.SnapshotDetails = .init(abi: context.current.metadata.abi,
64-
requirements: context.current.metadata.requirements)
64+
requirements: context.current.metadata.requirements,
65+
commit: context.current.metadata.commit?.hash)
6566
var foreign:[Unidoc.Vertex.Foreign] = []
6667

6768
// Compute shoots for out-of-package extended types.

Sources/UnidocQueries/Volumes/Unidoc.VertexQuery.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ extension Unidoc.VertexQuery:Unidoc.VolumeQuery
239239
.version,
240240
.display,
241241
.refname,
242-
.commit,
243242
.patch,
244243

245244
// TODO: we only need this for top-level queries and

Sources/UnidocRecords/Volumes/Metadata/Unidoc.VolumeMetadata.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ extension Unidoc
1919
var display:String?
2020
public
2121
var refname:String?
22-
public
23-
var commit:SHA1?
2422

2523
public
2624
var symbol:Symbol.Edition
@@ -43,7 +41,6 @@ extension Unidoc
4341
dependencies:[Dependency] = [],
4442
display:String? = nil,
4543
refname:String? = nil,
46-
commit:SHA1? = nil,
4744
symbol:Symbol.Edition,
4845
latest:Bool,
4946
realm:Unidoc.Realm?,
@@ -56,7 +53,6 @@ extension Unidoc
5653
self.dependencies = dependencies
5754
self.display = display
5855
self.refname = refname
59-
self.commit = commit
6056
self.symbol = symbol
6157
self.latest = latest
6258
self.realm = realm
@@ -103,7 +99,10 @@ extension Unidoc.VolumeMetadata
10399
/// to match (and duplicate) the refname in the associated ``Unidoc.EditionMetadata``
104100
/// record.
105101
case refname = "G"
102+
103+
@available(*, unavailable)
106104
case commit = "H"
105+
107106
case patch = "S"
108107
case tree = "X"
109108

@@ -143,7 +142,6 @@ extension Unidoc.VolumeMetadata:BSONDocumentEncodable
143142

144143
bson[.display] = self.display
145144
bson[.refname] = self.refname
146-
bson[.commit] = self.commit
147145

148146
bson[.latest] = self.latest ? true : nil
149147
bson[.realm] = self.realm
@@ -173,7 +171,6 @@ extension Unidoc.VolumeMetadata:BSONDocumentDecodable
173171
dependencies: try bson[.dependencies]?.decode() ?? [],
174172
display: try bson[.display]?.decode(),
175173
refname: try bson[.refname]?.decode(),
176-
commit: try bson[.commit]?.decode(),
177174
symbol: .init(
178175
package: try bson[.package].decode(),
179176
version: try bson[.version].decode()),
@@ -182,6 +179,6 @@ extension Unidoc.VolumeMetadata:BSONDocumentDecodable
182179
patch: try bson[.patch]?.decode(),
183180
tree: try bson[.tree]?.decode(as: Unidoc.NounTable.self, with: \.rows) ?? [])
184181

185-
self.abi = try bson[.abi]?.decode() ?? .v(0, 1)
182+
self.abi = try bson[.abi].decode()
186183
}
187184
}

Sources/UnidocRecords/Volumes/Unidoc.Volume.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extension Unidoc
1111
var latest:Edition?
1212

1313
public
14-
var metadata:Unidoc.VolumeMetadata
14+
var metadata:VolumeMetadata
1515
public
1616
var vertices:Vertices
1717
public
@@ -22,8 +22,8 @@ extension Unidoc
2222
var trees:[TypeTree]
2323

2424
@inlinable public
25-
init(latest:Unidoc.Edition?,
26-
metadata:Unidoc.VolumeMetadata,
25+
init(latest:Edition?,
26+
metadata:VolumeMetadata,
2727
vertices:Vertices,
2828
groups:Groups,
2929
index:JSON,

Sources/UnidocRecords/Volumes/Vertices/Unidoc.SnapshotDetails.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import BSON
22
import SemanticVersions
3+
import SHA1
34
import SymbolGraphs
45

56
extension Unidoc
@@ -15,6 +16,9 @@ extension Unidoc
1516
/// `Package.swift` manifest.
1617
public
1718
var requirements:[SymbolGraphMetadata.PlatformRequirement]
19+
/// The git commit to associate with this snapshot.
20+
public
21+
var commit:SHA1?
1822
/// Top-level linker statistics.
1923
public
2024
var census:Unidoc.Census
@@ -24,10 +28,12 @@ extension Unidoc
2428
@inlinable public
2529
init(abi:PatchVersion,
2630
requirements:[SymbolGraphMetadata.PlatformRequirement],
31+
commit:SHA1?,
2732
census:Unidoc.Census = .init())
2833
{
2934
self.abi = abi
3035
self.requirements = requirements
36+
self.commit = commit
3137
self.census = census
3238
}
3339
}
@@ -39,6 +45,7 @@ extension Unidoc.SnapshotDetails
3945
{
4046
case abi = "B"
4147
case requirements = "O"
48+
case commit = "H"
4249
case census = "C"
4350
}
4451
}
@@ -49,6 +56,7 @@ extension Unidoc.SnapshotDetails:BSONDocumentEncodable
4956
{
5057
bson[.abi] = self.abi
5158
bson[.requirements] = self.requirements.isEmpty ? nil : self.requirements
59+
bson[.commit] = self.commit
5260
bson[.census] = self.census
5361
}
5462
}
@@ -59,6 +67,7 @@ extension Unidoc.SnapshotDetails:BSONDocumentDecodable
5967
{
6068
self.init(abi: try bson[.abi].decode(),
6169
requirements: try bson[.requirements]?.decode() ?? [],
70+
commit: try bson[.commit]?.decode(),
6271
census: try bson[.census].decode())
6372
}
6473
}

0 commit comments

Comments
 (0)