Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3
Expand All @@ -29,6 +29,7 @@ jobs:
- run: cd ../argunparse && pip install -r requirements_test.txt && python setup.py build && cd -
- run: git clone https://github.com/python-semver/python-semver ../semver
- run: cd ../semver && python -m build && cd -
- run: pip install jupyter # example package that uses metadata.json
- run: python -m coverage run --branch --source . -m unittest -v
- run: python -m coverage run --append --branch --source . -m unittest -v test.test_version
env:
Expand All @@ -45,7 +46,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
architecture: x64
- run: pip install -r requirements_test.txt
- run: python setup.py bdist_wheel sdist
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PYTHON_VERSION="3.10"
ARG PYTHON_VERSION="3.11"

FROM python:${PYTHON_VERSION}

Expand Down Expand Up @@ -71,6 +71,6 @@ RUN set -Eeuxo pipefail && \
cd semver && \
python -m build && \
cd - && \
pip install jupyter
pip install jupyter # example package that uses metadata.json

WORKDIR /home/user/version-query
6 changes: 3 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pipeline {
axes {
axis {
name 'PYTHON_VERSION'
values '3.8', '3.9', '3.10'
values '3.9', '3.10', '3.11'
}
}

Expand All @@ -38,7 +38,7 @@ pipeline {

stage('Lint') {
when {
environment name: 'PYTHON_VERSION', value: '3.10'
environment name: 'PYTHON_VERSION', value: '3.11'
}
steps {
sh """#!/usr/bin/env bash
Expand Down Expand Up @@ -66,7 +66,7 @@ pipeline {

stage('Coverage') {
when {
environment name: 'PYTHON_VERSION', value: '3.10'
environment name: 'PYTHON_VERSION', value: '3.11'
}
steps {
sh '''#!/usr/bin/env bash
Expand Down
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version-query
Copyright (c) 2017-2022 Mateusz Bysiek https://mbdevpl.github.io/
Copyright (c) 2017-2023 Mateusz Bysiek https://mbdevpl.github.io/
Copyright (c) 2020 John Vandenberg https://github.com/jayvdb

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
14 changes: 7 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Examples of valid version tags:
* ``v1.0``
* ``v0.16.0``
* ``v1.0.dev3``
* ``ver0.5.1-4.0.0+a1de3012``
* ``ver0.5.1-4.0.0+gita1de3012``
* ``42.0``
* ``3.14-15``

Expand Down Expand Up @@ -240,8 +240,8 @@ the current commit and the most recent version tag.

Additionally, the ``<patch>`` version component is incremented by ``1``.

Additionally, a plus (``+``) character and the first 8 characters of SHA of the latest commit
are appended to version identifier, e.g. ``+a3014fe0``.
Additionally, a plus (``+``) character, word ``git`` and the first 8 characters of SHA
of the latest commit are appended to version identifier, e.g. ``+gita3014fe0``.


Repository index status
Expand All @@ -256,16 +256,16 @@ of the repository:

* Most recent version tag is ``v0.4.5``, there were 2 commits since,
latest having SHA starting with ``812f12ea``.
Version identifier will be ``0.4.6.dev2+812f12ea``.
Version identifier will be ``0.4.6.dev2+git812f12ea``.

* Most recent version tag is ``ver6.0``, and there was 1 commit since
having SHA starting with ``e10ac365``.
Version identifier will be ``6.0.1.dev1+e10ac365``.
Version identifier will be ``6.0.1.dev1+gite10ac365``.

* Most recent version tag is ``v9``, there were 40 commit since,
latest having SHA starting with ``1ad22355``, the repository has uncommitted changes and
version was queried at 19:52.20, 8th June 2017.
the result is ``9.0.1.dev40+1ad22355.dirty20170608195220``.
the result is ``9.0.1.dev40+git1ad22355.dirty20170608195220``.


How exactly version numbers are compared
Expand Down Expand Up @@ -436,7 +436,7 @@ using version-query without any issues.
Requirements
============

Python version 3.8 or later.
Python version 3.9 or later.

Python libraries as specified in `<requirements.txt>`_.

Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GitPython ~= 3.1
packaging >= 21.0
packaging >= 23.0
semver ~= 2.13
setuptools >= 60.4
setuptools >= 67.4
14 changes: 7 additions & 7 deletions requirements_ci.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
build ~= 0.10
codecov ~= 2.1
coverage ~= 6.2
flake518 ~= 1.2
mypy ~= 0.930
pydocstyle ~= 6.1
pylint ~= 2.12
types-docutils ~= 0.17
types-setuptools ~= 57.4
coverage ~= 7.2
flake518 ~= 1.5
mypy ~= 1.1
pydocstyle ~= 6.3
pylint ~= 2.17
types-docutils ~= 0.19
types-setuptools ~= 67.4
-r requirements_test.txt
10 changes: 5 additions & 5 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
colorlog ~= 6.6
docutils >= 0.18
pip >= 21.0
Pygments >= 2.5
wheel >= 0.37
colorlog ~= 6.7
docutils ~= 0.19
pip >= 23.0
Pygments ~= 2.14
wheel >= 0.40
-r requirements.txt
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class Package(setup_boilerplate.Package):
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3 :: Only',
'Topic :: Software Development :: Version Control',
'Topic :: Software Development :: Version Control :: Git',
Expand Down
26 changes: 13 additions & 13 deletions test/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_no_tags(self):
with self.assertRaises(ValueError):
query_git_repo(self.repo_path)
version = predict_git_repo(self.repo_path)
self.assertEqual(version.to_str(), f'0.1.0.dev{i}+{self.repo_head_hexsha}')
self.assertEqual(version.to_str(), f'0.1.0.dev{i}+git{self.repo_head_hexsha}')

def test_only_nonversion_tags(self):
for i in range(1, 5):
Expand All @@ -44,7 +44,7 @@ def test_only_nonversion_tags(self):
with self.assertRaises(ValueError):
query_git_repo(self.repo_path)
version = predict_git_repo(self.repo_path)
self.assertEqual(version.to_str(), f'0.1.0.dev{i}+{self.repo_head_hexsha}')
self.assertEqual(version.to_str(), f'0.1.0.dev{i}+git{self.repo_head_hexsha}')

def test_inconsistent_tag_prefix(self):
version = Version.from_str('1.0')
Expand All @@ -70,7 +70,7 @@ def test_nonversion_tags(self):
upcoming_version = predict_git_repo(self.repo_path)
version.increment(VersionComponent.Patch, 1)
version.increment(VersionComponent.DevPatch, 2)
version.local = (self.repo_head_hexsha,)
version.local = (f'git{self.repo_head_hexsha}',)
self.assertEqual(version, upcoming_version)

def test_too_long_no_tag(self):
Expand Down Expand Up @@ -103,7 +103,7 @@ def test_nonversion_merged_branches(self):
with self.assertRaises(ValueError):
query_git_repo(self.repo_path)
upcoming_version = predict_git_repo(self.repo_path)
self.assertEqual(upcoming_version.to_str(), f'0.1.0.dev6+{self.repo_head_hexsha}')
self.assertEqual(upcoming_version.to_str(), f'0.1.0.dev6+git{self.repo_head_hexsha}')

def test_invalid_version_tags(self):
for i in range(1, 3):
Expand All @@ -116,7 +116,7 @@ def test_invalid_version_tags(self):
self.assertEqual(current_version.to_str(), f'{i}.0.0')
upcoming_version = predict_git_repo(self.repo_path)
current_version.devel_increment(1)
current_version.local = (self.repo_head_hexsha,)
current_version.local = (f'git{self.repo_head_hexsha}',)
self.assertEqual(current_version, upcoming_version)

def test_dirty_repo(self):
Expand All @@ -133,9 +133,9 @@ def test_dirty_repo(self):
self.assertLess(version, upcoming_version)
if new_commit:
current_version.devel_increment(1)
current_version.local = (self.repo_head_hexsha,)
current_version.local = (f'git{self.repo_head_hexsha}',)
self.assertTupleEqual(current_version.local, upcoming_version.local[:1])
local_prefix = f'+{self.repo_head_hexsha}.dirty'
local_prefix = f'+git{self.repo_head_hexsha}.dirty'
else:
local_prefix = '+dirty'
self.assertTrue(upcoming_version.local_to_str().startswith(local_prefix),
Expand All @@ -157,12 +157,12 @@ def test_nonlatest_commit(self):
current_version = query_git_repo(self.repo_path)
self.assertEqual(current_version.to_str(), '0.1.0')
upcoming_version = predict_git_repo(self.repo_path)
self.assertEqual(upcoming_version.to_str(), f'0.1.1.dev1+{self.repo_head_hexsha}')
self.assertEqual(upcoming_version.to_str(), f'0.1.1.dev1+git{self.repo_head_hexsha}')
self.repo.git.checkout('devel')
current_version = query_git_repo(self.repo_path)
self.assertEqual(current_version.to_str(), '0.2.0')
upcoming_version = predict_git_repo(self.repo_path)
self.assertEqual(upcoming_version.to_str(), f'0.2.1.dev1+{self.repo_head_hexsha}')
self.assertEqual(upcoming_version.to_str(), f'0.2.1.dev1+git{self.repo_head_hexsha}')

def test_tags_on_merged_branches(self):
self.git_commit_new_file()
Expand All @@ -182,7 +182,7 @@ def test_tags_on_merged_branches(self):
current_version = query_git_repo(self.repo_path)
self.assertEqual(current_version.to_str(), '0.2.0')
upcoming_version = predict_git_repo(self.repo_path)
self.assertEqual(upcoming_version.to_str(), f'0.2.1.dev5+{self.repo_head_hexsha}')
self.assertEqual(upcoming_version.to_str(), f'0.2.1.dev5+git{self.repo_head_hexsha}')

def test_tag_on_merged_branch(self):
self.git_commit_new_file()
Expand All @@ -196,7 +196,7 @@ def test_tag_on_merged_branch(self):
current_version = query_git_repo(self.repo_path)
self.assertEqual(current_version.to_str(), '1.0.0')
upcoming_version = predict_git_repo(self.repo_path)
self.assertEqual(upcoming_version.to_str(), f'1.0.1.dev1+{self.repo_head_hexsha}')
self.assertEqual(upcoming_version.to_str(), f'1.0.1.dev1+git{self.repo_head_hexsha}')

def test_many_versions_on_one_commit(self):
self.git_commit_new_file()
Expand All @@ -207,7 +207,7 @@ def test_many_versions_on_one_commit(self):
current_version = query_git_repo(self.repo_path)
self.assertEqual(current_version.to_str(), '0.3.0')
upcoming_version = predict_git_repo(self.repo_path)
self.assertEqual(upcoming_version.to_str(), f'0.3.1.dev1+{self.repo_head_hexsha}')
self.assertEqual(upcoming_version.to_str(), f'0.3.1.dev1+git{self.repo_head_hexsha}')

def test_version_decreased(self):
self.git_commit_new_file()
Expand All @@ -218,4 +218,4 @@ def test_version_decreased(self):
current_version = query_git_repo(self.repo_path)
self.assertEqual(current_version.to_str(), '0.1.0')
upcoming_version = predict_git_repo(self.repo_path)
self.assertEqual(upcoming_version.to_str(), f'0.1.1.dev1+{self.repo_head_hexsha}')
self.assertEqual(upcoming_version.to_str(), f'0.1.1.dev1+git{self.repo_head_hexsha}')
2 changes: 1 addition & 1 deletion version_query/git_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def predict_git_repo(repo_path: pathlib.Path, search_parent_directories: bool =
assert isinstance(version, Version), version
if commit_distance > 0:
version.devel_increment(commit_distance)
version.local = (repo.head.commit.hexsha[:8],)
version.local = (f'git{repo.head.commit.hexsha[:8]}',)
if is_repo_dirty:
dt_ = f'dirty{datetime.datetime.strftime(datetime.datetime.now(), "%Y%m%d%H%M%S")}'
if version.has_local:
Expand Down
2 changes: 1 addition & 1 deletion version_query/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def main(args=None, namespace=None) -> None:
prog='version_query',
description='''Tool for querying current versions of Python packages. Use LOGGING_LEVEL
environment variable to adjust logging level.''',
epilog='''Copyright 2017-2022 by the contributors, Apache License 2.0,
epilog='''Copyright 2017-2023 by the contributors, Apache License 2.0,
https://github.com/mbdevpl/version-query''',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-i', '--increment', action='store_true', help='''output version string for
Expand Down