Skip to content

Add option to set minimum supported branch #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 30, 2023
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
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ combine_as_imports=True
use_parentheses=True
line_length=88
known_first_party=oca_github_bot
known_third_party = aiohttp,appdirs,celery,gidgethub,github3,lxml,odoorpc,pytest,requests,setuptools
known_third_party = aiohttp,appdirs,celery,gidgethub,github3,lxml,odoorpc,packaging,pytest,requests,setuptools
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ pytest-mock==3.9.0
pytest-vcr==1.0.2
PyYAML==6.0
vcrpy==4.2.1
wrapt==1.15.0
5 changes: 1 addition & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ click-plugins==1.1.1
click-repl==0.2.0
commonmark==0.9.1
cryptography==41.0.2
Deprecated==1.2.13
docutils==0.19
flower==1.2.0
frozenlist==1.3.1
Expand All @@ -34,14 +33,13 @@ lxml==4.9.1
more-itertools==8.14.0
multidict==6.0.2
OdooRPC==0.8.0
packaging==21.3
packaging==23.1
pkginfo==1.8.3
prometheus-client==0.14.1
prompt-toolkit==3.0.31
pycparser==2.21
Pygments==2.15.0
PyJWT==2.5.0
pyparsing==3.0.9
python-dateutil==2.8.2
pytz==2022.4
raven==6.10.0
Expand All @@ -65,6 +63,5 @@ urllib3==1.26.12
vine==5.0.0
wcwidth==0.2.5
webencodings==0.5.1
wrapt==1.14.1
yarl==1.8.1
zipp==3.8.1
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
"lxml",
# for setuptools-odoo-make-default
"setuptools-odoo",
# packaging
"packaging>=22",
],
extras_require={
"test": [
Expand Down
2 changes: 2 additions & 0 deletions src/oca_github_bot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,5 @@ def func_wrapper(*args, **kwargs):
"WHEEL_BUILD_TOOLS",
"build,pip,setuptools<58,wheel,setuptools-odoo,whool",
).split(",")

MAIN_BRANCH_BOT_MIN_VERSION = os.environ.get("MAIN_BRANCH_BOT_MIN_VERSION", "8.0")
11 changes: 8 additions & 3 deletions src/oca_github_bot/version_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

import re

from packaging import version

from . import config

ODOO_VERSION_RE = re.compile(r"^(?P<major>\d+)\.(?P<minor>\d+)$")
MERGE_BOT_BRANCH_RE = re.compile(
r"(?P<target_branch>\S+)"
Expand All @@ -14,10 +18,11 @@


def is_main_branch_bot_branch(branch_name):
mo = ODOO_VERSION_RE.match(branch_name)
if not mo:
if not ODOO_VERSION_RE.match(branch_name):
return False
return int(mo.group("major")) >= 8
return version.parse(branch_name) >= version.parse(
config.MAIN_BRANCH_BOT_MIN_VERSION
)


def is_protected_branch(branch_name):
Expand Down
6 changes: 6 additions & 0 deletions tests/test_version_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@
search_merge_bot_branch,
)

from .common import set_config


def test_is_main_branch_bot_branch():
assert not is_main_branch_bot_branch("6.1")
assert not is_main_branch_bot_branch("7.0")
assert is_main_branch_bot_branch("8.0")
assert is_main_branch_bot_branch("12.0")
assert not is_main_branch_bot_branch("10.0-something")
with set_config(MAIN_BRANCH_BOT_MIN_VERSION="10.0"):
assert is_main_branch_bot_branch("10.0")
assert is_main_branch_bot_branch("12.0")
assert not is_main_branch_bot_branch("7.0")


def test_is_protected_branch():
Expand Down