Browse Source

fix bug

tags/v3.0.2
jasder 5 years ago
parent
commit
860b46685a
11 changed files with 162 additions and 13 deletions
  1. +1
    -1
      app/controllers/projects/project_units_controller.rb
  2. +2
    -2
      app/controllers/projects_controller.rb
  3. +1
    -1
      app/helpers/repositories_helper.rb
  4. +4
    -3
      app/services/gitea/versions/list_service.rb
  5. +1
    -1
      app/services/repositories/detail_service.rb
  6. +1
    -0
      app/views/repositories/_author.json.jbuilder
  7. +2
    -2
      app/views/repositories/_commit.json.jbuilder
  8. +4
    -1
      app/views/repositories/_commit_author.json.jbuilder
  9. +8
    -1
      app/views/repositories/commits.json.jbuilder
  10. +3
    -1
      app/views/repositories/detail.json.jbuilder
  11. +135
    -0
      dir.md

+ 1
- 1
app/controllers/projects/project_units_controller.rb View File

@@ -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


+ 2
- 2
app/controllers/projects_controller.rb View File

@@ -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
@@ -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!


+ 1
- 1
app/helpers/repositories_helper.rb View File

@@ -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)


+ 4
- 3
app/services/gitea/versions/list_service.rb View File

@@ -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


+ 1
- 1
app/services/repositories/detail_service.rb View File

@@ -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



+ 1
- 0
app/views/repositories/_author.json.jbuilder View File

@@ -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


+ 2
- 2
app/views/repositories/_commit.json.jbuilder View File

@@ -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

+ 4
- 1
app/views/repositories/_commit_author.json.jbuilder View File

@@ -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

+ 8
- 1
app/views/repositories/commits.json.jbuilder View File

@@ -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


+ 3
- 1
app/views/repositories/detail.json.jbuilder View File

@@ -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 }

+ 135
- 0
dir.md View File

@@ -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)

Loading…
Cancel
Save