Skip to content

Commit

Permalink
fix: regex matching wrong version substring (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamtabrams authored Mar 11, 2022
1 parent 950bb0a commit a2a9701
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 2 deletions.
4 changes: 2 additions & 2 deletions change
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ get_needed_tags() {

tags=$(get_git_tags -v)

! echo "$tags" | grep -q "$latest_log_tag" && return 0
echo "$tags" | sed -n "/$latest_log_tag/!p;//q" | sed '1!G;h;$!d'
! echo "$tags" | grep -q "^${latest_log_tag}$" && return 0
echo "$tags" | sed -n "/^${latest_log_tag}$/!p;//q" | sed '1!G;h;$!d'

latest_changes=$(git log --pretty=format:"%B" "$latest_git_tag..")
[ ! "$latest_changes" ] && return
Expand Down
27 changes: 27 additions & 0 deletions tests/change-submatch/setup/CHANGELOG-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.0.10] - ~~SUB-DATE~~
### Changed
- Fix add fourth file.

## [0.0.2] - ~~SUB-DATE~~
### Fixed
- Add third file.

## [0.0.1] - 2021-01-19
### Added
- Add first file.

### Fixed
- Add second file.

[Unreleased]: https://github.com/adamtabrams/change/compare/0.0.10...HEAD
[0.0.10]: https://github.com/adamtabrams/change/compare/0.0.2...0.0.10
[0.0.2]: https://github.com/adamtabrams/change/compare/0.0.1...0.0.2
[0.0.1]: https://github.com/adamtabrams/change/releases/tag/0.0.1
17 changes: 17 additions & 0 deletions tests/change-submatch/setup/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.0.1] - 2021-01-19
### Added
- Add first file.

### Fixed
- Add second file.

[Unreleased]: https://github.com/adamtabrams/change/compare/0.0.1...HEAD
[0.0.1]: https://github.com/adamtabrams/change/releases/tag/0.0.1
Empty file.
2 changes: 2 additions & 0 deletions tests/change-submatch/setup/exp-stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
added 0.0.2 to CHANGELOG.md
added 0.0.10 to CHANGELOG.md
9 changes: 9 additions & 0 deletions tests/change-submatch/setup/results
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

. ../../.test-resources.sh

compare_stdout
compare_stderr

gen_changelog_exp
compare_changelog
23 changes: 23 additions & 0 deletions tests/change-submatch/setup/run-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

git init --quiet

git add run-test
git commit --quiet -am "feat: add first file"
git add results
git commit --quiet -am "fix: add second file"
git tag 0.0.1

git add exp-stderr
git commit --quiet -am "fix: add third file"
git tag 0.0.2

git add exp-stdout
git commit --quiet -am "Fix add fourth file"
git tag 0.0.10

git remote add origin https://github.com/adamtabrams/change.git

change >act-stdout 2>act-stderr

rm -rf ./.git

0 comments on commit a2a9701

Please sign in to comment.