Skip to content

Commit

Permalink
🐛 [-bugs] Addressed multiple bugs (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrownell authored Mar 9, 2024
2 parents 42508b6 + 11c4191 commit aee9d17
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
15 changes: 10 additions & 5 deletions src/AutoGitSemVer/Lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def GetBranchName() -> str:
build=None if no_metadata else tuple(metadata),
)

semver_string = f"{configuration.version_prefix}{semver}"
semver_string = f"{configuration.version_prefix or ''}{semver}"

calculate_dm.WriteLine(semver_string)

Expand Down Expand Up @@ -614,10 +614,15 @@ def EnumCommits(
for tag in repo.tags:
# Tags are most often associated with merges into a mainline branch, but we are filtering merges
# out in the code below. Therefore, associate the tag with a parent that isn't a merge commit.
for parent in tag.commit.parents:
if len(parent.parents) == 1:
git_tags.setdefault(parent.hexsha, []).append(tag)
break
if len(tag.commit.parents) == 1:
# We are looking at a direct commit to the branch
git_tags.setdefault(tag.commit.hexsha, []).append(tag)
else:
# We are looking at a merge
for parent in tag.commit.parents:
if len(parent.parents) == 1:
git_tags.setdefault(parent.hexsha, []).append(tag)
break

offset = 0

Expand Down
2 changes: 1 addition & 1 deletion src/AutoGitSemVer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# pylint: disable=missing-module-docstring,invalid-name

# ----------------------------------------------------------------------
# Note that this value will be overwritten by calls to `python ../../Build.py UpdateVersion` based
# Note that this value will be overwritten by calls to `python ../../Build.py update_version` based
# on changes observed in the git repository. The default value below will be used until the value
# here is explicitly updated as part of a commit.
__version__ = "0.1.0"
Expand Down
4 changes: 2 additions & 2 deletions src/ConfigurationSchema/AutoGitSemVerSchema.SimpleSchema
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
# | |-- <Semantic versions based on changes to any files in this directory or its descendants
# | | will be controlled by this AutoGitSemVer.json file>
# |-- Directory2
# | |-- AutoGitSemVer.json
# | |-- AutoGitSemVer.yaml
# | |-- <Semantic versions based on changes to any files in this directory or its descendants
# | | will be controlled by this AutoGitSemVer.json file>
# | | will be controlled by this AutoGitSemVer.yaml file>
# |-- <Changes in this directory will not impact either semantic version>
#

Expand Down
19 changes: 19 additions & 0 deletions tests/Lib_UnitTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,25 @@ def CustomCommitDeltaExtractor(
) # prerelease is wiped when a new version is encountered
assert semver.semantic_version.build and "bumped_patch" in semver.semantic_version.build

# ----------------------------------------------------------------------
def test_String(self):
result, semver = _GetSemanticVersionImpl([])

assert result == 0
assert semver.semantic_version.major == 0
assert semver.semantic_version.minor == 1
assert semver.semantic_version.patch == 0
assert semver.semantic_version_string != "0.1.0"

result, semver = _GetSemanticVersionImpl(
[],
include_branch_name_when_necessary=False,
include_timestamp_when_necessary=False,
include_computer_name_when_necessary=False,
no_metadata=True,
)
assert semver.semantic_version_string == "0.1.0"


# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
Expand Down

0 comments on commit aee9d17

Please sign in to comment.