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

Previous not populated when using --latest #3

Closed
PurpleBooth opened this issue Aug 14, 2021 · 2 comments
Closed

Previous not populated when using --latest #3

PurpleBooth opened this issue Aug 14, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@PurpleBooth
Copy link

PurpleBooth commented Aug 14, 2021

Describe the bug

When using "latest" previous is not set.

To Reproduce
Steps to reproduce the behavior:

Notes: experienced on PurpleBooth/git-mit, it has the config as defined below.

[changelog]
header = """## Changelog
"""
body = """
{% if version %}\
    {% if previous %}\
        ### [{{ version }}](https://github.com/PurpleBooth/git-mit/compare/{{ previous.version }}...{{ version }}) ({{ timestamp | date(format="%Y-%m-%d") }})
    {% else %}\
        ### [{{ version }}](https://github.com/PurpleBooth/git-mit/tree/{{ version }}) ({{ timestamp | date(format="%Y-%m-%d") }})
    {% endif %}\
{% else %}\
    ### [unreleased]
{% endif %}\
{% if previous %}\
    {% if previous.commit_id %}
        [{{ previous.commit_id | truncate(length=7, end="") }}]({{ previous.commit_id }})...\
            [{{ commit_id | truncate(length=7, end="") }}]({{ commit_id }})
    {% endif %}\
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
    ### {{ group | upper_first }}
    {% for commit in commits %}
        - {{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}]({{ commit.id }}))\
    {% endfor %}
{% endfor %}\n
"""
trim = true

[git]
conventional_commits = true
tag_pattern = "v[0-9]*"

Expected behavior
A clear and concise description of what you expected to happen.

I would expect previous to always be set, so we can correctly generate compare URLs for Github.

Screenshots/Logs

$ git-cliff | head
## Changelog
### [unreleased]

### Fix

- Update the changelog ([70bd7ff](70bd7ffe55857940e898f5b97b34b2f62acd1c8e))

### [v4.0.14](https://github.com/PurpleBooth/git-mit/compare/v4.0.13...v4.0.14) (2021-08-14)

[88ef7ec](88ef7ecd813d32f19804421acf3daa3e396d48e2)...[fb1afd9](fb1afd98c2c290fee748c89fde064667f49b8cda)
$ git-cliff --latest | head
## Changelog
### [v4.0.14](https://github.com/PurpleBooth/git-mit/compare/...v4.0.14) (2021-08-14)

### Build

- Versio update versions ([fb1afd9](fb1afd98c2c290fee748c89fde064667f49b8cda))

### Chore

- Update FUNDING.yml ([651ef61](651ef61ed10923c6e451bd63dae4b038c845ad2e))

System (please complete the following information):

  • OS Information: [e.g. Arch GNU/Linux x86_64 5.4.8-arch1-1]
  • Project Version: [e.g. 0.1.0]
$ sw_vers
ProductName:    macOS
ProductVersion: 11.5.1
BuildVersion:   20G80
$ git-cliff --version
git-cliff 0.1.0

Additional context
Add any other context about the problem here.

@PurpleBooth PurpleBooth added the bug Something isn't working label Aug 14, 2021
@orhun
Copy link
Owner

orhun commented Aug 14, 2021

The --latest flag basically takes the last 2 tags into account for determining a range to process the commits.

e.g. running git cliff --latest is like running the following in your git repository:

$ git log --oneline fb1afd9..05361bc

05361bc (HEAD -> main, tag: versio-prev, tag: v4.0.15, origin/main, origin/HEAD) build(deploy): Versio update versions
70bd7ff fix: Update the changelog

(P.S. you can also specify a commit range for changelog generation: git cliff fb1afd9..05361bc)

So git-cliff does not have any idea about the previous release (commits), it only knows what was the previous tag name (v4.0.14) and the commit (fb1afd9).

29db41a will now set the previous release data (only the tag name and commit) thus solve your issue.

$ cargo run -- --latest --workspace ~/gh/git-mit/

## Changelog
### [v4.0.15](https://github.com/PurpleBooth/git-mit/compare/v4.0.14...v4.0.15) (2021-08-14)

[fb1afd9](fb1afd98c2c290fee748c89fde064667f49b8cda)...[05361bc](05361bc6e5512477c838542aee17c1c585750144)

### Build

- Versio update versions ([05361bc](05361bc6e5512477c838542aee17c1c585750144))

### Fix

- Update the changelog ([70bd7ff](70bd7ffe55857940e898f5b97b34b2f62acd1c8e))

@PurpleBooth
Copy link
Author

That's exactly what I needed, thank you!

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