Skip to content

Commit

Permalink
Link to user's profile in a generated changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxDesiatov committed Mar 24, 2020
1 parent e5af335 commit 06e02bc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
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

0 comments on commit 06e02bc

Please sign in to comment.