Skip to content

Commit

Permalink
Add mechanism to dynamically filter main branches
Browse files Browse the repository at this point in the history
So we don't need to update with each Odoo release
  • Loading branch information
sbidoul committed Oct 2, 2022
1 parent 3f8cdf3 commit f38983d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
11 changes: 11 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from tools.config import is_main_branch


def test_is_main_branch():
assert is_main_branch("6.1")
assert is_main_branch("8.0")
assert is_main_branch("10.0")
assert is_main_branch("16.0")
assert is_main_branch("17.0")
assert not is_main_branch("14.0-ocabot-thing")
assert not is_main_branch("14.1")
7 changes: 7 additions & 0 deletions tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import configparser
import os
import re

CREDENTIALS_FILE = 'oca.cfg'

Expand Down Expand Up @@ -65,6 +66,7 @@ def write_config(config):
}


# deprecated, use is_main_branch() instead
MAIN_BRANCHES = (
'6.1',
'7.0',
Expand All @@ -76,4 +78,9 @@ def write_config(config):
'13.0',
'14.0',
'15.0',
'16.0',
)


def is_main_branch(branch):
return re.match(r"^(6\.1|\d+\.0)$", branch)
4 changes: 3 additions & 1 deletion tools/oca_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def get_repositories():
return all_repos


def get_repositories_and_branches(repos=(), branches=MAIN_BRANCHES):
def get_repositories_and_branches(repos=(), branches=MAIN_BRANCHES, branch_filter=None):
gh = login()
for repo in gh.repositories_by('OCA'):
if repos and repo.name not in repos:
Expand All @@ -230,6 +230,8 @@ def get_repositories_and_branches(repos=(), branches=MAIN_BRANCHES):
for branch in repo.branches():
if branches and branch.name not in branches:
continue
if branch_filter and not branch_filter(branch):
continue
yield repo.name, branch.name


Expand Down

0 comments on commit f38983d

Please sign in to comment.