Skip to content

Previous not populated when using --latest #3

@PurpleBooth

Description

@PurpleBooth

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions