跳转到主要内容

从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 apt install cloc
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/16.0/github_connector/static/description/github_settings.png
  2. 转到您(们)的用户表,将他们添加到新的“连接器 Github 管理员”组中。该组的成员将有机会运行 Github 同步。

技术信息

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

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

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

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

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

使用

从Github的初始上传

要从 Github 获取信息,您必须

  1. 转到‘Github’/‘设置’/‘同步对象’

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

    https://raw.githubusercontent.com/OCA/interface-github/16.0/github_connector/static/description/sync_organization.png
  3. 完成组织(们)的设置后,转到‘Github’/‘Github 社区’/‘组织’

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

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

选择要下载的分支

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

  1. 在“设置”选项卡中,设置您不希望下载的仓库(或您想要下载的仓库)。如果设置了“特定仓库”,则忽略“忽略仓库”的值。

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

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

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

团队/成员同步

您可以同步成员团队

  1. 转到‘团队’/树形视图/‘操作’/‘从 Github 更新’。

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

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

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

仓库同步

您可以同步您仓库的分支

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

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

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

获取源代码

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

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

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

    https://raw.githubusercontent.com/OCA/interface-github/16.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/16.0/github_connector/static/description/wizard_create_team.png
  2. 仓库

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

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

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

注意

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

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

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

报告

此模块提供几个报告

按系列查看分支

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

按系列查看大小

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

仓库分支分析规则

https://raw.githubusercontent.com/OCA/interface-github/16.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 Issues上跟踪。在出现问题时,请检查是否已报告您的问题。如果是您首先发现的,请提供详细且受欢迎的反馈,以帮助我们解决问题。

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

致谢

作者

  • GRAP

  • Akretion

  • Tecnativa

贡献者

维护者

此模块由OCA维护。

Odoo Community Association

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

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

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

项目详情


下载文件

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

源代码分发

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

构建分发

支持者