Skip to content
Open
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
81 changes: 81 additions & 0 deletions vcp_psc/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
=======================
Contributors Github Psc
=======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:183c6a4f3366dc8045913f644b065e91fe8cd0cc8f869dc7b02ca87df5267e50
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fversion--control--platform-lightgray.png?logo=github
:target: https://github.com/OCA/version-control-platform/tree/18.0/vcp_psc
:alt: OCA/version-control-platform
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/version-control-platform-18-0/version-control-platform-18-0-vcp_psc
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/version-control-platform&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module adds PSCs information to users by following a repository of
configuration that executes

https://github.com/OCA/repo-maintainer

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/version-control-platform/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/version-control-platform/issues/new?body=module:%20vcp_psc%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Dixmit

Contributors
------------

- `Dixmit <https://www.dixmit.com>`__

- Enric Tobella

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/version-control-platform <https://github.com/OCA/version-control-platform/tree/18.0/vcp_psc>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions vcp_psc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
22 changes: 22 additions & 0 deletions vcp_psc/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2026 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Contributors Github Psc",
"summary": """Integrate PSCs""",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"author": "Dixmit,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/version-control-platform",
"depends": ["vcp_git"],
"data": [
"data/vcp_rule.xml",
"views/vcp_repository.xml",
"security/ir.model.access.csv",
"views/vcp_platform_psc.xml",
"views/vcp_platform.xml",
# "templates/templates.xml",
],
"assets": {},
"demo": [],
}
11 changes: 11 additions & 0 deletions vcp_psc/data/vcp_rule.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2026 Dixmit
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo noupdate="1">
<record id="vcp_rule_psc" model="vcp.rule">
<field name="name">PSC Detection</field>
<field name="rule_type">psc</field>
<field name="branch_pattern">^master$</field>
<field name="paths"><![CDATA[conf]]></field>
</record>
</odoo>
5 changes: 5 additions & 0 deletions vcp_psc/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from . import vcp_platform
from . import vcp_platform_psc
from . import vcp_repository
from . import vcp_rule
from . import vcp_user
39 changes: 39 additions & 0 deletions vcp_psc/models/vcp_platform.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2026 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).


from odoo import fields, models


class VCPPlatform(models.Model):
_inherit = "vcp.platform"

psc_ids = fields.One2many(
"vcp.platform.psc",
inverse_name="platform_id",
readonly=True,
)

def _get_merged_domain(self, start, end, psc_id=None, **values):
result = super()._get_merged_domain(start, end, psc_id=psc_id, **values)
if psc_id:
result.append(("repository_id.psc_id", "=", int(psc_id)))
return result

def _get_created_domain(self, start, end, psc_id=None, **values):
result = super()._get_created_domain(start, end, psc_id=psc_id, **values)
if psc_id:
result.append(("repository_id.psc_id", "=", int(psc_id)))
return result

def _get_comments_domain(self, start, end, psc_id=None, **values):
result = super()._get_comments_domain(start, end, psc_id=psc_id, **values)
if psc_id:
result.append(("repository_id.psc_id", "=", int(psc_id)))
return result

def _get_reviews_domain(self, start, end, psc_id=None, **values):
result = super()._get_reviews_domain(start, end, psc_id=psc_id, **values)
if psc_id:
result.append(("repository_id.psc_id", "=", int(psc_id)))
return result
21 changes: 21 additions & 0 deletions vcp_psc/models/vcp_platform_psc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2026 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class VCPPlatformPsc(models.Model):
_name = "vcp.platform.psc"
_description = "Version Control Platform PSC"

platform_id = fields.Many2one(
comodel_name="vcp.platform",
string="Platform",
required=True,
)
name = fields.Char(required=True)
key = fields.Char(required=True)
member_ids = fields.Many2many(
"vcp.user",
readonly=True,
)
13 changes: 13 additions & 0 deletions vcp_psc/models/vcp_repository.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2026 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class VCPRepository(models.Model):
_inherit = "vcp.repository"

psc_id = fields.Many2one(
"vcp.platform.psc",
readonly=True,
)
161 changes: 161 additions & 0 deletions vcp_psc/models/vcp_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Copyright 2026 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import logging
import os
import re

import yaml

from odoo import fields, models

_logger = logging.getLogger(__name__)


class VcpRule(models.Model):
_inherit = "vcp.rule"

rule_type = fields.Selection(
selection_add=[("psc", "PSC Analysis")],
ondelete={"psc": "cascade"},
)

def _process_rule_psc(self, record, parameters=None):
"""
Process a PSC rule for a given repository.

:param repository: The repository to process the rule for.
:param rule: The PSC rule to process.
"""
if record._name != "vcp.repository.branch":
# It doesn't make sense to process this kind of rules outside
# of a repository branch, as they need the code to be downloaded
# and analyzed.
return
record._download_code()
_logger.info("Downloaded code for repository branch '%s'", record.display_name)
for conf in self.paths.splitlines():
conf = conf.strip()
if not conf or conf.startswith("#"):
continue
conf = record.local_path + "/" + conf
if not os.path.exists(conf):
_logger.warning(
"Path '%s' does not exist for repository branch '%s'",
conf,
record.display_name,
)
continue
_logger.info(f"Found {conf}")
for psc_file in os.listdir(os.path.join(record.local_path, conf, "psc")):
if re.match(r"^.*\.yml$", psc_file):
psc_path = os.path.join(record.local_path, conf, "psc", psc_file)
with open(psc_path) as f:
try:
psc_data = yaml.safe_load(f)
except yaml.YAMLError as e:
_logger.error(f"Error parsing PSC file '{psc_path}': {e}")
continue
self._process_psc_data(record, psc_data)
for psc_repo_file in os.listdir(
os.path.join(record.local_path, conf, "repo")
):
if re.match(r"^.*\.yml$", psc_repo_file):
psc_repo_path = os.path.join(
record.local_path, conf, "repo", psc_repo_file
)
with open(psc_repo_path) as f:
try:
psc_repo_data = yaml.safe_load(f)
except yaml.YAMLError as e:
_logger.error(
f"Error parsing PSC file '{psc_repo_path}': {e}"
)
continue
self._process_psc_repo_data(record, psc_repo_data)

def _process_psc_data(self, record, psc_data):
"""
Process the PSC data.

:param record: The repository branch record to process the PSC data for.
:param psc_data: The PSC data to process.
"""
if not psc_data:
_logger.warning(
"No PSC data found for repository branch '%s'", record.display_name
)
return
for psc_name in psc_data:
psc_record = self.env["vcp.platform.psc"].search(
[
("platform_id", "=", record.platform_id.id),
("key", "=", psc_name),
],
limit=1,
)
if not psc_record:
psc_record = (
self.env["vcp.platform.psc"]
.sudo()
.create(
{
"platform_id": record.platform_id.id,
"key": psc_name,
"name": psc_data[psc_name].get("name", psc_name),
}
)
)
else:
psc_record.sudo().write(
{
"name": psc_data[psc_name].get("name", psc_name),
}
)
member_logins = psc_data[psc_name].get("members", []) + psc_data[
psc_name
].get("representatives", [])
members = []
for member in member_logins:
members.append(record.platform_id.host_id._get_user(member))
psc_record.sudo().member_ids = self.env["vcp.user"].browse(members)

def _process_psc_repo_data(self, record, psc_repo_data):
"""
Process the PSC Repository data

:param record: The repository branch record to process the PSC data for.
:param psc_repo_data: The PSC Repository data to process.
"""
if not psc_repo_data:
_logger.warning(
"No data found for repository branch '%s'", record.display_name
)
return
for repo_name in psc_repo_data:
psc_name = psc_repo_data[repo_name].get("psc")
psc_record = self.env["vcp.platform.psc"].search(
[
("platform_id", "=", record.platform_id.id),
("key", "=", psc_name),
],
limit=1,
)
if not psc_record:
continue
repo_record = (
self.env["vcp.repository"]
.sudo()
.search(
[
("platform_id", "=", record.platform_id.id),
("name", "=", repo_name),
],
limit=1,
)
)
if repo_record:
repo_record.sudo().write(
{
"psc_id": psc_record.id,
}
)
13 changes: 13 additions & 0 deletions vcp_psc/models/vcp_user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2026 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class VCPUser(models.Model):
_inherit = "vcp.user"

psc_ids = fields.Many2many(
comodel_name="vcp.platform.psc",
readonly=True,
)
3 changes: 3 additions & 0 deletions vcp_psc/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions vcp_psc/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Dixmit](https://www.dixmit.com)
- Enric Tobella
3 changes: 3 additions & 0 deletions vcp_psc/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module adds PSCs information to users by following a repository of configuration that executes

https://github.com/OCA/repo-maintainer
3 changes: 3 additions & 0 deletions vcp_psc/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
access_vcp_psc,Access VCP PSC,model_vcp_platform_psc,base.group_user,1,0,0,0
access_vcp_portal_psc,Access VCP PSC,model_vcp_platform_psc,base.group_portal,1,0,0,0
Binary file added vcp_psc/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading