From a2a9701e556c68e0c89841dad178e5ea36916f04 Mon Sep 17 00:00:00 2001 From: Adam Abrams Date: Fri, 11 Mar 2022 12:28:39 -0600 Subject: [PATCH] fix: regex matching wrong version substring (#20) --- change | 4 +-- .../setup/CHANGELOG-template.md | 27 +++++++++++++++++++ tests/change-submatch/setup/CHANGELOG.md | 17 ++++++++++++ tests/change-submatch/setup/exp-stderr | 0 tests/change-submatch/setup/exp-stdout | 2 ++ tests/change-submatch/setup/results | 9 +++++++ tests/change-submatch/setup/run-test | 23 ++++++++++++++++ 7 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 tests/change-submatch/setup/CHANGELOG-template.md create mode 100644 tests/change-submatch/setup/CHANGELOG.md create mode 100644 tests/change-submatch/setup/exp-stderr create mode 100644 tests/change-submatch/setup/exp-stdout create mode 100755 tests/change-submatch/setup/results create mode 100755 tests/change-submatch/setup/run-test diff --git a/change b/change index 65087ee..9bcc369 100755 --- a/change +++ b/change @@ -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 diff --git a/tests/change-submatch/setup/CHANGELOG-template.md b/tests/change-submatch/setup/CHANGELOG-template.md new file mode 100644 index 0000000..5f1c85e --- /dev/null +++ b/tests/change-submatch/setup/CHANGELOG-template.md @@ -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 diff --git a/tests/change-submatch/setup/CHANGELOG.md b/tests/change-submatch/setup/CHANGELOG.md new file mode 100644 index 0000000..95d9aa3 --- /dev/null +++ b/tests/change-submatch/setup/CHANGELOG.md @@ -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 diff --git a/tests/change-submatch/setup/exp-stderr b/tests/change-submatch/setup/exp-stderr new file mode 100644 index 0000000..e69de29 diff --git a/tests/change-submatch/setup/exp-stdout b/tests/change-submatch/setup/exp-stdout new file mode 100644 index 0000000..b391421 --- /dev/null +++ b/tests/change-submatch/setup/exp-stdout @@ -0,0 +1,2 @@ +added 0.0.2 to CHANGELOG.md +added 0.0.10 to CHANGELOG.md diff --git a/tests/change-submatch/setup/results b/tests/change-submatch/setup/results new file mode 100755 index 0000000..6c93623 --- /dev/null +++ b/tests/change-submatch/setup/results @@ -0,0 +1,9 @@ +#!/bin/sh + +. ../../.test-resources.sh + +compare_stdout +compare_stderr + +gen_changelog_exp +compare_changelog diff --git a/tests/change-submatch/setup/run-test b/tests/change-submatch/setup/run-test new file mode 100755 index 0000000..8376f80 --- /dev/null +++ b/tests/change-submatch/setup/run-test @@ -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