ADD pr冲突文件展示
This commit is contained in:
commit
c298ff02b8
|
@ -91,7 +91,7 @@ class PullRequestsController < ApplicationController
|
||||||
if @issue.update_attributes(@issue_params)
|
if @issue.update_attributes(@issue_params)
|
||||||
if @pull_request.update_attributes(@local_params.compact)
|
if @pull_request.update_attributes(@local_params.compact)
|
||||||
gitea_pull = Gitea::PullRequest::UpdateService.call(@owner.login, @repository.identifier,
|
gitea_pull = Gitea::PullRequest::UpdateService.call(@owner.login, @repository.identifier,
|
||||||
@pull_request.gpid, @requests_params, current_user.gitea_token)
|
@pull_request.gitea_number, @requests_params, current_user.gitea_token)
|
||||||
|
|
||||||
if gitea_pull[:status] === :success
|
if gitea_pull[:status] === :success
|
||||||
if params[:issue_tag_ids].present?
|
if params[:issue_tag_ids].present?
|
||||||
|
@ -139,7 +139,7 @@ class PullRequestsController < ApplicationController
|
||||||
@issue_user = @issue.user
|
@issue_user = @issue.user
|
||||||
@issue_assign_to = @issue.get_assign_user
|
@issue_assign_to = @issue.get_assign_user
|
||||||
@gitea_pull = Gitea::PullRequest::GetService.call(@owner.login,
|
@gitea_pull = Gitea::PullRequest::GetService.call(@owner.login,
|
||||||
@repository.identifier, @pull_request.gpid, current_user&.gitea_token)
|
@repository.identifier, @pull_request.gitea_number, current_user&.gitea_token)
|
||||||
end
|
end
|
||||||
|
|
||||||
def pr_merge
|
def pr_merge
|
||||||
|
@ -191,12 +191,12 @@ class PullRequestsController < ApplicationController
|
||||||
|
|
||||||
|
|
||||||
def files
|
def files
|
||||||
@files_result = Gitea::PullRequest::FilesService.call(@owner.login, @project.identifier, @pull_request.gpid, current_user&.gitea_token)
|
@files_result = Gitea::PullRequest::FilesService.call(@owner.login, @project.identifier, @pull_request.gitea_number, current_user&.gitea_token)
|
||||||
# render json: @files_result
|
# render json: @files_result
|
||||||
end
|
end
|
||||||
|
|
||||||
def commits
|
def commits
|
||||||
@commits_result = Gitea::PullRequest::CommitsService.call(@owner.login, @project.identifier, @pull_request.gpid, current_user&.gitea_token)
|
@commits_result = Gitea::PullRequest::CommitsService.call(@owner.login, @project.identifier, @pull_request.gitea_number, current_user&.gitea_token)
|
||||||
# render json: @commits_result
|
# render json: @commits_result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,26 @@
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: applied_messages
|
# Table name: forge_applied_messages
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# user_id :integer
|
# user_id :integer
|
||||||
# applied_id :integer
|
|
||||||
# applied_type :string(255)
|
# applied_type :string(255)
|
||||||
|
# applied_id :integer
|
||||||
# viewed :integer default("0")
|
# viewed :integer default("0")
|
||||||
# status :integer default("0")
|
# status :integer default("0")
|
||||||
# created_at :datetime not null
|
|
||||||
# updated_at :datetime not null
|
|
||||||
# name :string(255)
|
# name :string(255)
|
||||||
# applied_user_id :integer
|
# applied_user_id :integer
|
||||||
# role :integer
|
# role :integer
|
||||||
# project_id :integer
|
# project_id :integer
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_forge_applied_messages_on_applied_type_and_applied_id (applied_type,applied_id)
|
||||||
|
# index_forge_applied_messages_on_applied_user_id (applied_user_id)
|
||||||
|
# index_forge_applied_messages_on_project_id (project_id)
|
||||||
|
# index_forge_applied_messages_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class AppliedMessage < ApplicationRecord
|
class AppliedMessage < ApplicationRecord
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: applied_projects
|
# Table name: forge_applied_projects
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# project_id :integer not null
|
# project_id :integer
|
||||||
# user_id :integer not null
|
# user_id :integer
|
||||||
# role :integer default("0")
|
# role :integer default("0")
|
||||||
# status :integer default("0")
|
# status :integer default("0")
|
||||||
# created_at :datetime
|
# created_at :datetime not null
|
||||||
# updated_at :datetime
|
# updated_at :datetime not null
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_forge_applied_projects_on_project_id (project_id)
|
||||||
|
# index_forge_applied_projects_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class AppliedProject < ApplicationRecord
|
class AppliedProject < ApplicationRecord
|
||||||
|
|
|
@ -1,41 +1,42 @@
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: attachments
|
# Table name: attachments
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# container_id :integer
|
# container_id :integer
|
||||||
# container_type :string(30)
|
# container_type :string(30)
|
||||||
# filename :string(255) default(""), not null
|
# filename :string(255) default(""), not null
|
||||||
# disk_filename :string(255) default(""), not null
|
# disk_filename :string(255) default(""), not null
|
||||||
# filesize :integer default("0"), not null
|
# filesize :integer default("0"), not null
|
||||||
# content_type :string(255) default("")
|
# content_type :string(255) default("")
|
||||||
# digest :string(60) default(""), not null
|
# digest :string(60) default(""), not null
|
||||||
# downloads :integer default("0"), not null
|
# downloads :integer default("0"), not null
|
||||||
# author_id :integer default("0"), not null
|
# author_id :integer default("0"), not null
|
||||||
# created_on :datetime
|
# created_on :datetime
|
||||||
# description :text(65535)
|
# description :text(65535)
|
||||||
# disk_directory :string(255)
|
# disk_directory :string(255)
|
||||||
# attachtype :integer default("1")
|
# attachtype :integer default("1")
|
||||||
# is_public :integer default("1")
|
# is_public :integer default("1")
|
||||||
# copy_from :integer
|
# copy_from :string(255)
|
||||||
# quotes :integer default("0")
|
# quotes :integer default("0")
|
||||||
# is_publish :integer default("1")
|
# is_publish :integer default("1")
|
||||||
# publish_time :datetime
|
# publish_time :datetime
|
||||||
# resource_bank_id :integer
|
# resource_bank_id :integer
|
||||||
# unified_setting :boolean default("1")
|
# unified_setting :boolean default("1")
|
||||||
# cloud_url :string(255) default("")
|
# cloud_url :string(255) default("")
|
||||||
# course_second_category_id :integer default("0")
|
# course_second_category_id :integer default("0")
|
||||||
# delay_publish :boolean default("0")
|
# delay_publish :boolean default("0")
|
||||||
#
|
# link :string(255)
|
||||||
# Indexes
|
# clone_id :integer
|
||||||
#
|
#
|
||||||
# index_attachments_on_author_id (author_id)
|
# Indexes
|
||||||
# index_attachments_on_container_id_and_container_type (container_id,container_type)
|
#
|
||||||
# index_attachments_on_course_second_category_id (course_second_category_id)
|
# index_attachments_on_author_id (author_id)
|
||||||
# index_attachments_on_created_on (created_on)
|
# index_attachments_on_clone_id (clone_id)
|
||||||
# index_attachments_on_is_public (is_public)
|
# index_attachments_on_container_id_and_container_type (container_id,container_type)
|
||||||
# index_attachments_on_quotes (quotes)
|
# index_attachments_on_created_on (created_on)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Attachment < ApplicationRecord
|
class Attachment < ApplicationRecord
|
||||||
|
|
|
@ -39,17 +39,15 @@
|
||||||
# business :boolean default("0")
|
# business :boolean default("0")
|
||||||
# profile_completed :boolean default("0")
|
# profile_completed :boolean default("0")
|
||||||
# laboratory_id :integer
|
# laboratory_id :integer
|
||||||
# platform :string(255) default("0")
|
|
||||||
# gitea_token :string(255)
|
|
||||||
# gitea_uid :integer
|
|
||||||
# is_shixun_marker :boolean default("0")
|
# is_shixun_marker :boolean default("0")
|
||||||
|
# admin_visitable :boolean default("0")
|
||||||
|
# collaborator :boolean default("0")
|
||||||
|
# gitea_uid :integer
|
||||||
# is_sync_pwd :boolean default("1")
|
# is_sync_pwd :boolean default("1")
|
||||||
# watchers_count :integer default("0")
|
# watchers_count :integer default("0")
|
||||||
# devops_step :integer default("0")
|
# devops_step :integer default("0")
|
||||||
# sponsor_certification :integer default("0")
|
# gitea_token :string(255)
|
||||||
# sponsor_num :integer default("0")
|
# platform :string(255)
|
||||||
# sponsored_num :integer default("0")
|
|
||||||
# award_time :datetime
|
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
|
@ -57,8 +55,9 @@
|
||||||
# index_users_on_homepage_engineer (homepage_engineer)
|
# index_users_on_homepage_engineer (homepage_engineer)
|
||||||
# index_users_on_homepage_teacher (homepage_teacher)
|
# index_users_on_homepage_teacher (homepage_teacher)
|
||||||
# index_users_on_laboratory_id (laboratory_id)
|
# index_users_on_laboratory_id (laboratory_id)
|
||||||
# index_users_on_login (login)
|
# index_users_on_login (login) UNIQUE
|
||||||
# index_users_on_mail (mail)
|
# index_users_on_mail (mail) UNIQUE
|
||||||
|
# index_users_on_phone (phone) UNIQUE
|
||||||
# index_users_on_type (type)
|
# index_users_on_type (type)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
class Gitea::Base < Gitea::Database
|
class Gitea::Base < ApplicationRecord
|
||||||
self.abstract_class = true
|
db_config = Rails.configuration.database_configuration[Rails.env]["gitea_server"]
|
||||||
|
raise 'gitea database config missing' if db_config.blank?
|
||||||
|
|
||||||
|
establish_connection db_config
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: pull_request
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# type :integer
|
||||||
|
# status :integer
|
||||||
|
# conflicted_files :text(65535)
|
||||||
|
# commits_ahead :integer
|
||||||
|
# commits_behind :integer
|
||||||
|
# changed_protected_files :text(65535)
|
||||||
|
# issue_id :integer
|
||||||
|
# index :integer
|
||||||
|
# head_repo_id :integer
|
||||||
|
# base_repo_id :integer
|
||||||
|
# head_branch :string(255)
|
||||||
|
# base_branch :string(255)
|
||||||
|
# merge_base :string(40)
|
||||||
|
# has_merged :boolean
|
||||||
|
# merged_commit_id :string(40)
|
||||||
|
# merger_id :integer
|
||||||
|
# merged_unix :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# IDX_pull_request_base_repo_id (base_repo_id)
|
||||||
|
# IDX_pull_request_has_merged (has_merged)
|
||||||
|
# IDX_pull_request_head_repo_id (head_repo_id)
|
||||||
|
# IDX_pull_request_issue_id (issue_id)
|
||||||
|
# IDX_pull_request_merged_unix (merged_unix)
|
||||||
|
# IDX_pull_request_merger_id (merger_id)
|
||||||
|
#
|
||||||
|
|
||||||
|
class Gitea::Pull < Gitea::Base
|
||||||
|
self.inheritance_column = nil # FIX The single-table inheritance mechanism failed
|
||||||
|
# establish_connection :gitea_db
|
||||||
|
|
||||||
|
self.table_name = "pull_request"
|
||||||
|
|
||||||
|
serialize :conflicted_files, Array
|
||||||
|
|
||||||
|
belongs_to :pull_request, class_name: '::PullRequest', foreign_key: :id, primary_key: :gitea_number, optional: true
|
||||||
|
|
||||||
|
end
|
|
@ -10,6 +10,7 @@
|
||||||
# sync_course :boolean default("0")
|
# sync_course :boolean default("0")
|
||||||
# sync_subject :boolean default("0")
|
# sync_subject :boolean default("0")
|
||||||
# sync_shixun :boolean default("0")
|
# sync_shixun :boolean default("0")
|
||||||
|
# is_local :boolean default("0")
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
# content :text(65535)
|
# content :text(65535)
|
||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
# is_secret :boolean default("0")
|
|
||||||
#
|
#
|
||||||
|
|
||||||
class License < ApplicationRecord
|
class License < ApplicationRecord
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
# course_group_id :integer default("0")
|
# course_group_id :integer default("0")
|
||||||
# is_collect :integer default("1")
|
# is_collect :integer default("1")
|
||||||
# graduation_group_id :integer default("0")
|
# graduation_group_id :integer default("0")
|
||||||
# is_apply_signature :boolean default("0")
|
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
|
|
|
@ -39,17 +39,15 @@
|
||||||
# business :boolean default("0")
|
# business :boolean default("0")
|
||||||
# profile_completed :boolean default("0")
|
# profile_completed :boolean default("0")
|
||||||
# laboratory_id :integer
|
# laboratory_id :integer
|
||||||
# platform :string(255) default("0")
|
|
||||||
# gitea_token :string(255)
|
|
||||||
# gitea_uid :integer
|
|
||||||
# is_shixun_marker :boolean default("0")
|
# is_shixun_marker :boolean default("0")
|
||||||
|
# admin_visitable :boolean default("0")
|
||||||
|
# collaborator :boolean default("0")
|
||||||
|
# gitea_uid :integer
|
||||||
# is_sync_pwd :boolean default("1")
|
# is_sync_pwd :boolean default("1")
|
||||||
# watchers_count :integer default("0")
|
# watchers_count :integer default("0")
|
||||||
# devops_step :integer default("0")
|
# devops_step :integer default("0")
|
||||||
# sponsor_certification :integer default("0")
|
# gitea_token :string(255)
|
||||||
# sponsor_num :integer default("0")
|
# platform :string(255)
|
||||||
# sponsored_num :integer default("0")
|
|
||||||
# award_time :datetime
|
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
|
@ -57,8 +55,9 @@
|
||||||
# index_users_on_homepage_engineer (homepage_engineer)
|
# index_users_on_homepage_engineer (homepage_engineer)
|
||||||
# index_users_on_homepage_teacher (homepage_teacher)
|
# index_users_on_homepage_teacher (homepage_teacher)
|
||||||
# index_users_on_laboratory_id (laboratory_id)
|
# index_users_on_laboratory_id (laboratory_id)
|
||||||
# index_users_on_login (login)
|
# index_users_on_login (login) UNIQUE
|
||||||
# index_users_on_mail (mail)
|
# index_users_on_mail (mail) UNIQUE
|
||||||
|
# index_users_on_phone (phone) UNIQUE
|
||||||
# index_users_on_type (type)
|
# index_users_on_type (type)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,6 @@
|
||||||
# rep_identifier :string(255)
|
# rep_identifier :string(255)
|
||||||
# project_category_id :integer
|
# project_category_id :integer
|
||||||
# project_language_id :integer
|
# project_language_id :integer
|
||||||
# license_id :integer
|
|
||||||
# ignore_id :integer
|
|
||||||
# praises_count :integer default("0")
|
# praises_count :integer default("0")
|
||||||
# watchers_count :integer default("0")
|
# watchers_count :integer default("0")
|
||||||
# issues_count :integer default("0")
|
# issues_count :integer default("0")
|
||||||
|
@ -52,9 +50,10 @@
|
||||||
# open_devops_count :integer default("0")
|
# open_devops_count :integer default("0")
|
||||||
# recommend :boolean default("0")
|
# recommend :boolean default("0")
|
||||||
# platform :integer default("0")
|
# platform :integer default("0")
|
||||||
|
# license_id :integer
|
||||||
|
# ignore_id :integer
|
||||||
# default_branch :string(255) default("master")
|
# default_branch :string(255) default("master")
|
||||||
# website :string(255)
|
# website :string(255)
|
||||||
# order_index :integer default("0")
|
|
||||||
# lesson_url :string(255)
|
# lesson_url :string(255)
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
|
|
|
@ -8,11 +8,6 @@
|
||||||
# projects_count :integer default("0")
|
# projects_count :integer default("0")
|
||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
# ancestry :string(255)
|
|
||||||
#
|
|
||||||
# Indexes
|
|
||||||
#
|
|
||||||
# index_project_categories_on_ancestry (ancestry)
|
|
||||||
#
|
#
|
||||||
|
|
||||||
class ProjectCategory < ApplicationRecord
|
class ProjectCategory < ApplicationRecord
|
||||||
|
|
|
@ -37,6 +37,7 @@ class PullRequest < ApplicationRecord
|
||||||
has_many :pull_request_tags, foreign_key: :pull_request_id
|
has_many :pull_request_tags, foreign_key: :pull_request_id
|
||||||
has_many :project_trends, as: :trend, dependent: :destroy
|
has_many :project_trends, as: :trend, dependent: :destroy
|
||||||
has_many :attachments, as: :container, dependent: :destroy
|
has_many :attachments, as: :container, dependent: :destroy
|
||||||
|
has_one :gitea_pull, foreign_key: :id, primary_key: :gitea_number, class_name: 'Gitea::Pull'
|
||||||
|
|
||||||
scope :merged_and_closed, ->{where.not(status: 0)}
|
scope :merged_and_closed, ->{where.not(status: 0)}
|
||||||
scope :opening, -> {where(status: 0)}
|
scope :opening, -> {where(status: 0)}
|
||||||
|
@ -54,7 +55,7 @@ class PullRequest < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def bind_gitea_pull_request!(gitea_pull_number)
|
def bind_gitea_pull_request!(gitea_pull_number)
|
||||||
update_column(:gpid, gitea_pull_number)
|
update_column(:gitea_number, gitea_pull_number)
|
||||||
end
|
end
|
||||||
|
|
||||||
def merge!
|
def merge!
|
||||||
|
@ -67,19 +68,26 @@ class PullRequest < ApplicationRecord
|
||||||
|
|
||||||
# TODO: sync educoder platform repo's for update some statistics count
|
# TODO: sync educoder platform repo's for update some statistics count
|
||||||
def self.update_some_count
|
def self.update_some_count
|
||||||
PullRequest.includes(:user, :project).select(:id, :user_id, :gpid, :project_id, :fork_project_id).each do |pr|
|
PullRequest.includes(:user, :project).select(:id, :user_id, :gitea_number, :project_id, :fork_project_id).each do |pr|
|
||||||
puts pr.id
|
puts pr.id
|
||||||
next if pr.gpid.blank?
|
next if pr.gitea_number.blank?
|
||||||
project = pr.project
|
project = pr.project
|
||||||
|
|
||||||
next if project.blank?
|
next if project.blank?
|
||||||
user = project.owner
|
user = project.owner
|
||||||
next if pr.gpid === 6 || pr.gpid === 7
|
next if pr.gitea_number === 6 || pr.gitea_number === 7
|
||||||
files_result = Gitea::PullRequest::FilesService.call(user.login, project.identifier, pr.gpid)
|
files_result = Gitea::PullRequest::FilesService.call(user.login, project.identifier, pr.gitea_number)
|
||||||
pr.update_column(:files_count, files_result['NumFiles']) unless files_result.blank?
|
pr.update_column(:files_count, files_result['NumFiles']) unless files_result.blank?
|
||||||
|
|
||||||
commits_result = Gitea::PullRequest::CommitsService.call(user.login, project.identifier, pr.gpid)
|
commits_result = Gitea::PullRequest::CommitsService.call(user.login, project.identifier, pr.gitea_number)
|
||||||
pr.update_column(:commits_count, commits_result.size) unless commits_result.blank?
|
pr.update_column(:commits_count, commits_result.size) unless commits_result.blank?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def conflict_files
|
||||||
|
file_names = self&.gitea_pull&.conflicted_files
|
||||||
|
return [] if file_names.blank?
|
||||||
|
|
||||||
|
JSON.parse file_names
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
# index_repositories_on_identifier (identifier)
|
|
||||||
# index_repositories_on_project_id (project_id)
|
# index_repositories_on_project_id (project_id)
|
||||||
# index_repositories_on_user_id (user_id)
|
# index_repositories_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
|
@ -39,17 +39,15 @@
|
||||||
# business :boolean default("0")
|
# business :boolean default("0")
|
||||||
# profile_completed :boolean default("0")
|
# profile_completed :boolean default("0")
|
||||||
# laboratory_id :integer
|
# laboratory_id :integer
|
||||||
# platform :string(255) default("0")
|
|
||||||
# gitea_token :string(255)
|
|
||||||
# gitea_uid :integer
|
|
||||||
# is_shixun_marker :boolean default("0")
|
# is_shixun_marker :boolean default("0")
|
||||||
|
# admin_visitable :boolean default("0")
|
||||||
|
# collaborator :boolean default("0")
|
||||||
|
# gitea_uid :integer
|
||||||
# is_sync_pwd :boolean default("1")
|
# is_sync_pwd :boolean default("1")
|
||||||
# watchers_count :integer default("0")
|
# watchers_count :integer default("0")
|
||||||
# devops_step :integer default("0")
|
# devops_step :integer default("0")
|
||||||
# sponsor_certification :integer default("0")
|
# gitea_token :string(255)
|
||||||
# sponsor_num :integer default("0")
|
# platform :string(255)
|
||||||
# sponsored_num :integer default("0")
|
|
||||||
# award_time :datetime
|
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
|
@ -57,8 +55,9 @@
|
||||||
# index_users_on_homepage_engineer (homepage_engineer)
|
# index_users_on_homepage_engineer (homepage_engineer)
|
||||||
# index_users_on_homepage_teacher (homepage_teacher)
|
# index_users_on_homepage_teacher (homepage_teacher)
|
||||||
# index_users_on_laboratory_id (laboratory_id)
|
# index_users_on_laboratory_id (laboratory_id)
|
||||||
# index_users_on_login (login)
|
# index_users_on_login (login) UNIQUE
|
||||||
# index_users_on_mail (mail)
|
# index_users_on_mail (mail) UNIQUE
|
||||||
|
# index_users_on_phone (phone) UNIQUE
|
||||||
# index_users_on_type (type)
|
# index_users_on_type (type)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,9 @@
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
# index_user_actions_on_ip (ip)
|
# index_user_actions_on_ip (ip)
|
||||||
|
# index_user_actions_on_user_id (user_id)
|
||||||
|
# index_user_actions_on_user_id_and_action_type (user_id,action_type)
|
||||||
#
|
#
|
||||||
|
|
||||||
class UserAction < ApplicationRecord
|
class UserAction < ApplicationRecord
|
||||||
|
|
|
@ -10,10 +10,13 @@
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
# register_status :integer default("0")
|
# register_status :integer default("0")
|
||||||
# action_status :integer default("0")
|
# action_status :integer default("0")
|
||||||
|
# is_delete :boolean default("0")
|
||||||
|
# user_id :integer
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
# index_user_agents_on_ip (ip) UNIQUE
|
# index_user_agents_on_ip (ip)
|
||||||
|
# index_user_agents_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class UserAgent < ApplicationRecord
|
class UserAgent < ApplicationRecord
|
||||||
|
|
|
@ -22,6 +22,9 @@
|
||||||
# school_id :integer
|
# school_id :integer
|
||||||
# description :string(255) default("")
|
# description :string(255) default("")
|
||||||
# department_id :integer
|
# department_id :integer
|
||||||
|
# honor :text(65535)
|
||||||
|
# edu_background :integer
|
||||||
|
# edu_entry_year :integer
|
||||||
# province :string(255)
|
# province :string(255)
|
||||||
# city :string(255)
|
# city :string(255)
|
||||||
# custom_department :string(255)
|
# custom_department :string(255)
|
||||||
|
|
|
@ -8,7 +8,7 @@ class Gitea::PullRequest::CloseService < Gitea::PullRequest::UpdateService
|
||||||
# number: number of pull request
|
# number: number of pull request
|
||||||
# token: token of gitea user
|
# token: token of gitea user
|
||||||
# eq:
|
# eq:
|
||||||
# Gitea::PullRequest::CloseService.call(owner.login, repo.identifier, pull.gpid, pull.base, current_user.gitea_token)
|
# Gitea::PullRequest::CloseService.call(owner.login, repo.identifier, pull.gitea_number, pull.base, current_user.gitea_token)
|
||||||
def initialize(owner, repo, number, base,token=nil)
|
def initialize(owner, repo, number, base,token=nil)
|
||||||
colse_pull_params = Hash.new.merge(base: base, state: 'closed').compact
|
colse_pull_params = Hash.new.merge(base: base, state: 'closed').compact
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ class Gitea::PullRequest::GetService < Gitea::ClientService
|
||||||
attr_reader :owner, :repo, :number, :token
|
attr_reader :owner, :repo, :number, :token
|
||||||
|
|
||||||
#eq:
|
#eq:
|
||||||
# Gitea::PullRequest::GetService.call(user.login, repository.identifier, pull.gpid, user.gitea_token)
|
# Gitea::PullRequest::GetService.call(user.login, repository.identifier, pull.gitea_number, user.gitea_token)
|
||||||
def initialize(owner, repo, number, token=nil)
|
def initialize(owner, repo, number, token=nil)
|
||||||
@owner = owner
|
@owner = owner
|
||||||
@repo = repo
|
@repo = repo
|
||||||
|
|
|
@ -8,7 +8,7 @@ class Gitea::PullRequest::OpenService < Gitea::PullRequest::UpdateService
|
||||||
# number: number of pull request
|
# number: number of pull request
|
||||||
# token: token of gitea user
|
# token: token of gitea user
|
||||||
# eq:
|
# eq:
|
||||||
# Gitea::PullRequest::OpenService.new(owner.login, repo.identifier, pr.gpid, pr.base, current_user.gitea_token)
|
# Gitea::PullRequest::OpenService.new(owner.login, repo.identifier, pr.gitea_number, pr.base, current_user.gitea_token)
|
||||||
def initialize(owner, repo, number, base, token=nil)
|
def initialize(owner, repo, number, base, token=nil)
|
||||||
open_pull_params = Hash.new.merge(base: base, state: 'open').compact
|
open_pull_params = Hash.new.merge(base: base, state: 'open').compact
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ class PullRequests::CloseService < ApplicationService
|
||||||
|
|
||||||
def close_gitea_pull
|
def close_gitea_pull
|
||||||
Gitea::PullRequest::CloseService.call(@owner.login, @repo.identifier,
|
Gitea::PullRequest::CloseService.call(@owner.login, @repo.identifier,
|
||||||
@pull.gpid, @pull.base, current_user.gitea_token)
|
@pull.gitea_number, @pull.base, current_user.gitea_token)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_pull_status!
|
def update_pull_status!
|
||||||
|
|
|
@ -22,7 +22,7 @@ class PullRequests::MergeService < ApplicationService
|
||||||
|
|
||||||
def gitea_pull_merge!
|
def gitea_pull_merge!
|
||||||
result = Gitea::PullRequest::MergeService.call(@current_user.gitea_token, @owner.login,
|
result = Gitea::PullRequest::MergeService.call(@current_user.gitea_token, @owner.login,
|
||||||
@repo.identifier, @pull.gpid, gitea_merge_pull_params)
|
@repo.identifier, @pull.gitea_number, gitea_merge_pull_params)
|
||||||
@status, @message = result
|
@status, @message = result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ class PullRequests::OpenService < ApplicationService
|
||||||
|
|
||||||
def open_gitea_pull
|
def open_gitea_pull
|
||||||
Gitea::PullRequest::OpenService.call(@owner.login, @repo.identifier,
|
Gitea::PullRequest::OpenService.call(@owner.login, @repo.identifier,
|
||||||
@pull.gpid, @pull.base, @current_user.gitea_token)
|
@pull.gitea_number, @pull.base, @current_user.gitea_token)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_pull_status!
|
def update_pull_status!
|
||||||
|
|
|
@ -32,3 +32,5 @@ json.issue do
|
||||||
json.version @issue.version.try(:name)
|
json.version @issue.version.try(:name)
|
||||||
json.issue_tags @issue.get_issue_tags
|
json.issue_tags @issue.get_issue_tags
|
||||||
end
|
end
|
||||||
|
|
||||||
|
json.conflict_files @pull_request.conflict_files
|
||||||
|
|
|
@ -17,6 +17,13 @@ default: &default
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
# socket: /var/run/mysqld/mysqld.sock
|
# socket: /var/run/mysqld/mysqld.sock
|
||||||
|
gitea_server:
|
||||||
|
aadapter: mysql2
|
||||||
|
database: gitea_development
|
||||||
|
host: 127.0.0.1
|
||||||
|
username: root
|
||||||
|
password: "123456"
|
||||||
|
encoding: utf8
|
||||||
|
|
||||||
development:
|
development:
|
||||||
<<: *default
|
<<: *default
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
class ChangeColumnsNameFromPullRequests < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
rename_column :pull_requests, :pull_request_id, :gitea_id
|
||||||
|
rename_column :pull_requests, :gpid, :gitea_number
|
||||||
|
|
||||||
|
|
||||||
|
PullRequest.find_each do |pr|
|
||||||
|
next if pr.gitea_number.blank?
|
||||||
|
|
||||||
|
project = pr.project
|
||||||
|
next if project.blank?
|
||||||
|
|
||||||
|
owner = project&.owner
|
||||||
|
gitea_pull = Gitea::PullRequest::GetService.call(owner.login, project.identifier, pr.gitea_number, owner&.gitea_token)
|
||||||
|
|
||||||
|
next if gitea_pull.blank?
|
||||||
|
|
||||||
|
pr.update_column(:gitea_id, gitea_pull["id"])
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue