From ebc639e48b207c41e28d6961635a6079480d1f57 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Wed, 26 Feb 2020 10:28:26 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=91=E5=B8=83=E7=9A=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- app/controllers/pull_requests_controller.rb | 4 ++++ app/controllers/version_releases_controller.rb | 7 +++++-- app/models/pull_request.rb | 1 + app/models/version_release.rb | 1 + 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index cb39a24f7..fe77a99f7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -329,7 +329,7 @@ class ApplicationController < ActionController::Base def current_user # User.current if Rails.env.development? - user_id = 50207 + user_id = 36390 else user_id = 130328 end diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 886f597cb..6ae5f76c2 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -120,6 +120,8 @@ class PullRequestsController < ApplicationController attachment = Attachment.select(:id, :container_id, :container_type)&.find_by_id(id) unless attachment.blank? attachment.container = pull_issue + attachment.author_id = current_user.id + attachment.description = "" attachment.save end end @@ -205,6 +207,8 @@ class PullRequestsController < ApplicationController attachment = Attachment.select(:id, :container_id, :container_type)&.find_by_id(id) unless attachment.blank? attachment.container = @issue + attachment.author_id = current_user.id + attachment.description = "" attachment.save end end diff --git a/app/controllers/version_releases_controller.rb b/app/controllers/version_releases_controller.rb index 5a1b76969..aad21c51c 100644 --- a/app/controllers/version_releases_controller.rb +++ b/app/controllers/version_releases_controller.rb @@ -45,7 +45,6 @@ class VersionReleasesController < ApplicationController @all_branches.push(b["name"]) end end - end def create @@ -53,6 +52,10 @@ class VersionReleasesController < ApplicationController normal_status(-1, "名称不能为空") elsif params[:tag_name].blank? 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 ActiveRecord::Base.transaction do begin @@ -60,7 +63,7 @@ class VersionReleasesController < ApplicationController body: params[:body], draft: params[:draft] || false, name: params[:name], - prerelease: params[:prerelease], + prerelease: params[:prerelease] || false, tag_name: params[:tag_name], target_commitish: params[:target_commitish] || "master" #分支 } diff --git a/app/models/pull_request.rb b/app/models/pull_request.rb index 1c41f6a46..7445cc518 100644 --- a/app/models/pull_request.rb +++ b/app/models/pull_request.rb @@ -6,4 +6,5 @@ class PullRequest < ApplicationRecord has_many :pull_request_assigns, 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 :attachments, as: :container, dependent: :destroy end diff --git a/app/models/version_release.rb b/app/models/version_release.rb index 89907c613..01db9eda6 100644 --- a/app/models/version_release.rb +++ b/app/models/version_release.rb @@ -2,4 +2,5 @@ class VersionRelease < ApplicationRecord belongs_to :repository belongs_to :user has_many :project_trends, as: :trend, dependent: :destroy + # has_many :attachments, as: :container, dependent: :destroy end