mirror of
https://github.com/orhun/git-cliff.git
synced 2024-09-11 15:05:30 +03:00
Compare commits
3 Commits
78f37e49f1
...
9495fb4ede
Author | SHA1 | Date | |
---|---|---|---|
|
9495fb4ede | ||
|
9e152a2dc0 | ||
|
e5b31a26e5 |
@ -613,7 +613,7 @@ mod test {
|
|||||||
header: Some(String::from("# Changelog")),
|
header: Some(String::from("# Changelog")),
|
||||||
body: Some(String::from(
|
body: Some(String::from(
|
||||||
r#"{% if version %}
|
r#"{% if version %}
|
||||||
## Release [{{ version }}] - {{ timestamp | date(format="%Y-%m-%d") }}
|
## Release [{{ version }}] - {{ timestamp | date(format="%Y-%m-%d") }} - ({{ repository }})
|
||||||
{% if commit_id %}({{ commit_id }}){% endif %}{% else %}
|
{% if commit_id %}({{ commit_id }}){% endif %}{% else %}
|
||||||
## Unreleased{% endif %}
|
## Unreleased{% endif %}
|
||||||
{% for group, commits in commits | group_by(attribute="group") %}
|
{% for group, commits in commits | group_by(attribute="group") %}
|
||||||
@ -880,6 +880,7 @@ mod test {
|
|||||||
commit_id: Some(String::from("0bc123")),
|
commit_id: Some(String::from("0bc123")),
|
||||||
timestamp: 50000000,
|
timestamp: 50000000,
|
||||||
previous: None,
|
previous: None,
|
||||||
|
repository: Some(String::from("/root/repo")),
|
||||||
#[cfg(feature = "github")]
|
#[cfg(feature = "github")]
|
||||||
github: crate::remote::RemoteReleaseMetadata {
|
github: crate::remote::RemoteReleaseMetadata {
|
||||||
contributors: vec![],
|
contributors: vec![],
|
||||||
@ -939,6 +940,7 @@ mod test {
|
|||||||
commit_id: None,
|
commit_id: None,
|
||||||
timestamp: 1000,
|
timestamp: 1000,
|
||||||
previous: Some(Box::new(test_release)),
|
previous: Some(Box::new(test_release)),
|
||||||
|
repository: Some(String::from("/root/repo")),
|
||||||
#[cfg(feature = "github")]
|
#[cfg(feature = "github")]
|
||||||
github: crate::remote::RemoteReleaseMetadata {
|
github: crate::remote::RemoteReleaseMetadata {
|
||||||
contributors: vec![],
|
contributors: vec![],
|
||||||
@ -972,7 +974,7 @@ mod test {
|
|||||||
String::from(
|
String::from(
|
||||||
r#"# Changelog
|
r#"# Changelog
|
||||||
|
|
||||||
## Release [v1.1.0] - 1970-01-01
|
## Release [v1.1.0] - 1970-01-01 - (/root/repo)
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
@ -990,7 +992,7 @@ mod test {
|
|||||||
#### ui
|
#### ui
|
||||||
- do exciting stuff
|
- do exciting stuff
|
||||||
|
|
||||||
## Release [v1.0.0] - 1971-08-02
|
## Release [v1.0.0] - 1971-08-02 - (/root/repo)
|
||||||
(0bc123)
|
(0bc123)
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
@ -1115,7 +1117,7 @@ chore(deps): fix broken deps
|
|||||||
#### app
|
#### app
|
||||||
- merge #5
|
- merge #5
|
||||||
|
|
||||||
## Release [v1.0.0] - 1971-08-02
|
## Release [v1.0.0] - 1971-08-02 - (/root/repo)
|
||||||
(0bc123)
|
(0bc123)
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
@ -20,28 +20,30 @@ use serde::{
|
|||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct Release<'a> {
|
pub struct Release<'a> {
|
||||||
/// Release version, git tag.
|
/// Release version, git tag.
|
||||||
pub version: Option<String>,
|
pub version: Option<String>,
|
||||||
/// Commits made for the release.
|
/// Commits made for the release.
|
||||||
pub commits: Vec<Commit<'a>>,
|
pub commits: Vec<Commit<'a>>,
|
||||||
/// Commit ID of the tag.
|
/// Commit ID of the tag.
|
||||||
#[serde(rename = "commit_id")]
|
#[serde(rename = "commit_id")]
|
||||||
pub commit_id: Option<String>,
|
pub commit_id: Option<String>,
|
||||||
/// Timestamp of the release in seconds, from epoch.
|
/// Timestamp of the release in seconds, from epoch.
|
||||||
pub timestamp: i64,
|
pub timestamp: i64,
|
||||||
/// Previous release.
|
/// Previous release.
|
||||||
pub previous: Option<Box<Release<'a>>>,
|
pub previous: Option<Box<Release<'a>>>,
|
||||||
|
/// Repository path.
|
||||||
|
pub repository: Option<String>,
|
||||||
/// Contributors.
|
/// Contributors.
|
||||||
#[cfg(feature = "github")]
|
#[cfg(feature = "github")]
|
||||||
pub github: RemoteReleaseMetadata,
|
pub github: RemoteReleaseMetadata,
|
||||||
/// Contributors.
|
/// Contributors.
|
||||||
#[cfg(feature = "gitlab")]
|
#[cfg(feature = "gitlab")]
|
||||||
pub gitlab: RemoteReleaseMetadata,
|
pub gitlab: RemoteReleaseMetadata,
|
||||||
/// Contributors.
|
/// Contributors.
|
||||||
#[cfg(feature = "gitea")]
|
#[cfg(feature = "gitea")]
|
||||||
pub gitea: RemoteReleaseMetadata,
|
pub gitea: RemoteReleaseMetadata,
|
||||||
/// Contributors.
|
/// Contributors.
|
||||||
#[cfg(feature = "bitbucket")]
|
#[cfg(feature = "bitbucket")]
|
||||||
pub bitbucket: RemoteReleaseMetadata,
|
pub bitbucket: RemoteReleaseMetadata,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "github")]
|
#[cfg(feature = "github")]
|
||||||
@ -169,6 +171,7 @@ mod test {
|
|||||||
version: Some(String::from(version)),
|
version: Some(String::from(version)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})),
|
})),
|
||||||
|
repository: Some(String::from("/root/repo")),
|
||||||
#[cfg(feature = "github")]
|
#[cfg(feature = "github")]
|
||||||
github: crate::remote::RemoteReleaseMetadata {
|
github: crate::remote::RemoteReleaseMetadata {
|
||||||
contributors: vec![],
|
contributors: vec![],
|
||||||
@ -368,6 +371,7 @@ mod test {
|
|||||||
version: Some(String::from("1.0.0")),
|
version: Some(String::from("1.0.0")),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})),
|
})),
|
||||||
|
repository: Some(String::from("/root/repo")),
|
||||||
github: RemoteReleaseMetadata {
|
github: RemoteReleaseMetadata {
|
||||||
contributors: vec![],
|
contributors: vec![],
|
||||||
},
|
},
|
||||||
@ -653,6 +657,7 @@ mod test {
|
|||||||
version: Some(String::from("1.0.0")),
|
version: Some(String::from("1.0.0")),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})),
|
})),
|
||||||
|
repository: Some(String::from("/root/repo")),
|
||||||
#[cfg(feature = "github")]
|
#[cfg(feature = "github")]
|
||||||
github: RemoteReleaseMetadata {
|
github: RemoteReleaseMetadata {
|
||||||
contributors: vec![],
|
contributors: vec![],
|
||||||
@ -996,6 +1001,7 @@ mod test {
|
|||||||
version: Some(String::from("1.0.0")),
|
version: Some(String::from("1.0.0")),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})),
|
})),
|
||||||
|
repository: Some(String::from("/root/repo")),
|
||||||
#[cfg(feature = "github")]
|
#[cfg(feature = "github")]
|
||||||
github: RemoteReleaseMetadata {
|
github: RemoteReleaseMetadata {
|
||||||
contributors: vec![],
|
contributors: vec![],
|
||||||
|
@ -22,7 +22,9 @@ use url::Url;
|
|||||||
///
|
///
|
||||||
/// [`Repository`]: GitRepository
|
/// [`Repository`]: GitRepository
|
||||||
pub struct Repository {
|
pub struct Repository {
|
||||||
inner: GitRepository,
|
inner: GitRepository,
|
||||||
|
/// Repository path.
|
||||||
|
pub path: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Repository {
|
impl Repository {
|
||||||
@ -30,7 +32,8 @@ impl Repository {
|
|||||||
pub fn init(path: PathBuf) -> Result<Self> {
|
pub fn init(path: PathBuf) -> Result<Self> {
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
inner: GitRepository::open(path)?,
|
inner: GitRepository::open(&path)?,
|
||||||
|
path,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(Error::IoError(io::Error::new(
|
Err(Error::IoError(io::Error::new(
|
||||||
|
@ -205,6 +205,7 @@ mod test {
|
|||||||
commit_id: None,
|
commit_id: None,
|
||||||
timestamp: 0,
|
timestamp: 0,
|
||||||
previous: None,
|
previous: None,
|
||||||
|
repository: Some(String::from("/root/repo")),
|
||||||
#[cfg(feature = "github")]
|
#[cfg(feature = "github")]
|
||||||
github: crate::remote::RemoteReleaseMetadata {
|
github: crate::remote::RemoteReleaseMetadata {
|
||||||
contributors: vec![],
|
contributors: vec![],
|
||||||
|
@ -193,6 +193,7 @@ fn generate_changelog() -> Result<()> {
|
|||||||
commit_id: None,
|
commit_id: None,
|
||||||
timestamp: 0,
|
timestamp: 0,
|
||||||
previous: None,
|
previous: None,
|
||||||
|
repository: Some(String::from("/root/repo")),
|
||||||
#[cfg(feature = "github")]
|
#[cfg(feature = "github")]
|
||||||
github: git_cliff_core::remote::RemoteReleaseMetadata {
|
github: git_cliff_core::remote::RemoteReleaseMetadata {
|
||||||
contributors: vec![],
|
contributors: vec![],
|
||||||
@ -233,6 +234,7 @@ fn generate_changelog() -> Result<()> {
|
|||||||
commit_id: None,
|
commit_id: None,
|
||||||
timestamp: 0,
|
timestamp: 0,
|
||||||
previous: None,
|
previous: None,
|
||||||
|
repository: Some(String::from("/root/repo")),
|
||||||
#[cfg(feature = "github")]
|
#[cfg(feature = "github")]
|
||||||
github: git_cliff_core::remote::RemoteReleaseMetadata {
|
github: git_cliff_core::remote::RemoteReleaseMetadata {
|
||||||
contributors: vec![],
|
contributors: vec![],
|
||||||
|
@ -243,6 +243,8 @@ fn process_repository<'a>(
|
|||||||
for git_commit in commits.iter().rev() {
|
for git_commit in commits.iter().rev() {
|
||||||
let commit = Commit::from(git_commit);
|
let commit = Commit::from(git_commit);
|
||||||
let commit_id = commit.id.to_string();
|
let commit_id = commit.id.to_string();
|
||||||
|
releases[release_index].repository =
|
||||||
|
Some(repository.path.to_string_lossy().to_string());
|
||||||
if args.sort == Sort::Newest {
|
if args.sort == Sort::Newest {
|
||||||
releases[release_index].commits.insert(0, commit);
|
releases[release_index].commits.insert(0, commit);
|
||||||
} else {
|
} else {
|
||||||
|
@ -61,6 +61,7 @@ following context is generated to use for templating:
|
|||||||
],
|
],
|
||||||
"commit_id": "a440c6eb26404be4877b7e3ad592bfaa5d4eb210 (release commit)",
|
"commit_id": "a440c6eb26404be4877b7e3ad592bfaa5d4eb210 (release commit)",
|
||||||
"timestamp": 1625169301,
|
"timestamp": 1625169301,
|
||||||
|
"repository": "/path/to/repository",
|
||||||
"previous": {
|
"previous": {
|
||||||
"version": "previous release"
|
"version": "previous release"
|
||||||
}
|
}
|
||||||
@ -154,6 +155,7 @@ If [`conventional_commits`](/docs/configuration/git#conventional_commits) is set
|
|||||||
],
|
],
|
||||||
"commit_id": "a440c6eb26404be4877b7e3ad592bfaa5d4eb210 (release commit)",
|
"commit_id": "a440c6eb26404be4877b7e3ad592bfaa5d4eb210 (release commit)",
|
||||||
"timestamp": 1625169301,
|
"timestamp": 1625169301,
|
||||||
|
"repository": "/path/to/repository",
|
||||||
"previous": {
|
"previous": {
|
||||||
"version": "previous release"
|
"version": "previous release"
|
||||||
}
|
}
|
||||||
|
@ -11,3 +11,11 @@ git cliff --repository path1 path2
|
|||||||
```
|
```
|
||||||
|
|
||||||
Note that the changelog will be generated using the merged history of the given repositories.
|
Note that the changelog will be generated using the merged history of the given repositories.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
You can use the `{{ repository }}` variable in the template to display which release belongs to which repository.
|
||||||
|
|
||||||
|
See [context](/docs/templating/context) for more information.
|
||||||
|
|
||||||
|
:::
|
||||||
|
8
website/package-lock.json
generated
8
website/package-lock.json
generated
@ -11,7 +11,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@docusaurus/core": "^3.4.0",
|
"@docusaurus/core": "^3.4.0",
|
||||||
"@docusaurus/preset-classic": "^3.4.0",
|
"@docusaurus/preset-classic": "^3.4.0",
|
||||||
"@easyops-cn/docusaurus-search-local": "^0.44.1",
|
"@easyops-cn/docusaurus-search-local": "^0.44.2",
|
||||||
"@mdx-js/react": "^3.0.1",
|
"@mdx-js/react": "^3.0.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"prism-react-renderer": "^2.3.0",
|
"prism-react-renderer": "^2.3.0",
|
||||||
@ -2738,9 +2738,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@easyops-cn/docusaurus-search-local": {
|
"node_modules/@easyops-cn/docusaurus-search-local": {
|
||||||
"version": "0.44.1",
|
"version": "0.44.2",
|
||||||
"resolved": "https://registry.npmjs.org/@easyops-cn/docusaurus-search-local/-/docusaurus-search-local-0.44.1.tgz",
|
"resolved": "https://registry.npmjs.org/@easyops-cn/docusaurus-search-local/-/docusaurus-search-local-0.44.2.tgz",
|
||||||
"integrity": "sha512-AxofPmf5Vayzj1Z2XOSORwg0nu/v/uaSfEfacs4eCqazI1+LH+abdgzCxUvarFrjy+ViSj+fqoZwppx5sePY1Q==",
|
"integrity": "sha512-4tMBU54R1O6ITxkMGwOEifSHNkZLa2fb4ajGc8rd6TYZ0a8+jlu/u/5gYtw1s6sGGMRkwyG+QI6HD0bEnCRa1w==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@docusaurus/plugin-content-docs": "^2 || ^3",
|
"@docusaurus/plugin-content-docs": "^2 || ^3",
|
||||||
"@docusaurus/theme-translations": "^2 || ^3",
|
"@docusaurus/theme-translations": "^2 || ^3",
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@docusaurus/core": "^3.4.0",
|
"@docusaurus/core": "^3.4.0",
|
||||||
"@docusaurus/preset-classic": "^3.4.0",
|
"@docusaurus/preset-classic": "^3.4.0",
|
||||||
"@easyops-cn/docusaurus-search-local": "^0.44.1",
|
"@easyops-cn/docusaurus-search-local": "^0.44.2",
|
||||||
"@mdx-js/react": "^3.0.1",
|
"@mdx-js/react": "^3.0.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"prism-react-renderer": "^2.3.0",
|
"prism-react-renderer": "^2.3.0",
|
||||||
|
@ -1671,10 +1671,10 @@
|
|||||||
cssesc "^3.0.0"
|
cssesc "^3.0.0"
|
||||||
immediate "^3.2.3"
|
immediate "^3.2.3"
|
||||||
|
|
||||||
"@easyops-cn/docusaurus-search-local@^0.44.1":
|
"@easyops-cn/docusaurus-search-local@^0.44.2":
|
||||||
version "0.44.1"
|
version "0.44.2"
|
||||||
resolved "https://registry.yarnpkg.com/@easyops-cn/docusaurus-search-local/-/docusaurus-search-local-0.44.1.tgz#3076afdd30f1947771a25b07ec994814aa91013e"
|
resolved "https://registry.yarnpkg.com/@easyops-cn/docusaurus-search-local/-/docusaurus-search-local-0.44.2.tgz#580925d8b94220cecbe30c466bdc0b32cb275cf6"
|
||||||
integrity sha512-AxofPmf5Vayzj1Z2XOSORwg0nu/v/uaSfEfacs4eCqazI1+LH+abdgzCxUvarFrjy+ViSj+fqoZwppx5sePY1Q==
|
integrity sha512-4tMBU54R1O6ITxkMGwOEifSHNkZLa2fb4ajGc8rd6TYZ0a8+jlu/u/5gYtw1s6sGGMRkwyG+QI6HD0bEnCRa1w==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@docusaurus/plugin-content-docs" "^2 || ^3"
|
"@docusaurus/plugin-content-docs" "^2 || ^3"
|
||||||
"@docusaurus/theme-translations" "^2 || ^3"
|
"@docusaurus/theme-translations" "^2 || ^3"
|
||||||
|
Loading…
Reference in New Issue
Block a user