mirror of
https://github.com/orhun/git-cliff.git
synced 2024-11-20 10:50:31 +03:00
feat(changelog, config)!: replace --date-order
by --topo-order
This commit is contained in:
parent
352e884877
commit
ce7d44f666
2
.github/fixtures/test-date-order/cliff.toml
vendored
2
.github/fixtures/test-date-order/cliff.toml
vendored
@ -26,5 +26,3 @@ footer = """
|
||||
<!-- generated by git-cliff -->
|
||||
"""
|
||||
|
||||
[git]
|
||||
date_order = true
|
||||
|
6
.github/fixtures/test-fixtures-locally.sh
vendored
6
.github/fixtures/test-fixtures-locally.sh
vendored
@ -4,8 +4,8 @@ set -e
|
||||
SCRIPT_DIR=$(readlink -f "$(dirname "$0")")
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Please input a fixture name."
|
||||
exit 1
|
||||
echo "Please input a fixture name."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export FIXTURES_DIR="$SCRIPT_DIR/$1"
|
||||
@ -19,4 +19,4 @@ git init
|
||||
|
||||
# Show results
|
||||
echo -e "\n---Run git-cliff---"
|
||||
cargo run --manifest-path "$SCRIPT_DIR/../../Cargo.toml" -- --config "$FIXTURES_DIR/cliff.toml" $2
|
||||
cargo run --manifest-path "$SCRIPT_DIR/../../Cargo.toml" -- --config "$FIXTURES_DIR/cliff.toml" "$@"
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [0.1.1] - 2021-01-23
|
||||
## [0.2.0] - 2021-01-23
|
||||
|
||||
### Feat
|
||||
|
||||
- Fix feature 1
|
||||
- Add feature 2
|
||||
|
||||
<!-- generated by git-cliff -->
|
3
.github/fixtures/test-topo-order/cliff.toml
vendored
3
.github/fixtures/test-topo-order/cliff.toml
vendored
@ -25,3 +25,6 @@ trim = true
|
||||
footer = """
|
||||
<!-- generated by git-cliff -->
|
||||
"""
|
||||
|
||||
[git]
|
||||
topo_order = true
|
||||
|
4
.github/workflows/test-fixtures.yml
vendored
4
.github/workflows/test-fixtures.yml
vendored
@ -21,8 +21,8 @@ jobs:
|
||||
command: --latest
|
||||
- fixtures-name: test-date-order
|
||||
command: --latest
|
||||
- fixtures-name: test-date-order-arg
|
||||
command: --latest --date-order
|
||||
- fixtures-name: test-topo-order-arg
|
||||
command: --latest --topo-order
|
||||
- fixtures-name: test-latest-with-one-tag
|
||||
command: --latest
|
||||
- fixtures-name: test-commit-preprocessors
|
||||
|
18
README.md
18
README.md
@ -70,7 +70,7 @@
|
||||
- [tag_pattern](#tag_pattern)
|
||||
- [skip_tags](#skip_tags)
|
||||
- [ignore_tags](#ignore_tags)
|
||||
- [date_order](#date_order)
|
||||
- [topo_order](#topo_order)
|
||||
- [sort_commits](#sort_commits)
|
||||
- [link_parsers](#link_parsers)
|
||||
- [Project Integration](#project-integration)
|
||||
@ -164,7 +164,7 @@ git-cliff [FLAGS] [OPTIONS] [--] [RANGE]
|
||||
-l, --latest Processes the commits starting from the latest tag
|
||||
--current Processes the commits that belong to the current tag
|
||||
-u, --unreleased Processes the commits that do not belong to a tag
|
||||
-d, --date-order Sorts the tags chronologically
|
||||
--topo-order Sorts the tags topologically
|
||||
--context Prints changelog context as JSON
|
||||
-h, --help Prints help information
|
||||
-V, --version Prints version information
|
||||
@ -270,11 +270,11 @@ git cliff --sort oldest
|
||||
git cliff --sort newest
|
||||
```
|
||||
|
||||
Sort the tags in chronological order:
|
||||
Sort the tags in topological order:
|
||||
|
||||
```sh
|
||||
# Process in chronological order instead of topological.
|
||||
git cliff --date-order
|
||||
# Process in topological order instead of chronological.
|
||||
git cliff --topo-order
|
||||
```
|
||||
|
||||
Save the changelog file to the specified file:
|
||||
@ -463,7 +463,7 @@ filter_commits = false
|
||||
tag_pattern = "v[0-9]*"
|
||||
skip_tags = "v0.1.0-beta.1"
|
||||
ignore_tags = ""
|
||||
date_order = false
|
||||
topo_order = false
|
||||
sort_commits = "oldest"
|
||||
link_parsers = [
|
||||
{ pattern = "#(\\d+)", href = "https://github.com/orhun/git-cliff/issues/$1"},
|
||||
@ -625,11 +625,11 @@ A regex for ignore processing the matched tags.
|
||||
|
||||
While `skip_tags` drop commits from the changelog, `ignore_tags` include ignored commits into the next tag.
|
||||
|
||||
#### date_order
|
||||
#### topo_order
|
||||
|
||||
If set to `true`, tags are processed in chronological order instead of topological.
|
||||
If set to `true`, tags are processed in topological order instead of chronological.
|
||||
|
||||
This can also be achieved by using the `--date-order` command line flag.
|
||||
This can also be achieved by using the `--topo-order` command line flag.
|
||||
|
||||
#### sort_commits
|
||||
|
||||
|
@ -62,8 +62,8 @@ tag_pattern = "v[0-9]*"
|
||||
skip_tags = "v0.1.0-beta.1"
|
||||
# regex for ignoring tags
|
||||
ignore_tags = ""
|
||||
# sort the tags chronologically
|
||||
date_order = false
|
||||
# sort the tags topologically
|
||||
topo_order = false
|
||||
# sort the commits inside sections by oldest/newest order
|
||||
sort_commits = "oldest"
|
||||
# limit the number of commits included in the changelog.
|
||||
|
@ -67,7 +67,7 @@ tag_pattern = "v[0-9]*"
|
||||
skip_tags = "v0.1.0-beta.1"
|
||||
# regex for ignoring tags
|
||||
ignore_tags = ""
|
||||
# sort the tags chronologically
|
||||
date_order = false
|
||||
# sort the tags topologically
|
||||
topo_order = false
|
||||
# sort the commits inside sections by oldest/newest order
|
||||
sort_commits = "oldest"
|
||||
|
@ -59,7 +59,7 @@ tag_pattern = "v[0-9]*"
|
||||
skip_tags = "v0.1.0-beta.1"
|
||||
# regex for ignoring tags
|
||||
ignore_tags = ""
|
||||
# sort the tags chronologically
|
||||
date_order = false
|
||||
# sort the tags topologically
|
||||
topo_order = false
|
||||
# sort the commits inside sections by oldest/newest order
|
||||
sort_commits = "oldest"
|
||||
|
@ -61,7 +61,7 @@ tag_pattern = "v[0-9]*"
|
||||
skip_tags = "v0.1.0-beta.1"
|
||||
# regex for ignoring tags
|
||||
ignore_tags = ""
|
||||
# sort the tags chronologically
|
||||
date_order = false
|
||||
# sort the tags topologically
|
||||
topo_order = false
|
||||
# sort the commits inside sections by oldest/newest order
|
||||
sort_commits = "oldest"
|
||||
|
@ -73,7 +73,7 @@ tag_pattern = "v[0-9]*"
|
||||
skip_tags = "v0.1.0-beta.1"
|
||||
# regex for ignoring tags
|
||||
ignore_tags = ""
|
||||
# sort the tags chronologically
|
||||
date_order = false
|
||||
# sort the tags topologically
|
||||
topo_order = false
|
||||
# sort the commits inside sections by oldest/newest order
|
||||
sort_commits = "oldest"
|
||||
|
@ -59,7 +59,7 @@ tag_pattern = "v[0-9]*"
|
||||
skip_tags = "v0.1.0-beta.1"
|
||||
# regex for ignoring tags
|
||||
ignore_tags = ""
|
||||
# sort the tags chronologically
|
||||
date_order = false
|
||||
# sort the tags topologically
|
||||
topo_order = false
|
||||
# sort the commits inside sections by oldest/newest order
|
||||
sort_commits = "oldest"
|
||||
|
@ -65,8 +65,8 @@ pub struct GitConfig {
|
||||
#[serde(with = "serde_regex", default)]
|
||||
/// Regex to ignore matched tags.
|
||||
pub ignore_tags: Option<Regex>,
|
||||
/// Whether to sort tags chronologically.
|
||||
pub date_order: Option<bool>,
|
||||
/// Whether to sort tags topologically.
|
||||
pub topo_order: Option<bool>,
|
||||
/// Sorting of the commits inside sections.
|
||||
pub sort_commits: Option<String>,
|
||||
/// Limit the number of commits included in the changelog.
|
||||
|
@ -103,7 +103,7 @@ impl Repository {
|
||||
pub fn tags(
|
||||
&self,
|
||||
pattern: &Option<String>,
|
||||
date_order: bool,
|
||||
topo_order: bool,
|
||||
) -> Result<IndexMap<String, String>> {
|
||||
let mut tags: Vec<(Commit, String)> = Vec::new();
|
||||
let tag_names = self.inner.tag_names(pattern.as_deref())?;
|
||||
@ -121,7 +121,7 @@ impl Repository {
|
||||
}
|
||||
}
|
||||
}
|
||||
if date_order {
|
||||
if !topo_order {
|
||||
tags.sort_by(|a, b| a.0.time().seconds().cmp(&b.0.time().seconds()));
|
||||
}
|
||||
Ok(tags
|
||||
|
@ -77,7 +77,7 @@ fn generate_changelog() -> Result<()> {
|
||||
tag_pattern: None,
|
||||
skip_tags: None,
|
||||
ignore_tags: None,
|
||||
date_order: None,
|
||||
topo_order: None,
|
||||
sort_commits: None,
|
||||
link_parsers: Some(vec![
|
||||
LinkParser {
|
||||
|
@ -106,9 +106,9 @@ pub struct Opt {
|
||||
/// Processes the commits that do not belong to a tag.
|
||||
#[clap(short, long, help_heading = Some("FLAGS"))]
|
||||
pub unreleased: bool,
|
||||
/// Sorts the tags chronologically.
|
||||
#[clap(short, long, help_heading = Some("FLAGS"))]
|
||||
pub date_order: bool,
|
||||
/// Sorts the tags topologically.
|
||||
#[clap(long, help_heading = Some("FLAGS"))]
|
||||
pub topo_order: bool,
|
||||
/// Prints changelog context as JSON.
|
||||
#[clap(long, help_heading = Some("FLAGS"))]
|
||||
pub context: bool,
|
||||
|
@ -262,7 +262,7 @@ mod test {
|
||||
tag_pattern: None,
|
||||
skip_tags: Regex::new("v3.*").ok(),
|
||||
ignore_tags: None,
|
||||
date_order: Some(false),
|
||||
topo_order: Some(false),
|
||||
sort_commits: Some(String::from("oldest")),
|
||||
link_parsers: None,
|
||||
limit_commits: None,
|
||||
|
@ -132,9 +132,9 @@ pub fn run(mut args: Opt) -> Result<()> {
|
||||
.expect("Incorrect config value for 'sort_commits'");
|
||||
}
|
||||
}
|
||||
if !args.date_order {
|
||||
if let Some(date_order) = config.git.date_order {
|
||||
args.date_order = date_order;
|
||||
if !args.topo_order {
|
||||
if let Some(topo_order) = config.git.topo_order {
|
||||
args.topo_order = topo_order;
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ pub fn run(mut args: Opt) -> Result<()> {
|
||||
Repository::init(args.repository.clone().unwrap_or(env::current_dir()?))?;
|
||||
|
||||
// Parse tags.
|
||||
let mut tags = repository.tags(&config.git.tag_pattern, args.date_order)?;
|
||||
let mut tags = repository.tags(&config.git.tag_pattern, args.topo_order)?;
|
||||
|
||||
// Skip tags.
|
||||
config.git.skip_tags = config.git.skip_tags.filter(|r| !r.as_str().is_empty());
|
||||
@ -207,7 +207,7 @@ pub fn run(mut args: Opt) -> Result<()> {
|
||||
None => {
|
||||
return Err(Error::ChangelogError(String::from(
|
||||
"No suitable tags found. Maybe run with \
|
||||
'--date-order'?",
|
||||
'--topo-order'?",
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user