Skip to content

Commit

Permalink
Merge pull request #67 from tyler-jachetta/tjachetta/fix_git_flavor_s…
Browse files Browse the repository at this point in the history
…uccessive_auto_bumps

Fix #68: git flavor autobumps failing to detect previous releases
bump:patch
change: git flavor no longer fails to detect previous bumps
change: successive prerelease bumps for the same release will now increment
  • Loading branch information
tyler-jachetta authored Jan 21, 2021
2 parents 58c7a63 + a5c17dc commit f554dea
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
3 changes: 2 additions & 1 deletion avakas/flavors/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ def __determine_bump(self):
vsn = None
reg = re.compile(r'(\#|bump:|\[)(?P<bump>(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)
Expand Down
18 changes: 18 additions & 0 deletions tests/integration/autobump.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
25 changes: 25 additions & 0 deletions tests/integration/gitnative.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
}

0 comments on commit f554dea

Please sign in to comment.