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

Context is incorrect when using --unreleased and --tag #457

Closed
lukehsiao opened this issue Jan 20, 2024 · 4 comments
Closed

Context is incorrect when using --unreleased and --tag #457

lukehsiao opened this issue Jan 20, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@lukehsiao
Copy link

Describe the bug

A common workflow is to run git-cliff --unreleased --tag {new version}. However, git-cliff appears to corrupt the value of previous.version in the context when --tag is provided.

To reproduce

I have a git repo which looks like this:

* 15f5037f5bac - (HEAD -> main, origin/main, origin/HEAD) build: remove extra `v` from version links (4 hours ago) <Luke Hsiao>
* f601cb051642 - (tag: v0.1.9) chore(release): bump version to v0.1.9 (2 days ago) <Luke Hsiao>

Note that without --tag, the previous.version is correctly v0.1.9:

❯ git-cliff --unreleased --context | jaq .
[
  {
    "version": null,
    "commits": [
      {
        "id": "15f5037f5bacb914b41514b33af4abc409515a2e",
        "message": "remove extra `v` from version links",
        "body": null,
        "footers": [],
        "group": "Build and Dependencies",
        "breaking_description": null,
        "breaking": false,
        "scope": null,
        "links": [],
        "author": {
          "name": "Luke Hsiao",
          "email": "[email protected]",
          "timestamp": 1705710146
        },
        "committer": {
          "name": "Luke Hsiao",
          "email": "[email protected]",
          "timestamp": 1705710146
        },
        "conventional": true
      }
    ],
    "commit_id": null,
    "timestamp": 0,
    "previous": {
      "version": "v0.1.9",
      "commits": [],
      "commit_id": "f601cb0516424b8efa0a8abcb94bb070fee152e4",
      "timestamp": 0,
      "previous": null
    }
  }
]

However, with --tag, it overwrites to a different value

❯ git-cliff --unreleased --tag v0.2.0 --context | jaq .
[
  {
    "version": "v0.2.0",
    "commits": [
      {
        "id": "15f5037f5bacb914b41514b33af4abc409515a2e",
        "message": "remove extra `v` from version links",
        "body": null,
        "footers": [],
        "group": "Build and Dependencies",
        "breaking_description": null,
        "breaking": false,
        "scope": null,
        "links": [],
        "author": {
          "name": "Luke Hsiao",
          "email": "[email protected]",
          "timestamp": 1705710146
        },
        "committer": {
          "name": "Luke Hsiao",
          "email": "[email protected]",
          "timestamp": 1705710146
        },
        "conventional": true
      }
    ],
    "commit_id": "15f5037f5bacb914b41514b33af4abc409515a2e",
    "timestamp": 1705723398,
    "previous": {
      "version": "v0.2.0",  <--- THIS
      "commits": [],
      "commit_id": "15f5037f5bacb914b41514b33af4abc409515a2e",
      "timestamp": 0,
      "previous": null
    }
  }
]

Software information

@lukehsiao lukehsiao added the bug Something isn't working label Jan 20, 2024
Copy link

welcome bot commented Jan 20, 2024

Thanks for opening your first issue at git-cliff! Be sure to follow the issue template! ⛰️

@lukehsiao
Copy link
Author

❯ git-cliff --context --unreleased --bump | jaq .
[
  {
    "version": "0.1.10",
    "commits": [
      {
        "id": "15f5037f5bacb914b41514b33af4abc409515a2e",
        "message": "remove extra `v` from version links",
        "body": null,
        "footers": [],
        "group": "Build and Dependencies",
        "breaking_description": null,
        "breaking": false,
        "scope": null,
        "links": [],
        "author": {
          "name": "Luke Hsiao",
          "email": "[email protected]",
          "timestamp": 1705710146
        },
        "committer": {
          "name": "Luke Hsiao",
          "email": "[email protected]",
          "timestamp": 1705710146
        },
        "conventional": true
      }
    ],
    "commit_id": null,
    "timestamp": 1705723747,
    "previous": {
      "version": "v0.1.9",
      "commits": [],
      "commit_id": "f601cb0516424b8efa0a8abcb94bb070fee152e4",
      "timestamp": 0,
      "previous": null
    }
  }
]

Note that --bump is closer to the behavior I want. It gets the right previous version. But, unfortunately, my versions are prefixed with v, so I can't use --bump directly or else my template needs to be different (include a v) for if I call git-cliff with --bump or not.

@lukehsiao
Copy link
Author

Another note, this appears to be fixed in main, so perhaps all we need is a new release?

On main

❯ ../../orhun/git-cliff/target/release/git-cliff --unreleased --tag v0.2.2 --context | jaq .
[
  {
    "version": "v0.2.2",
    "commits": [
      {
        "id": "8c2e2fefad43615db0da2a049abde8e8f5de504f",
        "message": "fix links to previous tags",
        "body": null,
        "footers": [],
        "group": "Documentation",
        "breaking_description": null,
        "breaking": false,
        "scope": "CHANGELOG",
        "links": [],
        "author": {
          "name": "Luke Hsiao",
          "email": "[email protected]",
          "timestamp": 1705724688
        },
        "committer": {
          "name": "Luke Hsiao",
          "email": "[email protected]",
          "timestamp": 1705724688
        },
        "conventional": true,
        "merge_commit": false,
        "github": {
          "username": null,
          "pr_title": null,
          "pr_number": null,
          "is_first_time": false
        }
      }
    ],
    "commit_id": "8c2e2fefad43615db0da2a049abde8e8f5de504f",
    "timestamp": 1705724796,
    "previous": {
      "version": "v0.2.1",
      "commits": [],
      "commit_id": "85d660b70fa544d80748328ab474add534973b3c",
      "timestamp": 1705722487,
      "previous": null,
      "github": {
        "contributors": []
      }
    },
    "github": {
      "contributors": []
    }
  }
]

On v1.4.0

❯ ../../orhun/git-cliff/target/release/git-cliff --unreleased --tag v0.2.2 --context | jaq .
[
  {
    "version": "v0.2.2",
    "commits": [
      {
        "id": "8c2e2fefad43615db0da2a049abde8e8f5de504f",
        "message": "fix links to previous tags",
        "body": null,
        "footers": [],
        "group": "Documentation",
        "breaking_description": null,
        "breaking": false,
        "scope": "CHANGELOG",
        "links": [],
        "author": {
          "name": "Luke Hsiao",
          "email": "[email protected]",
          "timestamp": 1705724688
        },
        "committer": {
          "name": "Luke Hsiao",
          "email": "[email protected]",
          "timestamp": 1705724688
        },
        "conventional": true
      }
    ],
    "commit_id": "8c2e2fefad43615db0da2a049abde8e8f5de504f",
    "timestamp": 1705724719,
    "previous": {
      "version": "v0.2.2",
      "commits": [],
      "commit_id": "8c2e2fefad43615db0da2a049abde8e8f5de504f",
      "timestamp": 0,
      "previous": null
    }
  }
]

@orhun
Copy link
Owner

orhun commented Jan 20, 2024

Yes, it should be fixed on main. I will create a new release soon!

Thanks for reporting 🐻

@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