Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't expected output when pre-release tags with same datetime #139

Closed
hituzi-no-sippo opened this issue Jan 20, 2023 · 3 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@hituzi-no-sippo
Copy link

Describe the bug

The following flags are not producing the expected output when there are pre-release tags with same date.

  • --unreleased
  • --latest
  • --current

I think this issue has a low priority, because this issue is an edge case.
This is because it is rare to encounter a situation where the date and time of the tag are the same.

To Reproduce

I've created a test script.

test script
#!/bin/bash

set -e

rm -rf /tmp/cliff/option_test &&
	mkdir -p "$_" &&
	cd "$_"

git init

git config --local commit.gpgsign false
git config --local tag.gpgsign false

date_now="$(date)"

function commit() {
	tag="v$1"
	git commit --allow-empty -m "chore: $tag"
	GIT_COMMITTER_DATE="$date_now" git tag $tag --message $tag
}

commit '1.0.0'
commit '1.1.0-rc.1'
commit '1.1.0-rc.2'
commit '1.1.0'

echo '====================================='
echo 'git log --oneline'
echo '====================================='
git log --oneline

echo '====================================='
echo 'git tag --sort=-taggerdate'
echo '====================================='
git tag --sort=-taggerdate

echo '====================================='
echo 'git-cliff version'
echo '====================================='
git-cliff --version

git-cliff --init
#
function output_changelog() {
	echo '====================================='
	echo "git-cliff $@"
	echo '====================================='
	git-cliff $@
}

output_changelog
output_changelog --unreleased
output_changelog --latest
output_changelog --current
output
Initialized empty Git repository in /tmp/cliff/option_test/.git/
[main (root-commit) f296b1e] chore: v1.0.0
[main 7d62cf8] chore: v1.1.0-rc.1
[main adc2ee1] chore: v1.1.0-rc.2
[main 5224e82] chore: v1.1.0
=====================================
git log --oneline
=====================================
5224e82 (HEAD -> main, tag: v1.1.0) chore: v1.1.0
adc2ee1 (tag: v1.1.0-rc.2) chore: v1.1.0-rc.2
7d62cf8 (tag: v1.1.0-rc.1) chore: v1.1.0-rc.1
f296b1e (tag: v1.0.0) chore: v1.0.0
=====================================
git tag --sort=-taggerdate
=====================================
v1.0.0
v1.1.0
v1.1.0-rc.1
v1.1.0-rc.2
=====================================
git-cliff version
=====================================
git-cliff 1.1.1
 INFO  git_cliff > Saving the configuration file to "cliff.toml"
=====================================
git-cliff
=====================================
# Changelog

All notable changes to this project will be documented in this file.

## [1.1.0] - 2023-01-20

### Miscellaneous Tasks

- V1.1.0

## [1.1.0-rc.2] - 2023-01-20

### Miscellaneous Tasks

- V1.1.0-rc.2

## [1.1.0-rc.1] - 2023-01-20

### Miscellaneous Tasks

- V1.1.0-rc.1

## [1.0.0] - 2023-01-20

### Miscellaneous Tasks

- V1.0.0

<!-- generated by git-cliff -->
=====================================
git-cliff --unreleased
=====================================
# Changelog

All notable changes to this project will be documented in this file.

## [1.1.0] - 2023-01-20

### Miscellaneous Tasks

- V1.1.0

<!-- generated by git-cliff -->
=====================================
git-cliff --latest
=====================================
# Changelog

All notable changes to this project will be documented in this file.

## [1.1.0-rc.2] - 2023-01-20

### Miscellaneous Tasks

- V1.1.0-rc.2

<!-- generated by git-cliff -->
=====================================
git-cliff --current
=====================================
# Changelog

All notable changes to this project will be documented in this file.

## [1.1.0] - 2023-01-20

### Miscellaneous Tasks

- V1.1.0

## [1.1.0-rc.2] - 2023-01-20

### Miscellaneous Tasks

- V1.1.0-rc.2

## [1.1.0-rc.1] - 2023-01-20

### Miscellaneous Tasks

- V1.1.0-rc.1

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

Unreleased

git-cliff --unreleased

# Changelog

All notable changes to this project will be documented in this file.

## [1.1.0] - 2023-01-20

### Miscellaneous Tasks

- V1.1.0

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

Latest

git-cliff --latest

# Changelog

All notable changes to this project will be documented in this file.

## [1.1.0-rc.2] - 2023-01-20

### Miscellaneous Tasks

- V1.1.0-rc.2

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

Current

git-cliff --current

# Changelog

All notable changes to this project will be documented in this file.

## [1.1.0] - 2023-01-20

### Miscellaneous Tasks

- V1.1.0

## [1.1.0-rc.2] - 2023-01-20

### Miscellaneous Tasks

- V1.1.0-rc.2

## [1.1.0-rc.1] - 2023-01-20

### Miscellaneous Tasks

- V1.1.0-rc.1

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

Expected behavior

Unreleased

git-cliff --unreleased

# Changelog

All notable changes to this project will be documented in this file.

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

Latest

git-cliff --latest

# Changelog

All notable changes to this project will be documented in this file.

## [1.1.0] - 2023-01-20

### Miscellaneous Tasks

- V1.1.0

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

Current

git-cliff --current

# Changelog

All notable changes to this project will be documented in this file.

## [1.1.0] - 2023-01-20

### Miscellaneous Tasks

- V1.1.0

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

System (please complete the following information):

  • OS Ubuntu 20.04 LTS (WSL2)
  • Project Version: v1.1.1

Additional context

Thank you.

@hituzi-no-sippo hituzi-no-sippo added the bug Something isn't working label Jan 20, 2023
@hituzi-no-sippo hituzi-no-sippo changed the title Doesn't expected output when Pre-release tags with same datetime. Doesn't expected output when pre-release tags with same datetime Jan 20, 2023
@orhun
Copy link
Owner

orhun commented Jan 20, 2023

Thanks for the detailed issue! 🐻 Loved your repro script!

This is indeed an edge case but 4df5656 should fix this.

orhun added a commit that referenced this issue Jan 20, 2023
@orhun
Copy link
Owner

orhun commented Jan 20, 2023

Hmm, it looks like 4df5656 was a breaking change: https://github.com/orhun/git-cliff/actions/runs/3967220267/jobs/6798926881

I will revert this for now. I think it's better to have precise timestamp comparison rather than unforeseen commit order behavior.

@hituzi-no-sippo
Copy link
Author

Thank you for your response.

I will revert this for now. I think it's better to have precise timestamp comparison rather than unforeseen commit order behavior.

I agree with your thoughts.

It is your decision whether or not to close this issue.

@orhun orhun closed this as completed Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants