From d7a459bad2e3ffa2c8c4243bb355543a5e6bb43f Mon Sep 17 00:00:00 2001 From: "vilet.yy" Date: Tue, 30 Mar 2021 16:33:21 +0800 Subject: [PATCH 1/5] add: dir md --- dir.md | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 dir.md diff --git a/dir.md b/dir.md new file mode 100644 index 000000000..a4443ded3 --- /dev/null +++ b/dir.md @@ -0,0 +1,135 @@ +forgeplus +├── app(应用目录) +│   ├── assets(应用静态资源目录) +│   ├── channels(actioncable的频道目录) +│   │   └── application_cable(父类) +│   ├── constraint +│   ├── controllers(应用控制器目录) +│   │   ├── admins(后台管理控制器) +│   │   ├── callbacks +│   │   ├── ci(工作流相关控制器) +│   │   ├── concerns(可反复使用的抽象方法) +│   │   │   ├── admins(对应后台管理模块) +│   │   │   ├── base(父类) +│   │   │   ├── ci(对应工作流模块) +│   │   │   └── repository(对应仓库模块) +│   │   ├── oauth(oauth验证控制器) +│   │   ├── organizations(组织模块控制器) +│   │   ├── projects(项目模块控制器) +│   │   └── users(用户模块控制器) +│   ├── decorators +│   ├── docs(api文档插件) +│   ├── forms(表单验证) +│   │   ├── ci(工作流模块) +│   │   ├── contents(仓库文件模块) +│   │   ├── gitea(gitea模块) +│   │   │   └── user(gitea用户模块) +│   │   ├── project_packages(竞标模块) +│   │   ├── projects(项目模块) +│   │   ├── protected_branches(保护分支模块) +│   │   ├── repositories(仓库模块) +│   │   ├── users(用户模块) +│   │   └── validate(公共模块) +│   ├── helpers(一些控制器帮助方法) +│   ├── imports(导入文件处理) +│   ├── interactors(流程处理器,和service类似,比如注册,创建项目) +│   ├── jobs(异步任务) +│   ├── libs(应用扩展目录) +│   │   ├── ci(工作流模块) +│   │   │   └── drone +│   │   ├── gitea +│   │   ├── limit_forbid_control +│   │   ├── omniauth +│   │   │   └── strategies +│   │   ├── trustie +│   │   ├── util +│   │   ├── wechat +│   │   └── wechat_oauth +│   ├── mailers(用来存放实现发送邮件功能的文件) +│   ├── models(模型目录) +│   ├── queries(模型查询的封装) +│   │   ├── admins(后台管理模块) +│   │   ├── ci(工作流模块) +│   │   ├── projects(项目模块) +│   │   ├── statistic(统计模块) +│   │   └── users(用户模块) +│   ├── services(业务逻辑的封装) +│   │   ├── admins(后台管理模块) +│   │   ├── branches(仓库分支模块) +│   │   ├── concerns(可反复使用的抽象方法) +│   │   ├── educoder(educoder仓库模块) +│   │   │   └── repository(仓库) +│   │   │   ├── commits(提交) +│   │   │   └── entries(文件) +│   │   ├── gitea(gitea接口封装) +│   │   │   ├── activity(项目统计模块) +│   │   │   ├── chain +│   │   │   ├── hooks(webhook模块) +│   │   │   ├── labels +│   │   │   ├── oauth2 +│   │   │   ├── organization(组织模块) +│   │   │   │   ├── organization_user(组织成员) +│   │   │   │   ├── repository(组织仓库) +│   │   │   │   ├── team(组织团队) +│   │   │   │   ├── team_project(组织团队项目) +│   │   │   │   └── team_user(组织团队成员) +│   │   │   ├── pull_request(合并请求模块) +│   │   │   ├── repository(仓库模块) +│   │   │   │   ├── branches(分支) +│   │   │   │   ├── commits(提交) +│   │   │   │   ├── contributors(贡献数) +│   │   │   │   ├── entries(文件) +│   │   │   │   ├── files(所有文件) +│   │   │   │   ├── languages(语言) +│   │   │   │   ├── members(仓库成员) +│   │   │   │   ├── protected_branches(分支保护) +│   │   │   │   ├── readme +│   │   │   │   └── tags(标签) +│   │   │   ├── user(用户) +│   │   │   └── versions(发行版) +│   │   ├── issues(易修) +│   │   ├── libraries +│   │   ├── oauth +│   │   ├── organizations(组织) +│   │   │   └── teams(组织团队) +│   │   ├── private_messages +│   │   ├── project_packages(项目竞标) +│   │   ├── projects(项目) +│   │   ├── protected_branches(分支保护) +│   │   ├── pull_requests(合并请求) +│   │   ├── repositories(仓库) +│   │   └── users(用户) +│   ├── tasks(可执行任务目录) +│   └── views(控制器对应视图文件目录) +├── bin(存放运行程序的 rails 脚本,以及其他用来部署或运行程序的脚本) +├── cable(actioncable配置目录) +├── config(配置的文件目录) +│   ├── admins(后台管理配置) +│   ├── environments(rails程序的不同运行环境的配置) +│   ├── harmonious_dictionary +│   ├── initializers(加载完gem后会自动加载此目录) +│   └── locales(i18n语言设置目录) +├── db(存放当前数据库的模式,以及数据库迁移文件) +│   └── migrate(用来存放数据库的迁移文件) +├── lib(程序的扩展模块) +│   ├── assets(通常是放置我们使用的插件中用到的assets) +│   ├── educoder +│   └── tasks(可执行任务目录) +├── log(日志目录) +├── public(唯一对外开放的文件夹,其他人可以直接访问这个目录中的东西) +│   ├── assets(编译好的静态资源目录) +│   ├── docs(api文档生成目录) +│   ├── echart(图表目录) +│   ├── editormd(富文本编辑器静态资源目录) +│   ├── fonts(字体目录) +│   ├── images(图片目录) +│   ├── javascripts(脚本目录) +│   ├── options(仓库许可证、gitignore、readme文件目录) +│   ├── react +│   │   └── build(前端编译好的文件目录) +│   └── stylesheets(层叠样式表目录) +├── spec(spec测试目录) +├── test(用于存放单元测试、功能测试及整合测试文件等测试文件) +├── tmp(临时文件,例如缓存,PID,会话文件) +├── vendor(存放第三方代码。经常用来放第三方 gem) +├──   └── assets(通常是放置一些我们从别的地方借用的assets) \ No newline at end of file From d0a65775aaf2b8828bf00840bec8ccda6753bdd3 Mon Sep 17 00:00:00 2001 From: "vilet.yy" Date: Tue, 30 Mar 2021 16:34:12 +0800 Subject: [PATCH 2/5] fix: not show commiter avatar --- app/helpers/repositories_helper.rb | 2 +- app/views/repositories/_author.json.jbuilder | 1 + app/views/repositories/_commit.json.jbuilder | 4 ++-- app/views/repositories/_commit_author.json.jbuilder | 5 ++++- app/views/repositories/commits.json.jbuilder | 9 ++++++++- app/views/repositories/detail.json.jbuilder | 4 +++- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 2889b6fc8..a6426083e 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -28,7 +28,7 @@ module RepositoriesHelper def render_commit_author(author_json) return nil if author_json.blank? - find_user_by_login author_json['login'] + find_user_by_login author_json['name'] end def readme_render_decode64_content(str, path) diff --git a/app/views/repositories/_author.json.jbuilder b/app/views/repositories/_author.json.jbuilder index 1dbcc4ebc..e37a50e44 100644 --- a/app/views/repositories/_author.json.jbuilder +++ b/app/views/repositories/_author.json.jbuilder @@ -1,5 +1,6 @@ json.author do if @project.forge? + json.id user.id json.login user.login json.type user&.type json.name user.real_name diff --git a/app/views/repositories/_commit.json.jbuilder b/app/views/repositories/_commit.json.jbuilder index 079473b3d..95cb03412 100644 --- a/app/views/repositories/_commit.json.jbuilder +++ b/app/views/repositories/_commit.json.jbuilder @@ -26,9 +26,9 @@ if @project.forge? end json.author do - json.partial! 'commit_author', user: render_commit_author(commit['author']) + json.partial! 'commit_author', user: render_commit_author(commit['commit']['author']), name: commit['commit']['author']['name'] end json.committer do - json.partial! 'commit_author', user: render_commit_author(commit['committer']) + json.partial! 'commit_author', user: render_commit_author(commit['commit']['committer']), name: commit['commit']['committer']['name'] end end diff --git a/app/views/repositories/_commit_author.json.jbuilder b/app/views/repositories/_commit_author.json.jbuilder index 77d9b655c..d57e7c534 100644 --- a/app/views/repositories/_commit_author.json.jbuilder +++ b/app/views/repositories/_commit_author.json.jbuilder @@ -4,5 +4,8 @@ if user json.name user.real_name json.image_url url_to_avatar(user) else - json.nil! + json.id nil + json.login name + json.name name + json.image_url File.join("avatars/User","b") end diff --git a/app/views/repositories/commits.json.jbuilder b/app/views/repositories/commits.json.jbuilder index 7cbf34c4d..82cd17133 100644 --- a/app/views/repositories/commits.json.jbuilder +++ b/app/views/repositories/commits.json.jbuilder @@ -5,6 +5,7 @@ else json.total_count @hash_commit[:total_count] json.commits do json.array! @hash_commit[:body] do |commit| + json.commit1 commit commiter = commit['committer'] if commiter.present? commit_user_id = commiter['id'] @@ -17,7 +18,13 @@ else if forge_user json.partial! 'author', user: forge_user else - json.author nil + json.author do + json.id nil + json.login commit['commit']['author']['name'] + json.type nil + json.name commit['commit']['author']['name'] + json.image_url File.join("avatars/User","b") + end end end end diff --git a/app/views/repositories/detail.json.jbuilder b/app/views/repositories/detail.json.jbuilder index 58bc9abce..28a64e50a 100644 --- a/app/views/repositories/detail.json.jbuilder +++ b/app/views/repositories/detail.json.jbuilder @@ -61,7 +61,7 @@ json.release_versions do json.tag_name release["tag_name"] json.created_at format_time(release["created_at"].to_time) end - json.total_count @result[:release].size + json.total_count @repository&.version_releases.size end json.branches do json.list @result[:branch].each do |branch| @@ -93,3 +93,5 @@ json.contributors do json.total_count total_count end json.languages @result[:language] + +json.partial! 'author', locals: { user: @project.owner } From ffa2782637a619ff23a3a217bf9c4d49cb80febe Mon Sep 17 00:00:00 2001 From: "vilet.yy" Date: Tue, 30 Mar 2021 16:34:31 +0800 Subject: [PATCH 3/5] fix: detail release version limit --- app/services/gitea/versions/list_service.rb | 7 ++++--- app/services/repositories/detail_service.rb | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/services/gitea/versions/list_service.rb b/app/services/gitea/versions/list_service.rb index 40db0d149..5d160fc3e 100644 --- a/app/services/gitea/versions/list_service.rb +++ b/app/services/gitea/versions/list_service.rb @@ -1,12 +1,13 @@ # Get a list of all commits from a repository class Gitea::Versions::ListService < Gitea::ClientService - attr_reader :token, :user_name, :repo + attr_reader :token, :user_name, :repo, :args # sha: SHA or branch to start listing commits from (usually 'master') - def initialize(token, user_name, repo) + def initialize(token, user_name, repo, args={}) @token = token @user_name = user_name @repo = repo + @args = args end def call @@ -16,7 +17,7 @@ class Gitea::Versions::ListService < Gitea::ClientService private def params - Hash.new.merge(token: token) + args.merge(token: token) end def url diff --git a/app/services/repositories/detail_service.rb b/app/services/repositories/detail_service.rb index 39fa57412..d8853cf45 100644 --- a/app/services/repositories/detail_service.rb +++ b/app/services/repositories/detail_service.rb @@ -37,7 +37,7 @@ class Repositories::DetailService < ApplicationService end def release_suitable - releases = Gitea::Versions::ListService.call(@owner.gitea_token, @owner.try(:login), @repo.try(:identifier)) + releases = Gitea::Versions::ListService.call(@owner.gitea_token, @owner.try(:login), @repo.try(:identifier), {page: 1, limit: 1}) releases.is_a?(Hash) && releases[:status] == -1 ? [] : releases end From 8952f6a9447468041c6bf35c802fd8c50655ebc0 Mon Sep 17 00:00:00 2001 From: "vilet.yy" Date: Tue, 30 Mar 2021 17:13:58 +0800 Subject: [PATCH 4/5] fix: menu manager allow visit --- app/controllers/projects_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 93b6dc3bd..34b60cd0e 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -17,7 +17,7 @@ class ProjectsController < ApplicationController menu.append(menu_hash_by_name("devops")) if @project.has_menu_permission("devops") menu.append(menu_hash_by_name("versions")) if @project.has_menu_permission("versions") menu.append(menu_hash_by_name("activity")) - menu.append(menu_hash_by_name("setting")) if current_user.admin? || @project.owner?(current_user) + menu.append(menu_hash_by_name("setting")) if current_user.admin? || @project.manager?(current_user) render json: menu end From 9394d15752afa6be8e05145d654c7ba3c3c4cccc Mon Sep 17 00:00:00 2001 From: "vilet.yy" Date: Tue, 30 Mar 2021 17:27:50 +0800 Subject: [PATCH 5/5] fix: menu manager allow visit --- app/controllers/projects/project_units_controller.rb | 2 +- app/controllers/projects_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/projects/project_units_controller.rb b/app/controllers/projects/project_units_controller.rb index 90bc64a71..e21fa388f 100644 --- a/app/controllers/projects/project_units_controller.rb +++ b/app/controllers/projects/project_units_controller.rb @@ -4,7 +4,7 @@ class Projects::ProjectUnitsController < Projects::BaseController end def create - if current_user.admin? || @project.owner?(current_user) + if current_user.admin? || @project.manager?(current_user) ActiveRecord::Base.transaction do ProjectUnit.update_by_unit_types!(@project, unit_types) render_ok diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 34b60cd0e..f6ab38369 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -111,7 +111,7 @@ class ProjectsController < ApplicationController end def destroy - if current_user.admin? || @project.owner?(current_user) + if current_user.admin? || @project.manager?(current_user) ActiveRecord::Base.transaction do Gitea::Repository::DeleteService.new(@project.owner, @project.identifier).call @project.destroy!