版本发布的修改

forge
sylor_huang@126.com 5 years ago
parent 966af92b18
commit ebc639e48b

@ -329,7 +329,7 @@ class ApplicationController < ActionController::Base
def current_user def current_user
# User.current # User.current
if Rails.env.development? if Rails.env.development?
user_id = 50207 user_id = 36390
else else
user_id = 130328 user_id = 130328
end end

@ -120,6 +120,8 @@ class PullRequestsController < ApplicationController
attachment = Attachment.select(:id, :container_id, :container_type)&.find_by_id(id) attachment = Attachment.select(:id, :container_id, :container_type)&.find_by_id(id)
unless attachment.blank? unless attachment.blank?
attachment.container = pull_issue attachment.container = pull_issue
attachment.author_id = current_user.id
attachment.description = ""
attachment.save attachment.save
end end
end end
@ -205,6 +207,8 @@ class PullRequestsController < ApplicationController
attachment = Attachment.select(:id, :container_id, :container_type)&.find_by_id(id) attachment = Attachment.select(:id, :container_id, :container_type)&.find_by_id(id)
unless attachment.blank? unless attachment.blank?
attachment.container = @issue attachment.container = @issue
attachment.author_id = current_user.id
attachment.description = ""
attachment.save attachment.save
end end
end end

@ -45,7 +45,6 @@ class VersionReleasesController < ApplicationController
@all_branches.push(b["name"]) @all_branches.push(b["name"])
end end
end end
end end
def create def create
@ -53,6 +52,10 @@ class VersionReleasesController < ApplicationController
normal_status(-1, "名称不能为空") normal_status(-1, "名称不能为空")
elsif params[:tag_name].blank? elsif params[:tag_name].blank?
normal_status(-1, "标签名称不能为空") normal_status(-1, "标签名称不能为空")
elsif VersionRelease.exists?(tag_name: params[:tag_name], repository_id: @repository.id)
normal_status(-1, "该版本已存在")
elsif VersionRelease.exists?(name: params[:name], repository_id: @repository.id)
normal_status(-1, "该版本已存在")
else else
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
@ -60,7 +63,7 @@ class VersionReleasesController < ApplicationController
body: params[:body], body: params[:body],
draft: params[:draft] || false, draft: params[:draft] || false,
name: params[:name], name: params[:name],
prerelease: params[:prerelease], prerelease: params[:prerelease] || false,
tag_name: params[:tag_name], tag_name: params[:tag_name],
target_commitish: params[:target_commitish] || "master" #分支 target_commitish: params[:target_commitish] || "master" #分支
} }

@ -6,4 +6,5 @@ class PullRequest < ApplicationRecord
has_many :pull_request_assigns, foreign_key: :pull_request_id has_many :pull_request_assigns, foreign_key: :pull_request_id
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
end end

@ -2,4 +2,5 @@ class VersionRelease < ApplicationRecord
belongs_to :repository belongs_to :repository
belongs_to :user belongs_to :user
has_many :project_trends, as: :trend, dependent: :destroy has_many :project_trends, as: :trend, dependent: :destroy
# has_many :attachments, as: :container, dependent: :destroy
end end

Loading…
Cancel
Save