Skip to content

Commit 5bc6d6a

Browse files
committed
🎉 Initial working implementation
0 parents  commit 5bc6d6a

File tree

5 files changed

+132
-0
lines changed

5 files changed

+132
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
xcuserdata/
5+
DerivedData/
6+
.swiftpm/configuration/registries.json
7+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
8+
.netrc

Package.resolved

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"originHash" : "0889c55f02193be06d3ba97bfa3acd05f9e65a2dae7dc3c921ab42540a8fa453",
3+
"pins" : [
4+
{
5+
"identity" : "swift-argument-parser",
6+
"kind" : "remoteSourceControl",
7+
"location" : "https://github.com/apple/swift-argument-parser.git",
8+
"state" : {
9+
"revision" : "0fbc8848e389af3bb55c182bc19ca9d5dc2f255b",
10+
"version" : "1.4.0"
11+
}
12+
},
13+
{
14+
"identity" : "swift-cmark",
15+
"kind" : "remoteSourceControl",
16+
"location" : "https://github.com/swiftlang/swift-cmark.git",
17+
"state" : {
18+
"branch" : "gfm",
19+
"revision" : "2c47322cb32cbed555f13bf5cbfaa488cc30a785"
20+
}
21+
},
22+
{
23+
"identity" : "swift-markdown",
24+
"kind" : "remoteSourceControl",
25+
"location" : "https://github.com/apple/swift-markdown.git",
26+
"state" : {
27+
"branch" : "main",
28+
"revision" : "d21714073e0d16ba78eebdf36724863afc36871d"
29+
}
30+
}
31+
],
32+
"version" : 3
33+
}

Package.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// swift-tools-version: 5.10
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "swift-changelog-parser",
8+
platforms: [.macOS(.v13)],
9+
dependencies: [
10+
.package(url: "https://github.com/apple/swift-markdown.git", branch: "main"),
11+
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMajor(from: "1.4.0")),
12+
],
13+
targets: [
14+
// Targets are the basic building blocks of a package, defining a module or a test suite.
15+
// Targets can depend on other targets in this package and products from dependencies.
16+
.executableTarget(
17+
name: "swift-changelog-parser",
18+
dependencies: [.product(name: "Markdown", package: "swift-markdown"),
19+
.product(name: "ArgumentParser", package: "swift-argument-parser")]),
20+
]
21+
)

Sources/Changelog.swift

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import Foundation
2+
import Markdown
3+
import ArgumentParser
4+
5+
@main
6+
struct Changelog: ParsableCommand {
7+
enum Release: ExpressibleByArgument, CustomStringConvertible {
8+
case unreleased
9+
case release(String)
10+
11+
var description: String {
12+
switch self {
13+
case .unreleased:
14+
return defaultValueDescription
15+
case let .release(value):
16+
return value
17+
}
18+
}
19+
20+
var defaultValueDescription: String {
21+
"unreleased"
22+
}
23+
24+
init?(argument: String) {
25+
switch argument.lowercased() {
26+
case "unreleased":
27+
self = .unreleased
28+
default:
29+
self = .release(argument)
30+
}
31+
}
32+
}
33+
34+
@Argument(help: "Path to Changelog.md file")
35+
var path: String
36+
37+
@Option(name: .shortAndLong, help: "Get a specific list of changes")
38+
var release: Release = .unreleased
39+
40+
func validate() throws {
41+
guard FileManager.default.fileExists(atPath: path) else {
42+
throw ValidationError("Changelog does not exist at path \(path)")
43+
}
44+
}
45+
46+
func run() throws {
47+
let document = try Document(parsing: URL(filePath: path))
48+
let heading = document.children
49+
.compactMap { $0 as? Heading }
50+
.filter { $0.level == 2 }
51+
.first { $0.plainText.lowercased() == release.description }
52+
53+
guard let heading else {
54+
throw ValidationError("Changelog does not contain '\(release.description.localizedCapitalized)' section")
55+
}
56+
57+
let list = document.child(at: heading.indexInParent + 1)
58+
guard let list, list is UnorderedList else {
59+
throw ValidationError("Changelog does not contain elements in the '\(release.description.localizedCapitalized)' section")
60+
}
61+
62+
print(list.format().trimmingCharacters(in: .whitespacesAndNewlines))
63+
}
64+
}

changelog.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- 🔥 No longer show AI features carousel after login
2+
- 🐛 Start call from native recent calls
3+
- 🐛 Crash on hangup
4+
- 🔥 Remove support for deprecated deeplinks
5+
- ✨ Showing new permission screen after login and if microphone permission is not granted.
6+
- ✨ Settings & account redesign

0 commit comments

Comments
 (0)