Skip to content

Commit

Permalink
Merge d57458b into e5e7c20
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Dec 8, 2020
2 parents e5e7c20 + d57458b commit 970ad1e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ jobs:
matrix:
python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9"]
steps:
- uses: "actions/checkout@v2"
- uses: actions/checkout@v2
with:
# some tests work on the git history so we need all of it!
fetch-depth: 0
- uses: "actions/setup-python@v2"
- uses: actions/setup-python@v2
with:
python-version: "${{ matrix.python-version }}"
- name: "Install dependencies"
- name: Install tox
run: python -m pip install tox tox-gh-actions
- name: "Run tox targets for ${{ matrix.python-version }}"
- name: Run tox
run: python -m tox
- name: Coveralls
if: matrix.python-version != 2.7
Expand All @@ -42,13 +42,13 @@ jobs:
- tests
if: startsWith(github.ref, 'refs/tags')
steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Install pypa/build
run: python -m pip install build
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/
- name: Publish distribution 📦 to Test PyPI
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Changes
.. ----------
.. -
2.7.0 (unreleased)
------------------
- [UPD] update base addons lists
- [ADD] add new ``.N`` git post version strategy that adds a 6th digit with the
number of commit since the latest manifest version change

2.6.0 (2020-10-21)
------------------

Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ N being the number of git commits since the version change.
``[8|9|10|11|12].0.x.y.z.99.devN``.
- Strategy ``+1.devN`` is the default for series 13 and 14 and yields
``[13|14].0.x.y.z+1.devN``.
- Strategy ``.N`` adds a digit, typically yielding ``[series].0.x.y.z.N``.
- Strategy ``none`` is not used by default and disables the post
versioning mechanism, yielding the version found in the manifest.

Expand Down
4 changes: 4 additions & 0 deletions setuptools_odoo/git_postversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
STRATEGY_NONE = "none"
STRATEGY_99_DEVN = ".99.devN"
STRATEGY_P1_DEVN = "+1.devN"
STRATEGY_DOT_N = ".N"


def _run_git_command_exit_code(args, cwd=None, stderr=None):
Expand Down Expand Up @@ -100,6 +101,7 @@ def get_git_postversion(addon_dir, strategy):
* STRATEGY_NONE: return the version in the manifest as is
* STRATEGY_99_DEVN: [8|9].0.x.y.z.99.devN
* STRATEGY_P1_DEVN: [series].0.x.y.(z+1).devN
* STRATEGY_DOT_N: [series].0.x.y.z.N
Notes:
Expand Down Expand Up @@ -144,6 +146,8 @@ def get_git_postversion(addon_dir, strategy):
return last_version + ".99.dev%s" % count
elif strategy == STRATEGY_P1_DEVN:
return _bump_last(last_version) + ".dev%s" % count
elif strategy == STRATEGY_DOT_N:
return last_version + ".%s" % count
else:
raise RuntimeError("Unknown postversion strategy: %s" % strategy)
if uncommitted:
Expand Down
21 changes: 21 additions & 0 deletions tests/test_git_postversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from setuptools_odoo import manifest
from setuptools_odoo.git_postversion import (
STRATEGY_99_DEVN,
STRATEGY_DOT_N,
STRATEGY_NONE,
STRATEGY_P1_DEVN,
get_git_postversion,
Expand All @@ -23,6 +24,8 @@ def test_addon1():
addon1_dir = os.path.join(DATA_DIR, "addon1")
version = get_git_postversion(addon1_dir, STRATEGY_99_DEVN)
assert version == "8.0.1.0.0.99.dev4"
version = get_git_postversion(addon1_dir, STRATEGY_DOT_N)
assert version == "8.0.1.0.0.4"
version = get_git_postversion(addon1_dir, STRATEGY_P1_DEVN)
assert version == "8.0.1.0.1.dev4"
version = get_git_postversion(addon1_dir, STRATEGY_NONE)
Expand All @@ -34,8 +37,12 @@ def test_addon2():
addon2_dir = os.path.join(DATA_DIR, "addon2")
version = get_git_postversion(addon2_dir, STRATEGY_99_DEVN)
assert version == "8.0.1.0.1"
version = get_git_postversion(addon2_dir, STRATEGY_DOT_N)
assert version == "8.0.1.0.1"
version = get_git_postversion(addon2_dir, STRATEGY_P1_DEVN)
assert version == "8.0.1.0.1"
version = get_git_postversion(addon2_dir, STRATEGY_NONE)
assert version == "8.0.1.0.1"


def test_addon2_uncommitted_version_change():
Expand All @@ -49,8 +56,12 @@ def test_addon2_uncommitted_version_change():
f.write(manifest.replace("8.0.1.0.1", "8.0.1.0.2"))
version = get_git_postversion(addon2_dir, STRATEGY_99_DEVN)
assert version == "8.0.1.0.2.dev1"
version = get_git_postversion(addon2_dir, STRATEGY_DOT_N)
assert version == "8.0.1.0.2.dev1"
version = get_git_postversion(addon2_dir, STRATEGY_P1_DEVN)
assert version == "8.0.1.0.2.dev1"
version = get_git_postversion(addon2_dir, STRATEGY_NONE)
assert version == "8.0.1.0.2"
finally:
with open(manifest_path, "w") as f:
f.write(manifest)
Expand All @@ -67,8 +78,12 @@ def test_addon1_uncommitted_change():
f.write(manifest.replace("summary", "great summary"))
version = get_git_postversion(addon1_dir, STRATEGY_99_DEVN)
assert version == "8.0.1.0.0.99.dev5"
version = get_git_postversion(addon1_dir, STRATEGY_DOT_N)
assert version == "8.0.1.0.0.5"
version = get_git_postversion(addon1_dir, STRATEGY_P1_DEVN)
assert version == "8.0.1.0.1.dev5"
version = get_git_postversion(addon1_dir, STRATEGY_NONE)
assert version == "8.0.1.0.0"
finally:
with open(manifest_path, "w") as f:
f.write(manifest)
Expand All @@ -87,11 +102,17 @@ def test_no_git(tmpdir):
)
version = get_git_postversion(str(tmpdir), STRATEGY_99_DEVN)
assert version == "10.0.1.2.3"
version = get_git_postversion(str(tmpdir), STRATEGY_DOT_N)
assert version == "10.0.1.2.3"
version = get_git_postversion(str(tmpdir), STRATEGY_P1_DEVN)
assert version == "10.0.1.2.3"
version = get_git_postversion(str(tmpdir), STRATEGY_NONE)
assert version == "10.0.1.2.3"


def test_no_manifest():
with pytest.raises(manifest.NoManifestFound):
get_git_postversion(DATA_DIR, STRATEGY_99_DEVN)
get_git_postversion(DATA_DIR, STRATEGY_DOT_N)
get_git_postversion(DATA_DIR, STRATEGY_P1_DEVN)
get_git_postversion(DATA_DIR, STRATEGY_NONE)

0 comments on commit 970ad1e

Please sign in to comment.