Skip to content

Commit

Permalink
Merge PR #111 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Jan 29, 2024
2 parents 4f77a18 + 429ccf3 commit b1e8241
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 4 deletions.
2 changes: 1 addition & 1 deletion github_connector/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"name": "Github Connector",
"summary": "Synchronize information from Github repositories",
"version": "14.0.2.1.0",
"version": "14.0.2.2.0",
"category": "Connector",
"license": "AGPL-3",
"author": "Odoo Community Association (OCA), GRAP, Akretion, Tecnativa",
Expand Down
20 changes: 20 additions & 0 deletions github_connector/migrations/14.0.2.2.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 Simone Rubino - Aion Tech
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
branches = env["github.repository.branch"].search([])
repositories = branches.repository_id
repositories.modified(
[
"complete_name",
]
)
branches.recompute(
fnames=[
"complete_name",
],
)
1 change: 1 addition & 0 deletions github_connector/models/github_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class GithubRepository(models.Model):
_inherit = ["abstract.github.model"]
_order = "organization_id, name"
_description = "Github Repository"
_rec_name = "complete_name"

_github_login_field = "full_name"

Expand Down
16 changes: 13 additions & 3 deletions github_connector/models/github_repository_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class GithubRepository(models.Model):
_inherit = ["abstract.github.model"]
_order = "repository_id, sequence_serie"
_description = "Github Repository Branch"
_rec_name = "complete_name"

_github_login_field = False

Expand Down Expand Up @@ -147,6 +148,12 @@ def cron_analyze_all(self):
branches._analyze_code()
return True

def find_related_github_object(self, obj_id=None):
self.ensure_one()
gh_repo = self.repository_id.find_related_github_object()
gh_branch = gh_repo.get_branch(self.name)
return gh_branch

# Custom
def create_or_update_from_name(self, repository_id, name):
branch = self.search(
Expand Down Expand Up @@ -344,10 +351,12 @@ def _operation_analysis_rule_id(self, analysis_rule_id):
return res

# Compute Section
@api.depends("name", "repository_id.name")
@api.depends("name", "repository_id.complete_name")
def _compute_complete_name(self):
for branch in self:
branch.complete_name = branch.repository_id.name + "/" + branch.name
branch.complete_name = (
branch.repository_id.complete_name + "/" + branch.name
)

@api.depends("size")
def _compute_mb_size(self):
Expand All @@ -373,7 +382,8 @@ def _compute_local_path(self):
)
for branch in self:
branch.local_path = os.path.join(
source_path, branch.organization_id.github_name, branch.complete_name
source_path,
branch.complete_name,
)

@api.depends(
Expand Down
3 changes: 3 additions & 0 deletions github_connector/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
* Carlos Roca
* Víctor Martínez
* João Marques
* `Aion Tech <https://aiontech.company/>`_:

* Simone Rubino <[email protected]>
3 changes: 3 additions & 0 deletions github_connector/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Copyright 2021-2022 Tecnativa - Víctor Martínez
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import test_branch
from . import test_github_connector
from . import test_github_analysis_rule
from . import test_repository
21 changes: 21 additions & 0 deletions github_connector/tests/test_branch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2023 Simone Rubino - Aion Tech
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from .common import TestGithubConnectorCommon


class TestBranch(TestGithubConnectorCommon):
def test_display_name(self):
"""The display name shows
the Organization name,
the Repository name
and the Branch name.
"""
branch = self.repository_ocb_13
repository = branch.repository_id
organization = repository.organization_id

display_name = branch.display_name
self.assertIn(branch.name, display_name)
self.assertIn(repository.name, display_name)
self.assertIn(organization.github_name, display_name)
18 changes: 18 additions & 0 deletions github_connector/tests/test_repository.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2023 Simone Rubino - Aion Tech
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from .common import TestGithubConnectorCommon


class TestRepository(TestGithubConnectorCommon):
def test_display_name(self):
"""The display name shows
the Organization name
and the Repository name.
"""
repository = self.repository_ocb
organization = repository.organization_id

display_name = repository.display_name
self.assertIn(repository.name, display_name)
self.assertIn(organization.github_name, display_name)

0 comments on commit b1e8241

Please sign in to comment.