-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(log): move finished log #27
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,9 +52,6 @@ public struct FileHelper { | |
// MARK: - Repositories and Releases | ||
|
||
public static func load(repositories: [GitHubRepository]) throws -> [GitHubRepository : [Release]] { | ||
defer { | ||
Logger.shared.info("🎉 \(#function) finished") | ||
} | ||
Logger.shared.info("ℹ️ \(#function) started") | ||
var contents: [GitHubRepository : [Release]] = [:] | ||
for repository in repositories { | ||
|
@@ -71,13 +68,11 @@ public struct FileHelper { | |
Logger.shared.info("🔔 \(repository.outputJSONFileName) loading was skipped because that file could not be found") | ||
} | ||
} | ||
Logger.shared.info("🎉 \(#function) finished") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. この変更により、 |
||
return contents | ||
} | ||
|
||
public static func save(contents: [GitHubRepository : [Release]]) throws { | ||
defer { | ||
Logger.shared.info("🎉 \(#function) finished") | ||
} | ||
Logger.shared.info("ℹ️ \(#function) started") | ||
for (repository, releases) in contents { | ||
Logger.shared.info("ℹ️ Saving \(repository.outputJSONFileName)") | ||
|
@@ -86,17 +81,14 @@ public struct FileHelper { | |
try data.write(to: url) | ||
Logger.shared.info("✅ Saved \(repository.outputJSONFileName)") | ||
} | ||
Logger.shared.info("🎉 \(#function) finished") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. この変更により、 |
||
} | ||
|
||
|
||
// MARK: - README.md | ||
|
||
private static let lowerBoundKeyword = "<!-- BEGIN LIST OF REPOSITORIES (AUTOMATICALLY OUTPUT) -->" | ||
private static let upperBoundKeyword = "<!-- END LIST OF REPOSITORIES (AUTOMATICALLY OUTPUT) -->" | ||
public static func writeToREADME(repositories: [GitHubRepository]) throws { | ||
defer { | ||
Logger.shared.info("🎉 \(#function) finished") | ||
} | ||
Logger.shared.info("ℹ️ \(#function) started") | ||
let (url, string, lowerBound, upperBound) = try readFromREADME() | ||
let outputListOfRepositoriesString = """ | ||
|
@@ -112,19 +104,18 @@ public struct FileHelper { | |
+ upperBoundKeyword | ||
try string.replacingCharacters(in: lowerBound..<upperBound, with: outputListOfRepositoriesString) | ||
.write(to: url, atomically: true, encoding: .utf8) | ||
Logger.shared.info("🎉 \(#function) finished") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. この変更により、 |
||
} | ||
|
||
static func readFromREADME() throws -> (URL, String, String.Index, String.Index) { | ||
defer { | ||
Logger.shared.info("🎉 \(#function) finished") | ||
} | ||
Logger.shared.info("ℹ️ \(#function) started") | ||
let url = URL.topLevelDirectory.appendingPathComponent("README.md") | ||
let string = try String(contentsOf: url) | ||
guard let lowerBound = string.range(of: lowerBoundKeyword)?.lowerBound, | ||
let upperBound = string.range(of: upperBoundKeyword)?.upperBound else { | ||
throw Error.invalidREADMEFormat | ||
} | ||
Logger.shared.info("🎉 \(#function) finished") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. この変更により、 |
||
return (url, string, lowerBound, upperBound) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,6 @@ public struct Parser { | |
} | ||
|
||
public static func parse() throws -> [GitHubRepository] { | ||
defer { | ||
Logger.shared.info("🎉 \(#function) finished") | ||
} | ||
Logger.shared.info("ℹ️ \(#function) started") | ||
let url = URL.topLevelDirectory.appendingPathComponent("ReleaseSubscriptions.yml") | ||
let string = try String(contentsOf: url) | ||
|
@@ -39,9 +36,11 @@ public struct Parser { | |
switch `case` { | ||
case "releases": | ||
Logger.shared.info("✅ The correct YAML format: \(name) (\(`case`))") | ||
Logger.shared.info("🎉 \(#function) finished") | ||
return .releases(destination, .init(name: name, owner: owner, repository: repository)) | ||
case "tags": | ||
Logger.shared.info("✅ The correct YAML format: \(name) (\(`case`))") | ||
Logger.shared.info("🎉 \(#function) finished") | ||
Comment on lines
+39
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. この変更により、 |
||
return .tags(destination, .init(name: name, owner: owner, repository: repository)) | ||
default: | ||
throw Error.unknownCase | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,9 +28,6 @@ public struct SlackNotifier { | |
}() | ||
|
||
public static func notify(to slackURLs: [SlackWebhookDestination : URL], updates: [GitHubRepository : [Release]]) async throws { | ||
defer { | ||
Logger.shared.info("🎉 \(#function) finished") | ||
} | ||
Logger.shared.info("ℹ️ \(#function) started") | ||
try await withThrowingTaskGroup(of: Void.self) { group in | ||
for (repository, releases) in updates { | ||
|
@@ -60,6 +57,7 @@ public struct SlackNotifier { | |
} | ||
try await group.waitForAll() | ||
} | ||
Logger.shared.info("🎉 \(#function) finished") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. この変更により、 |
||
} | ||
|
||
static private func message(name: String, owner: String, repo: String, repoURL: URL, title: String, version: String, releaseURL: URL, publishedAt: String?, body: String) -> String { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この変更により、
Fetcher.fetch(repositories:)
がエラーだったときに何も log が残らないため、エラー時もその旨の log を追加したいです。(1つ上にある
Fetcher.fetch(repository:)
にもエラー時の log を追加したいです。)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
スローした先でログを出力するので、ここでは何も残さなくていいと思うんだけどどうだろう?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ほかも同様