From 0232c610477a976f0fad41f04986db5ddaeb0312 Mon Sep 17 00:00:00 2001 From: Tyler Jachetta Date: Thu, 14 Jan 2021 23:15:43 -0500 Subject: [PATCH 1/3] Testing: Added one successful (the single bump) and one failing (the multiple bumps with one commit) case --- tests/integration/gitnative.bats | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/integration/gitnative.bats b/tests/integration/gitnative.bats index 724a284..1cf7f21 100644 --- a/tests/integration/gitnative.bats +++ b/tests/integration/gitnative.bats @@ -36,3 +36,28 @@ teardown() { scan_lines "0.0.2" "${lines[@]}" [ -e "$REPO/version" ] } + +@test "autobump git-native version once" { + cd $REPO + commit_message "$REPO" "you're probably not gonna read this anyway\nbump:patch" + avakas_wrapper bump "$REPO" auto --flavor "git-native" + avakas_wrapper show "$REPO" + [ "$output" == "0.0.2" ] +} + +@test "autobump git-native versions multiple times" { + cd $REPO + commit_message "$REPO" "whorp\nbump:patch" + avakas_wrapper bump "$REPO" auto --flavor "git-native" + avakas_wrapper show "$REPO" + [ "$output" == "0.0.2" ] + avakas_wrapper bump "$REPO" auto --flavor "git-native" + avakas_wrapper show "$REPO" + [ "$output" == "0.0.2" ] + avakas_wrapper bump "$REPO" auto --flavor "git-native" + avakas_wrapper show "$REPO" + [ "$output" == "0.0.2" ] + avakas_wrapper bump "$REPO" auto --flavor "git-native" + avakas_wrapper show "$REPO" + [ "$output" == "0.0.2" ] +} From 9854251baf9211128cb18bf61c4d33e54e6cb905 Mon Sep 17 00:00:00 2001 From: Tyler Jachetta Date: Fri, 15 Jan 2021 15:31:02 -0500 Subject: [PATCH 2/3] Testing: added successful test in autobump tests this exposes that issue #68 is not a bug universally in auto bumping, but exists either in the git flavor specifically or some subset of flavors --- tests/integration/autobump.bats | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/integration/autobump.bats b/tests/integration/autobump.bats index de39be3..aed8722 100644 --- a/tests/integration/autobump.bats +++ b/tests/integration/autobump.bats @@ -230,6 +230,24 @@ teardown() { avakas_wrapper show "$REPO" [ "$output" == "1.1.0" ] } + +@test "autobump multiple times with one commit" { + cd $REPO + commit_message "$REPO" "whorp\nbump:patch" + avakas_wrapper bump "$REPO" auto + avakas_wrapper show "$REPO" + [ "$output" == "0.0.2" ] + avakas_wrapper bump "$REPO" auto + avakas_wrapper show "$REPO" + [ "$output" == "0.0.2" ] + avakas_wrapper bump "$REPO" auto + avakas_wrapper show "$REPO" + [ "$output" == "0.0.2" ] + avakas_wrapper bump "$REPO" auto + avakas_wrapper show "$REPO" + [ "$output" == "0.0.2" ] +} + @test "autobump with no commit" { local rev=$(git rev-parse --verify HEAD | cut -c 1-7) avakas_wrapper show "$REPO" From 2aa9c54398c3dcc5fd56aea3ea37a62fc0d1aecd Mon Sep 17 00:00:00 2001 From: Tyler Jachetta Date: Sat, 16 Jan 2021 02:00:48 -0500 Subject: [PATCH 3/3] Git flavor: made autobump detect tags --- avakas/flavors/git.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/avakas/flavors/git.py b/avakas/flavors/git.py index fabb228..2f2c3a6 100644 --- a/avakas/flavors/git.py +++ b/avakas/flavors/git.py @@ -68,9 +68,10 @@ def __determine_bump(self): vsn = None reg = re.compile(r'(\#|bump:|\[)(?P(patch|minor|major))(.*|\])', re.MULTILINE) + tagged_commits = set(tag.commit for tag in self.repo.tags) for commit in self.repo.iter_commits(self.options['branch']): # we go iterate back to the last time we bumped the version - if commit.message.startswith('Version bumped to'): + if commit in tagged_commits: break res = reg.search(commit.message)