跳转到主要内容

从Github仓库同步信息

项目描述

Beta License: AGPL-3 OCA/interface-github Translate me on Weblate Try me on Runboat

此模块允许您

  • 从Github(组织、团队、用户)将社交信息获取到Odoo中

  • 从Github(仓库、分支)将代码结构信息获取到Odoo中

  • 从Github下载源代码

  • 根据之前创建的规则分析仓库代码

目录表

安装

要安装此插件,您需要安装一些Python依赖项

sudo pip install PyGitHub
sudo pip install pygount
sudo pip install pathspec
sudo pip install GitPython

源代码分析由https://github.com/roskakori/pygount生成

配置

一旦安装,您必须

  1. 打开您的odoo.conf文件,并添加额外的设置以提及Github凭据,以及源代码将下载到的本地路径

    • source_code_local_path = /workspace/source_code/

注意:您可以使用键SOURCE_CODE_LOCAL_PATH将路径定义为环境变量

注意:确保Odoo进程可以对该文件夹进行读写访问

  • github_token = your_github_access_token

注意:GitHub已弃用登录/密码认证。 https://githubdocs.cn/en/rest/overview/other-authentication-methods#via-username-and-password

  1. 转到“设置”/“技术”/“参数”/“系统参数”并定义以下值

    1. github.max_try:在引发错误之前调用API的次数。您的连接越不稳定/越慢,此值应越高

    2. git.partial_commit_during_analysis:如果您想在每次仓库分析后提交分析结果到数据库,则将其设置为True。我们建议在执行初始下载(可能包含大量仓库)时设置为True,以减少事务大小

    https://raw.githubusercontent.com/OCA/interface-github/14.0/github_connector/static/description/github_settings.png
  2. 前往您的用户表,将他们添加到新的“Connector Github Manager”组中。该组的成员将有机会运行Github同步。

技术信息

此模块提供4个cron任务,您可以选择启用

  • 同步所有组织和团队(cron_update_organization

  • 同步所有仓库的分支列表(cron_update_branch_list

  • 下载所有Github分支的源代码(cron_download_code

  • 分析所有Github分支的源代码(cron_analyze_code

用法

从Github的初始上传

要从Github获取信息,您必须

  1. 前往‘Github’/‘设置’/‘同步对象’

  2. 选择您想同步的对象类型及其Gthub名称

    https://raw.githubusercontent.com/OCA/interface-github/14.0/github_connector/static/description/sync_organization.png
  3. 完成组织设置后,前往‘Github’/‘Github社区’/‘组织’

    https://raw.githubusercontent.com/OCA/interface-github/14.0/github_connector/static/description/github_organization_kanban.png
  4. 可选的,一旦创建组织,您可以为项目创建系列。前往‘Github’/‘组织’/点击您的组织/‘组织系列’标签

    https://raw.githubusercontent.com/OCA/interface-github/14.0/github_connector/static/description/github_organization_series.png

选择要下载的分支

此设置将防止下载不需要的分支,仅下载主分支(发布)

  1. 在“设置”标签中,设置您不想下载的仓库(或您想下载的仓库)。如果设置了“特定仓库”,则忽略“忽略仓库”的值。

  2. 在“设置”标签中,设置您用于持续集成和覆盖率的外部服务的URL。

    https://raw.githubusercontent.com/OCA/interface-github/14.0/github_connector/static/description/github_organization_external_services.png
  3. 设置完成后,单击“同步”按钮以同步仓库、团队和成员。 (此过程可能需要一段时间,具体取决于您的大小)

    https://raw.githubusercontent.com/OCA/interface-github/14.0/github_connector/static/description/github_organization_sync_buttons.png

团队/成员同步

您可以同步成员团队

  1. 前往‘团队’/树形视图/‘操作’/‘从Github更新’

    https://raw.githubusercontent.com/OCA/interface-github/14.0/github_connector/static/description/github_team_kanban.png
  2. 在每个团队中,您可以看到成员列表和成员的角色

    https://raw.githubusercontent.com/OCA/interface-github/14.0/github_connector/static/description/github_team_partner_kanban.png
  3. 在每个团队中,您可以看到仓库列表,但不能看到团队权限。(见“已知问题”部分)

    https://raw.githubusercontent.com/OCA/interface-github/14.0/github_connector/static/description/github_team_repository_kanban.png

仓库同步

您可以同步您的仓库分支

  1. 前往‘仓库’/树形视图/‘操作’/‘从Github更新’

    https://raw.githubusercontent.com/OCA/interface-github/14.0/github_connector/static/description/github_repository_kanban.png
  2. 在每个仓库中,您可以看到主分支列表和源代码大小。

    https://raw.githubusercontent.com/OCA/interface-github/14.0/github_connector/static/description/github_repository_branch_kanban.png

获取源代码

最后,您可以下载所有分支的源代码

  1. 前往‘仓库分支’/树形视图/‘操作’/‘下载和分析源代码’

    https://raw.githubusercontent.com/OCA/interface-github/14.0/github_connector/static/description/wizard_download_analyze.png
  2. 在树形视图中,您可以手动更新源代码或刷新分析。

    https://raw.githubusercontent.com/OCA/interface-github/14.0/github_connector/static/description/github_repository_branch_list.png

分析源代码

您可以创建与GitHub组织、GitHub仓库和/或GitHub仓库分支相关的自定义分析规则来分析代码。

  1. 前往‘设置’/‘分析规则组’并创建记录,以便组织规则

  2. 前往‘设置’/‘分析规则’并创建规则,例如

  1. 名称:所有代码,组:通用,路径:*

  2. 名称:Python代码,组:通用,路径:*.py

  3. 名称:Xml代码,组:通用,路径:*.xml

  4. 名称:仓库1,组:自定义,路径:/path/

注意:“分析规则”中的路径字段允许放置多个路径,路径格式遵循https://git-scm.cn/docs/gitignore#_pattern_format

  1. 前往GitHub > GitHub社区 > 组织并定义分析规则(可选)

  2. 前往GitHub > GitHub仓库 > 仓库并定义分析规则(可选)

  3. 前往GitHub > GitHub仓库 > 仓库分支并定义分析规则(可选)

分析源代码在点击“更新源代码分析”按钮时执行,该按钮位于某些“仓库分支”中,获取所有分析规则(仓库+组织)并分析代码并生成相关信息。另一种分析源代码的方法是在cron中名为“分析所有GitHub分支的源代码”

您可以在“仓库分支”/“代码分析”中查看从分析规则获得的信息。

在Github中创建数据

您可以直接从Odoo创建两个项目在Github上。

  1. 团队

    1. 转到“设置”/“在GitHub中创建团队”。

    2. 设置信息和点击在GitHub中的创建。

    3. Odoo将尝试创建团队。如果访问权限和数据正确,则将在GitHub中直接完成创建。

    4. 稍后,将执行同步,以在Odoo实例中创建相应的团队。

    https://raw.githubusercontent.com/OCA/interface-github/14.0/github_connector/static/description/wizard_create_team.png
  2. 仓库

    1. 转到“设置”/“在GitHub中创建团队”。

    2. 设置信息和点击在GitHub中的创建。

    https://raw.githubusercontent.com/OCA/interface-github/14.0/github_connector/static/description/wizard_create_repository.png

注意

该模块的分析是基本的:目前,它只提供分支大小。

尽管如此,您可以根据需要开发额外的Odoo自定义模块来扩展分析功能并获得额外的统计数据。

这样,您可以看到模块github_connector_odoo,如果您的仓库包含Odoo模块。

报告

本模块提供了几个报告

按系列分支

https://raw.githubusercontent.com/OCA/interface-github/14.0/github_connector/static/description/reporting_branches_by_serie.png

按系列大小

https://raw.githubusercontent.com/OCA/interface-github/14.0/github_connector/static/description/reporting_sizes_by_serie.png

仓库分支分析规则

https://raw.githubusercontent.com/OCA/interface-github/14.0/github_connector/static/description/github_repository_branch_rule_info_report.png

已知问题/路线图

  • 目前,GitHub API不提供经典UI中可用的某些信息,包括

    1. 团队层次结构:该字段存在于模型github_team.parent_id中,但未使用。

  • 可能的改进

    1. 创建一个新的模块github_connector_website,可以显示团队/仓库/分支信息,供非登录用户查看。

    2. 分析提交(作者、按系列的数量等…):此功能已在V8.0 PR中部分实现。

    3. 同步拉取请求、问题、评论:此功能已在V8.0 PR中部分实现。

  • 重构GitHub连接器

    有一个名为PyGitHub的Python库可用。使用它可能很有趣,而不是使用自定义代码。然而,此库不提供对子对象的良好访问,导致目前产生不必要的API调用。例如,更新仓库应在调用父组织之前调用(当前模块更快)。

错误跟踪器

错误在GitHub问题上跟踪。如果遇到问题,请检查是否已报告您的问题。如果您是第一个发现它的人,请通过提供详细且受欢迎的反馈来帮助我们解决这个问题。

不要直接联系贡献者以获取支持或帮助解决技术问题。

致谢

作者

  • GRAP

  • Akretion

  • Tecnativa

贡献者

维护者

本模块由OCA维护。

Odoo Community Association

OCA,或Odoo社区协会,是一个非营利组织,其使命是支持Odoo功能的协作开发并推广其广泛使用。

本模块是GitHub上的OCA/interface-github项目的一部分。

欢迎您贡献力量。要了解如何贡献,请访问https://odoo-community.org/page/Contribute

项目详情


下载文件

下载您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

此版本没有可用的源分布文件。请参阅生成分布存档的教程。

构建分布

odoo14_addon_github_connector-14.0.2.3.0-py3-none-any.whl (568.9 kB 查看哈希值)

上传时间 Python 3

支持者