mirror of
https://github.com/orhun/git-cliff.git
synced 2025-01-05 22:54:48 +03:00
refactor(changelog): use timestamp for release dates
Signed-off-by: orhun <orhunparmaksiz@gmail.com>
This commit is contained in:
parent
bdf85d5302
commit
0e4d560761
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -317,7 +317,6 @@ dependencies = [
|
||||
name = "gitolith-cli"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"gitolith-core",
|
||||
"log",
|
||||
"pretty_env_logger",
|
||||
|
@ -16,7 +16,6 @@ edition = "2018"
|
||||
gitolith-core = { path = "../gitolith-core" }
|
||||
pretty_env_logger = "0.4.0"
|
||||
log = "0.4.14"
|
||||
chrono = "0.4.19"
|
||||
|
||||
[dependencies.structopt]
|
||||
version = "0.3"
|
||||
|
@ -1,11 +1,6 @@
|
||||
mod args;
|
||||
|
||||
use args::Opt;
|
||||
use chrono::{
|
||||
DateTime,
|
||||
NaiveDateTime,
|
||||
Utc,
|
||||
};
|
||||
use gitolith_core::changelog::Changelog;
|
||||
use gitolith_core::commit::Commit;
|
||||
use gitolith_core::config::Config;
|
||||
@ -50,14 +45,8 @@ fn main() -> Result<()> {
|
||||
if let Some(tag) = tags.get(&commit_id) {
|
||||
release_root.releases[release_index].version = Some(tag.to_string());
|
||||
release_root.releases[release_index].commit_id = Some(commit_id);
|
||||
release_root.releases[release_index].date = Some(
|
||||
DateTime::<Utc>::from_utc(
|
||||
NaiveDateTime::from_timestamp(git_commit.time().seconds(), 0),
|
||||
Utc,
|
||||
)
|
||||
.format(&config.changelog.date_format)
|
||||
.to_string(),
|
||||
);
|
||||
release_root.releases[release_index].timestamp =
|
||||
git_commit.time().seconds();
|
||||
release_index += 1;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ pub struct ChangelogConfig {
|
||||
pub group_parsers: Vec<GroupParser>,
|
||||
pub filter_group: bool,
|
||||
pub tag_pattern: String,
|
||||
pub date_format: String,
|
||||
}
|
||||
|
||||
/// Parser for grouping commits.
|
||||
|
@ -29,5 +29,5 @@ pub struct Release<'a> {
|
||||
pub commits: Vec<Commit<'a>>,
|
||||
#[serde(rename = "commit_id")]
|
||||
pub commit_id: Option<String>,
|
||||
pub date: Option<String>,
|
||||
pub timestamp: i64,
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
# template for the changelog body
|
||||
# https://tera.netlify.app/docs/#introduction
|
||||
body = """
|
||||
## {% if version %}[{{ version }}] - {{ date }}{% else %}[unreleased]{% endif %}
|
||||
## {% if version %}[{{ version }}] - {{ timestamp | date(format="%Y-%m-%d") }}{% else %}[unreleased]{% endif %}
|
||||
{% for group, commits in commits | group_by(attribute="group") %}
|
||||
### {{ group | capitalize}}
|
||||
{% for commit in commits %}
|
||||
@ -34,6 +34,3 @@ filter_group = false
|
||||
|
||||
# glob pattern for matching tags
|
||||
tag_pattern = "v[0-9]*"
|
||||
|
||||
# https://docs.rs/chrono/latest/chrono/format/strftime/index.html
|
||||
date_format = "%Y-%m-%d"
|
||||
|
Loading…
Reference in New Issue
Block a user