absolute-version / commit-and-tag-version

Fork of the excellent standard-version. Automate versioning and CHANGELOG generation, with semver.org and conventionalcommits.org :trophy:
ISC License
358 stars 33 forks source link

Why commits got repeated when I format the CHANGELOG file manually? #133

Open JonathanLoscalzo opened 3 months ago

JonathanLoscalzo commented 3 months ago

I have wanted to edit the changelog manually, because I have a lot of all commits in the history that I don't want to preserve in the changelog. During the edition, accidentally I have format the file with vscode and some blank spaces got removed.

When I bump the version again, the selected commits are not from "v0.0.X..v.0.0.Y", it selects it from the first commit again.

So, I assumed that if we modify the format of the changelog for whatever reason, it will fail. Is there any possibility to pass two properties? like the range of commits to generate instead of read the changelog.

There are situation where we want to switch from a changelog generator to another, and I want to preserve all history. I mean, it could be possible to skip that check and just use last two "v-tags"?

TimothyJones commented 3 months ago

This shouldn’t happen - are you sure the tags are visible when you’re running the tool? It sounds more like missing tags than a problem with editing the changelog

JonathanLoscalzo commented 3 months ago

Let me create a template example with my project

JonathanLoscalzo commented 3 months ago

Check the script... when I have formatted it with prettier, in the following bump it duplicates the entries.

npm init --yes
git init
echo "node_modules" > .gitignore
git add . 
git commit -m "feat: init"

for i in {1..5}; do
  git commit -m "feat($i): important feature $i" --allow-empty
done

for i in {1..5}; do
  git commit -m "fix($i): important feature $i" --allow-empty
done

npx --yes commit-and-tag-version --first-release

# modify the changelog JUST THE FORMAT
echo "{}" > .prettierrc
npx --yes prettier CHANGELOG.md --write
git add CHANGELOG.md 
git commit --amend --no-edit

# Create a commit between v1 and v2
git commit -m "feat(v2): important feature v2" --allow-empty

# If I release it, the unique commit that will be added to the changelog is the last one
npx commit-and-tag-version 

# CHECK CHANGELOG!
JonathanLoscalzo commented 3 months ago

If you comment the prettier part, it works. So the problem is in the md formatting. :cry:

JonathanLoscalzo commented 3 months ago

Any thoughts @TimothyJones ?