Skip to content

Commit

Permalink
Merge pull request #44 from RightBrain-Networks/bugfix/currentVersion
Browse files Browse the repository at this point in the history
Sort by ref not date
  • Loading branch information
yeslayla authored Feb 28, 2020
2 parents fa143a3 + 33d8615 commit ab94376
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion semver/get_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_tag_version():
version = get_file_version(config)

# If a version is found in tags, use that the lastest tagged version
tagged_versions = subprocess.Popen(['git','tag','--sort=taggerdate', '-l',tag_expression],
tagged_versions = subprocess.Popen(['git','tag','--sort=v:refname', '-l',tag_expression],
stdout=subprocess.PIPE, stderr=DEVNULL, cwd=".").stdout.read().decode('utf-8').rstrip().split('\n')
if len(tagged_versions) > 0 and tagged_versions[-1] != "":
version = tagged_versions[-1]
Expand Down
29 changes: 29 additions & 0 deletions semver/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,35 @@ def test_get_version_tag(self):
subprocess.call(['git', 'tag', '1.0.0'])
tag = get_version.get_tag_version()
self.assertEqual(tag, "1.0.0")
def test_get_version_multiple(self):
create_git_environment()
subprocess.call(['git', 'tag', '0.1.0'])
subprocess.call(['git', 'tag', '0.1.1'])
subprocess.call(['git', 'tag', '0.1.2'])
subprocess.call(['git', 'tag', '0.1.3'])
subprocess.call(['git', 'tag', '0.2.0'])
subprocess.call(['git', 'tag', '0.3.0'])
subprocess.call(['git', 'tag', '0.3.1'])
subprocess.call(['git', 'tag', '1.0.0'])
subprocess.call(['git', 'tag', '1.1.0'])
subprocess.call(['git', 'tag', '1.2.0'])
subprocess.call(['git', 'tag', '1.2.1'])
tag = get_version.get_tag_version()
self.assertEqual(tag, "1.2.1")
def test_get_version_out_of_order(self):
subprocess.call(['git', 'tag', '0.1.0'])
subprocess.call(['git', 'tag', '0.1.1'])
subprocess.call(['git', 'tag', '0.5.2'])
subprocess.call(['git', 'tag', '0.1.3'])
subprocess.call(['git', 'tag', '8.1.0'])
subprocess.call(['git', 'tag', '0.3.8'])
subprocess.call(['git', 'tag', '3.3.1'])
subprocess.call(['git', 'tag', '1.4.0'])
subprocess.call(['git', 'tag', '1.1.7'])
subprocess.call(['git', 'tag', '1.2.0'])
subprocess.call(['git', 'tag', '0.2.1'])
tag = get_version.get_tag_version()
self.assertEqual(tag, "8.1.0")
def test_default_get_version_tag(self):
create_git_environment()
tag = get_version.get_tag_version()
Expand Down

0 comments on commit ab94376

Please sign in to comment.