Skip to content

Commit 13ca64c

Browse files
committed
Merge branch 'main' into feat/git-cliff-tui
2 parents a53ce68 + e936ed5 commit 13ca64c

File tree

12 files changed

+354
-24
lines changed

12 files changed

+354
-24
lines changed

.github/fixtures/test-bitbucket-integration/cliff.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
[remote.bitbucket]
2-
owner = "orhunp"
2+
owner = "mcwarman-playground"
33
repo = "git-cliff-readme-example"
44

55
[changelog]
66
# template for the changelog body
77
# https://keats.github.io/tera/docs/#introduction
88
body = """
9+
{%- macro remote_url() -%}
10+
https://bitbucket.org/{{ remote.bitbucket.owner }}/{{ remote.bitbucket.repo }}
11+
{%- endmacro -%}
12+
913
## What's Changed
1014
{%- if version %} in {{ version }}{%- endif -%}
1115
{% for commit in commits %}
1216
* {{ commit.message | split(pat="\n") | first | trim }}\
1317
{% if commit.remote.username %} by @{{ commit.remote.username }}{%- endif -%}
14-
{% if commit.remote.pr_number %} in #{{ commit.remote.pr_number }}{%- endif %}
18+
{% if commit.remote.pr_number %} in \
19+
[#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull-requests/{{ commit.remote.pr_number }})\
20+
{%- endif %}
1521
{%- endfor -%}
1622
1723
{% if bitbucket.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
@@ -21,7 +27,7 @@ body = """
2127
{% for contributor in bitbucket.contributors | filter(attribute="is_first_time", value=true) %}
2228
* @{{ contributor.username }} made their first contribution
2329
{%- if contributor.pr_number %} in \
24-
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
30+
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull-requests/{{ contributor.pr_number }}) \
2531
{%- endif %}
2632
{%- endfor -%}
2733
{% raw %}\n\n{% endraw -%}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
git remote add origin https://bitbucket.org/orhunp/git-cliff-readme-example
4+
git remote add origin https://bitbucket.org/mcwarman-playground/git-cliff-readme-example
55
git pull origin master
66
git fetch --tags

.github/fixtures/test-bitbucket-integration/expected.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## What's Changed
22
* feat(config): support multiple file formats by @orhun <[email protected]>
33
* feat(cache): use cache while fetching pages by @orhun <[email protected]>
4+
* feat(ci): add pipeline config by @mcwarman <[email protected]> in [#1](https://bitbucket.org/mcwarman-playground/git-cliff-readme-example/pull-requests/1)
45

56
## What's Changed in v1.0.1
67
* refactor(parser): expose string functions by @orhun <[email protected]>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
GIT_COMMITTER_DATE="2021-01-23 01:23:45" git commit --allow-empty -m "Initial commit"
4+
GIT_COMMITTER_DATE="2021-01-23 01:23:45" git commit --allow-empty -m "feat: initial commit"
55

66
GIT_COMMITTER_DATE="2021-01-23 01:23:46" git commit --allow-empty -m "feat: add feature 1"
77
git tag v0.1.0

.github/fixtures/test-latest-with-one-tag/expected.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
66

77
### Feat
88

9+
- Initial commit
910
- Add feature 1
1011

1112
<!-- generated by git-cliff -->

Cargo.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

git-cliff-core/src/release.rs

Lines changed: 287 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,4 +1424,291 @@ mod test {
14241424

14251425
Ok(())
14261426
}
1427+
1428+
#[cfg(feature = "bitbucket")]
1429+
#[test]
1430+
fn update_bitbucket_metadata() -> Result<()> {
1431+
use crate::remote::bitbucket::{
1432+
BitbucketCommit,
1433+
BitbucketCommitAuthor,
1434+
BitbucketPullRequest,
1435+
BitbucketPullRequestMergeCommit,
1436+
};
1437+
1438+
let mut release = Release {
1439+
version: None,
1440+
message: None,
1441+
extra: None,
1442+
commits: vec![
1443+
Commit::from(String::from(
1444+
"1d244937ee6ceb8e0314a4a201ba93a7a61f2071 add bitbucket \
1445+
integration",
1446+
)),
1447+
Commit::from(String::from(
1448+
"21f6aa587fcb772de13f2fde0e92697c51f84162 fix bitbucket \
1449+
integration",
1450+
)),
1451+
Commit::from(String::from(
1452+
"35d8c6b6329ecbcf131d7df02f93c3bbc5ba5973 update metadata",
1453+
)),
1454+
Commit::from(String::from(
1455+
"4d3ffe4753b923f4d7807c490e650e6624a12074 do some stuff",
1456+
)),
1457+
Commit::from(String::from(
1458+
"5a55e92e5a62dc5bf9872ffb2566959fad98bd05 alright",
1459+
)),
1460+
Commit::from(String::from(
1461+
"6c34967147560ea09658776d4901709139b4ad66 should be fine",
1462+
)),
1463+
],
1464+
commit_id: None,
1465+
timestamp: 0,
1466+
previous: Some(Box::new(Release {
1467+
version: Some(String::from("1.0.0")),
1468+
..Default::default()
1469+
})),
1470+
repository: Some(String::from("/root/repo")),
1471+
#[cfg(feature = "github")]
1472+
github: RemoteReleaseMetadata {
1473+
contributors: vec![],
1474+
},
1475+
#[cfg(feature = "gitlab")]
1476+
gitlab: RemoteReleaseMetadata {
1477+
contributors: vec![],
1478+
},
1479+
#[cfg(feature = "gitea")]
1480+
gitea: RemoteReleaseMetadata {
1481+
contributors: vec![],
1482+
},
1483+
#[cfg(feature = "bitbucket")]
1484+
bitbucket: RemoteReleaseMetadata {
1485+
contributors: vec![],
1486+
},
1487+
};
1488+
release.update_bitbucket_metadata(
1489+
vec![
1490+
BitbucketCommit {
1491+
hash: String::from("1d244937ee6ceb8e0314a4a201ba93a7a61f2071"),
1492+
author: Some(BitbucketCommitAuthor {
1493+
login: Some(String::from("orhun")),
1494+
}),
1495+
},
1496+
BitbucketCommit {
1497+
hash: String::from("21f6aa587fcb772de13f2fde0e92697c51f84162"),
1498+
author: Some(BitbucketCommitAuthor {
1499+
login: Some(String::from("orhun")),
1500+
}),
1501+
},
1502+
BitbucketCommit {
1503+
hash: String::from("35d8c6b6329ecbcf131d7df02f93c3bbc5ba5973"),
1504+
author: Some(BitbucketCommitAuthor {
1505+
login: Some(String::from("nuhro")),
1506+
}),
1507+
},
1508+
BitbucketCommit {
1509+
hash: String::from("4d3ffe4753b923f4d7807c490e650e6624a12074"),
1510+
author: Some(BitbucketCommitAuthor {
1511+
login: Some(String::from("awesome_contributor")),
1512+
}),
1513+
},
1514+
BitbucketCommit {
1515+
hash: String::from("5a55e92e5a62dc5bf9872ffb2566959fad98bd05"),
1516+
author: Some(BitbucketCommitAuthor {
1517+
login: Some(String::from("orhun")),
1518+
}),
1519+
},
1520+
BitbucketCommit {
1521+
hash: String::from("6c34967147560ea09658776d4901709139b4ad66"),
1522+
author: Some(BitbucketCommitAuthor {
1523+
login: Some(String::from("someone")),
1524+
}),
1525+
},
1526+
BitbucketCommit {
1527+
hash: String::from("0c34967147560e809658776d4901709139b4ad68"),
1528+
author: Some(BitbucketCommitAuthor {
1529+
login: Some(String::from("idk")),
1530+
}),
1531+
},
1532+
BitbucketCommit {
1533+
hash: String::from("kk34967147560e809658776d4901709139b4ad68"),
1534+
author: Some(BitbucketCommitAuthor {
1535+
login: Some(String::from("orhun")),
1536+
}),
1537+
},
1538+
]
1539+
.into_iter()
1540+
.map(|v| Box::new(v) as Box<dyn RemoteCommit>)
1541+
.collect(),
1542+
vec![Box::new(BitbucketPullRequest {
1543+
id: 1,
1544+
title: Some(String::from("1")),
1545+
author: BitbucketCommitAuthor {
1546+
login: Some(String::from("42")),
1547+
},
1548+
merge_commit: BitbucketPullRequestMergeCommit {
1549+
// Bitbucket merge commits returned in short format
1550+
hash: String::from("1d244937ee6c"),
1551+
},
1552+
})],
1553+
)?;
1554+
#[allow(deprecated)]
1555+
let expected_commits = vec![
1556+
Commit {
1557+
id: String::from("1d244937ee6ceb8e0314a4a201ba93a7a61f2071"),
1558+
message: String::from("add bitbucket integration"),
1559+
bitbucket: RemoteContributor {
1560+
username: Some(String::from("orhun")),
1561+
pr_title: Some(String::from("1")),
1562+
pr_number: Some(1),
1563+
pr_labels: vec![],
1564+
is_first_time: false,
1565+
},
1566+
remote: Some(RemoteContributor {
1567+
username: Some(String::from("orhun")),
1568+
pr_title: Some(String::from("1")),
1569+
pr_number: Some(1),
1570+
pr_labels: vec![],
1571+
is_first_time: false,
1572+
}),
1573+
..Default::default()
1574+
},
1575+
Commit {
1576+
id: String::from("21f6aa587fcb772de13f2fde0e92697c51f84162"),
1577+
message: String::from("fix bitbucket integration"),
1578+
bitbucket: RemoteContributor {
1579+
username: Some(String::from("orhun")),
1580+
pr_title: None,
1581+
pr_number: None,
1582+
pr_labels: vec![],
1583+
is_first_time: false,
1584+
},
1585+
remote: Some(RemoteContributor {
1586+
username: Some(String::from("orhun")),
1587+
pr_title: None,
1588+
pr_number: None,
1589+
pr_labels: vec![],
1590+
is_first_time: false,
1591+
}),
1592+
..Default::default()
1593+
},
1594+
Commit {
1595+
id: String::from("35d8c6b6329ecbcf131d7df02f93c3bbc5ba5973"),
1596+
message: String::from("update metadata"),
1597+
bitbucket: RemoteContributor {
1598+
username: Some(String::from("nuhro")),
1599+
pr_title: None,
1600+
pr_number: None,
1601+
pr_labels: vec![],
1602+
is_first_time: false,
1603+
},
1604+
remote: Some(RemoteContributor {
1605+
username: Some(String::from("nuhro")),
1606+
pr_title: None,
1607+
pr_number: None,
1608+
pr_labels: vec![],
1609+
is_first_time: false,
1610+
}),
1611+
..Default::default()
1612+
},
1613+
Commit {
1614+
id: String::from("4d3ffe4753b923f4d7807c490e650e6624a12074"),
1615+
message: String::from("do some stuff"),
1616+
bitbucket: RemoteContributor {
1617+
username: Some(String::from("awesome_contributor")),
1618+
pr_title: None,
1619+
pr_number: None,
1620+
pr_labels: vec![],
1621+
is_first_time: false,
1622+
},
1623+
remote: Some(RemoteContributor {
1624+
username: Some(String::from("awesome_contributor")),
1625+
pr_title: None,
1626+
pr_number: None,
1627+
pr_labels: vec![],
1628+
is_first_time: false,
1629+
}),
1630+
..Default::default()
1631+
},
1632+
Commit {
1633+
id: String::from("5a55e92e5a62dc5bf9872ffb2566959fad98bd05"),
1634+
message: String::from("alright"),
1635+
bitbucket: RemoteContributor {
1636+
username: Some(String::from("orhun")),
1637+
pr_title: None,
1638+
pr_number: None,
1639+
pr_labels: vec![],
1640+
is_first_time: false,
1641+
},
1642+
remote: Some(RemoteContributor {
1643+
username: Some(String::from("orhun")),
1644+
pr_title: None,
1645+
pr_number: None,
1646+
pr_labels: vec![],
1647+
is_first_time: false,
1648+
}),
1649+
..Default::default()
1650+
},
1651+
Commit {
1652+
id: String::from("6c34967147560ea09658776d4901709139b4ad66"),
1653+
message: String::from("should be fine"),
1654+
bitbucket: RemoteContributor {
1655+
username: Some(String::from("someone")),
1656+
pr_title: None,
1657+
pr_number: None,
1658+
pr_labels: vec![],
1659+
is_first_time: false,
1660+
},
1661+
remote: Some(RemoteContributor {
1662+
username: Some(String::from("someone")),
1663+
pr_title: None,
1664+
pr_number: None,
1665+
pr_labels: vec![],
1666+
is_first_time: false,
1667+
}),
1668+
..Default::default()
1669+
},
1670+
];
1671+
assert_eq!(expected_commits, release.commits);
1672+
1673+
release
1674+
.bitbucket
1675+
.contributors
1676+
.sort_by(|a, b| a.pr_number.cmp(&b.pr_number));
1677+
1678+
let expected_metadata = RemoteReleaseMetadata {
1679+
contributors: vec![
1680+
RemoteContributor {
1681+
username: Some(String::from("nuhro")),
1682+
pr_title: None,
1683+
pr_number: None,
1684+
pr_labels: vec![],
1685+
is_first_time: true,
1686+
},
1687+
RemoteContributor {
1688+
username: Some(String::from("awesome_contributor")),
1689+
pr_title: None,
1690+
pr_number: None,
1691+
pr_labels: vec![],
1692+
is_first_time: true,
1693+
},
1694+
RemoteContributor {
1695+
username: Some(String::from("someone")),
1696+
pr_title: None,
1697+
pr_number: None,
1698+
pr_labels: vec![],
1699+
is_first_time: true,
1700+
},
1701+
RemoteContributor {
1702+
username: Some(String::from("orhun")),
1703+
pr_title: Some(String::from("1")),
1704+
pr_number: Some(1),
1705+
pr_labels: vec![],
1706+
is_first_time: false,
1707+
},
1708+
],
1709+
};
1710+
assert_eq!(expected_metadata, release.bitbucket);
1711+
1712+
Ok(())
1713+
}
14271714
}

0 commit comments

Comments
 (0)