Skip to content
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

Link to user's profile in a generated changelog #37

Merged
merged 1 commit into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/GitBuddyCore/Models/ChangelogItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct ChangelogItem {
title += " ([#\(input.number)](\(htmlURL)))"
}
if let username = closedBy.username {
title += " via @\(username)"
title += " via [@\(username)](https://github.com/\(username))"
}
return title
}
Expand Down
10 changes: 9 additions & 1 deletion Tests/GitBuddyTests/Changelog/ChangelogProducerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,15 @@ final class ChangelogProducerTests: XCTestCase {
Mocker.mockForIssueNumber(39)
MockedShell.mockGITProject(organisation: "WeTransfer", repository: "Diagnostics")
let changelog = try GitBuddy.run(arguments: ["GitBuddy", "changelog"], configuration: configuration)
XCTAssertEqual(changelog, "- Add charset utf-8 to html head ([#50](https://github.com/WeTransfer/Diagnostics/pull/50)) via @AvdLee\n- Get warning for file \'style.css\' after building ([#39](https://github.com/WeTransfer/Diagnostics/issues/39)) via @AvdLee")
XCTAssertEqual(
changelog,
"""
- Add charset utf-8 to html head \
([#50](https://github.com/WeTransfer/Diagnostics/pull/50)) via [@AvdLee](https://github.com/AvdLee)
- Get warning for file \'style.css\' after building \
([#39](https://github.com/WeTransfer/Diagnostics/issues/39)) via [@AvdLee](https://github.com/AvdLee)
"""
)
}

/// It should default to master branch.
Expand Down
12 changes: 9 additions & 3 deletions Tests/GitBuddyTests/Models/ChangelogItemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class ChangelogItemTests: XCTestCase {
let input = PullRequestsJSON.data(using: .utf8)!.mapJSON(to: [PullRequest].self).first!
input.htmlURL = nil
let item = ChangelogItem(input: input, closedBy: input)
XCTAssertEqual(item.title, "\(input.title!) via @AvdLee")
XCTAssertEqual(item.title, "\(input.title!) via [@AvdLee](https://github.com/AvdLee)")
}

/// It should fallback to the assignee if the user is nil for Pull Requests.
Expand All @@ -39,15 +39,21 @@ final class ChangelogItemTests: XCTestCase {
input.user = nil
input.htmlURL = nil
let item = ChangelogItem(input: input, closedBy: input)
XCTAssertEqual(item.title, "\(input.title!) via @kairadiagne")
XCTAssertEqual(
item.title,
"\(input.title!) via [@kairadiagne](https://github.com/kairadiagne)"
)
}

/// It should combine the title, number and user.
func testTitleNumberUser() {
let input = MockChangelogInput(number: 1, title: UUID().uuidString, htmlURL: URL(string: "https://www.fakeurl.com")!)
let closedBy = MockedPullRequest(username: "Henk")
let item = ChangelogItem(input: input, closedBy: closedBy)
XCTAssertEqual(item.title, "\(input.title!) ([#1](https://www.fakeurl.com)) via @Henk")
XCTAssertEqual(
item.title,
"\(input.title!) ([#1](https://www.fakeurl.com)) via [@Henk](https://github.com/Henk)"
)
}

}
12 changes: 8 additions & 4 deletions Tests/GitBuddyTests/Release/ReleaseProducerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ final class ReleaseProducerTests: XCTestCase {
XCTAssertEqual(parameters["tag_name"] as? String, "1.0.1")
XCTAssertEqual(parameters["name"] as? String, "1.0.1")
XCTAssertEqual(parameters["body"] as? String, """
- Add charset utf-8 to html head ([#50](https://github.com/WeTransfer/Diagnostics/pull/50)) via @AvdLee
- Get warning for file 'style.css' after building ([#39](https://github.com/WeTransfer/Diagnostics/issues/39)) via @AvdLee
- Add charset utf-8 to html head \
([#50](https://github.com/WeTransfer/Diagnostics/pull/50)) via [@AvdLee](https://github.com/AvdLee)
- Get warning for file 'style.css' after building \
([#39](https://github.com/WeTransfer/Diagnostics/issues/39)) via [@AvdLee](https://github.com/AvdLee)
""")
mockExpectation.fulfill()
}
Expand All @@ -76,8 +78,10 @@ final class ReleaseProducerTests: XCTestCase {

XCTAssertEqual(updatedChangelogContents, """
### 1.0.1
- Add charset utf-8 to html head ([#50](https://github.com/WeTransfer/Diagnostics/pull/50)) via @AvdLee
- Get warning for file \'style.css\' after building ([#39](https://github.com/WeTransfer/Diagnostics/issues/39)) via @AvdLee
- Add charset utf-8 to html head \
([#50](https://github.com/WeTransfer/Diagnostics/pull/50)) via [@AvdLee](https://github.com/AvdLee)
- Get warning for file \'style.css\' after building \
([#39](https://github.com/WeTransfer/Diagnostics/issues/39)) via [@AvdLee](https://github.com/AvdLee)
\(existingChangelog)
""")
Expand Down