| @@ -4,7 +4,7 @@ class Projects::ProjectUnitsController < Projects::BaseController | |||||
| end | end | ||||
| def create | def create | ||||
| if current_user.admin? || @project.owner?(current_user) | |||||
| if current_user.admin? || @project.manager?(current_user) | |||||
| ActiveRecord::Base.transaction do | ActiveRecord::Base.transaction do | ||||
| ProjectUnit.update_by_unit_types!(@project, unit_types) | ProjectUnit.update_by_unit_types!(@project, unit_types) | ||||
| render_ok | render_ok | ||||
| @@ -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("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("versions")) if @project.has_menu_permission("versions") | ||||
| menu.append(menu_hash_by_name("activity")) | 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 | render json: menu | ||||
| end | end | ||||
| @@ -111,7 +111,7 @@ class ProjectsController < ApplicationController | |||||
| end | end | ||||
| def destroy | def destroy | ||||
| if current_user.admin? || @project.owner?(current_user) | |||||
| if current_user.admin? || @project.manager?(current_user) | |||||
| ActiveRecord::Base.transaction do | ActiveRecord::Base.transaction do | ||||
| Gitea::Repository::DeleteService.new(@project.owner, @project.identifier).call | Gitea::Repository::DeleteService.new(@project.owner, @project.identifier).call | ||||
| @project.destroy! | @project.destroy! | ||||
| @@ -28,7 +28,7 @@ module RepositoriesHelper | |||||
| def render_commit_author(author_json) | def render_commit_author(author_json) | ||||
| return nil if author_json.blank? | return nil if author_json.blank? | ||||
| find_user_by_login author_json['login'] | |||||
| find_user_by_login author_json['name'] | |||||
| end | end | ||||
| def readme_render_decode64_content(str, path) | def readme_render_decode64_content(str, path) | ||||
| @@ -1,12 +1,13 @@ | |||||
| # Get a list of all commits from a repository | # Get a list of all commits from a repository | ||||
| class Gitea::Versions::ListService < Gitea::ClientService | 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') | # 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 | @token = token | ||||
| @user_name = user_name | @user_name = user_name | ||||
| @repo = repo | @repo = repo | ||||
| @args = args | |||||
| end | end | ||||
| def call | def call | ||||
| @@ -16,7 +17,7 @@ class Gitea::Versions::ListService < Gitea::ClientService | |||||
| private | private | ||||
| def params | def params | ||||
| Hash.new.merge(token: token) | |||||
| args.merge(token: token) | |||||
| end | end | ||||
| def url | def url | ||||
| @@ -37,7 +37,7 @@ class Repositories::DetailService < ApplicationService | |||||
| end | end | ||||
| def release_suitable | 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 | releases.is_a?(Hash) && releases[:status] == -1 ? [] : releases | ||||
| end | end | ||||
| @@ -1,5 +1,6 @@ | |||||
| json.author do | json.author do | ||||
| if @project.forge? | if @project.forge? | ||||
| json.id user.id | |||||
| json.login user.login | json.login user.login | ||||
| json.type user&.type | json.type user&.type | ||||
| json.name user.real_name | json.name user.real_name | ||||
| @@ -26,9 +26,9 @@ if @project.forge? | |||||
| end | end | ||||
| json.author do | 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 | end | ||||
| json.committer do | 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 | ||||
| end | end | ||||
| @@ -4,5 +4,8 @@ if user | |||||
| json.name user.real_name | json.name user.real_name | ||||
| json.image_url url_to_avatar(user) | json.image_url url_to_avatar(user) | ||||
| else | else | ||||
| json.nil! | |||||
| json.id nil | |||||
| json.login name | |||||
| json.name name | |||||
| json.image_url File.join("avatars/User","b") | |||||
| end | end | ||||
| @@ -5,6 +5,7 @@ else | |||||
| json.total_count @hash_commit[:total_count] | json.total_count @hash_commit[:total_count] | ||||
| json.commits do | json.commits do | ||||
| json.array! @hash_commit[:body] do |commit| | json.array! @hash_commit[:body] do |commit| | ||||
| json.commit1 commit | |||||
| commiter = commit['committer'] | commiter = commit['committer'] | ||||
| if commiter.present? | if commiter.present? | ||||
| commit_user_id = commiter['id'] | commit_user_id = commiter['id'] | ||||
| @@ -17,7 +18,13 @@ else | |||||
| if forge_user | if forge_user | ||||
| json.partial! 'author', user: forge_user | json.partial! 'author', user: forge_user | ||||
| else | 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 | end | ||||
| end | end | ||||
| @@ -61,7 +61,7 @@ json.release_versions do | |||||
| json.tag_name release["tag_name"] | json.tag_name release["tag_name"] | ||||
| json.created_at format_time(release["created_at"].to_time) | json.created_at format_time(release["created_at"].to_time) | ||||
| end | end | ||||
| json.total_count @result[:release].size | |||||
| json.total_count @repository&.version_releases.size | |||||
| end | end | ||||
| json.branches do | json.branches do | ||||
| json.list @result[:branch].each do |branch| | json.list @result[:branch].each do |branch| | ||||
| @@ -93,3 +93,5 @@ json.contributors do | |||||
| json.total_count total_count | json.total_count total_count | ||||
| end | end | ||||
| json.languages @result[:language] | json.languages @result[:language] | ||||
| json.partial! 'author', locals: { user: @project.owner } | |||||
| @@ -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_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) | |||||