diff --git a/app/models/commit.rb b/app/models/commit.rb index 246b8be0c..a6633206a 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -1,5 +1,8 @@ class Commit < ActiveRecord::Base attr_accessible :comments, :committed_on, :committer, :project_id, :repository_id, :version + validates :repository_id, presence: true + validates :version, presence: true, uniqueness: {scope: :repository_id} + validates :committed_on, presence: true has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy after_create :act_as_forge_activity diff --git a/lib/tasks/gitlab_forge_acts_update.rake b/lib/tasks/gitlab_forge_acts_update.rake index 2248f3b87..4d8e9b2fb 100644 --- a/lib/tasks/gitlab_forge_acts_update.rake +++ b/lib/tasks/gitlab_forge_acts_update.rake @@ -5,8 +5,8 @@ namespace :gitlab do ids = [2,847,931,942] projects = Project.find(ids) projects.each do |project| - c = Commit.where(:project_id => project.id) - if c.blank? + # c = Commit.where(:project_id => project.id) + # if c.blank? begin g_project = g.project(project.gpid) # 获取默认分支 @@ -26,7 +26,7 @@ namespace :gitlab do rescue Exception => e puts e end - end + # end end end end