commit
5d61d52890
@ -0,0 +1,13 @@
|
||||
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
|
||||
|
||||
# 项目中提交动态
|
||||
def act_as_forge_activity
|
||||
self.forge_acts << ForgeActivity.new(:user_id => 2, :project_id => self.project_id)
|
||||
end
|
||||
end
|
@ -0,0 +1,28 @@
|
||||
<% project = Project.find(activity.project_id) %>
|
||||
<% user = get_user_by_mail(activity.committer) %>
|
||||
<div class="resources mt10">
|
||||
<div class="homepagePostBrief">
|
||||
<div class="homepagePostPortrait">
|
||||
<%= link_to image_tag(url_to_avatar(user), :width => "50", :height => "50"), user_path(user), :alt => "用户头像" %>
|
||||
<%= render :partial => 'users/show_detail_info', :locals => {:user => user} %>
|
||||
</div>
|
||||
<div class="homepagePostDes">
|
||||
<div class="homepagePostTo break_word">
|
||||
<% if user.try(:realname) == ' ' %>
|
||||
<%= link_to user, user_path(user), :class => "newsBlue mr15" %>
|
||||
<% else %>
|
||||
<%= link_to user.try(:realname), user_path(user), :class => "newsBlue mr15" %>
|
||||
<% end %>
|
||||
TO
|
||||
<%= link_to project.to_s+" | 项目代码提交", project_path(project.id,:host=>Setting.host_course), :class => "newsBlue ml15" %>
|
||||
</div>
|
||||
<div class="homepagePostTitle break_word" >
|
||||
<%= link_to activity.comments, {:controller => 'repositories', :action => 'commit_diff', :id => project.id, :changeset => activity.version}, :class => "postGrey" %>
|
||||
</div>
|
||||
<div class="homepagePostDate">
|
||||
提交时间:<%= format_time(activity.committed_on) %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
@ -1,6 +0,0 @@
|
||||
class AddTypeToChangeset < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :changesets, :project_id, :integer
|
||||
add_column :changesets, :type, :integer, :default => false
|
||||
end
|
||||
end
|
@ -0,0 +1,14 @@
|
||||
class CreateCommits < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :commits do |t|
|
||||
t.integer :repository_id
|
||||
t.string :version
|
||||
t.string :committer
|
||||
t.text :comments
|
||||
t.datetime :committed_on
|
||||
t.integer :project_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,18 @@
|
||||
namespace :gitlab do
|
||||
desc "sync gitlab's commit acts to trustie"
|
||||
task :unused => :environment do
|
||||
begin
|
||||
Project.where("id in (161,236,266)").update_all(:gpid => nil)
|
||||
repositories = Repository.find_by_sql("select * from repositories where project_id in (select project_id from repositories group by project_id having count(project_id) > 1);")
|
||||
repositories.each do |rep|
|
||||
puts "#{rep.id}"
|
||||
if rep.type == "Repository::Git"
|
||||
rep.destroy
|
||||
end
|
||||
end
|
||||
# Repository.where("project_id in (161,236,266)").destroy_all
|
||||
rescue Exception => e
|
||||
puts e
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,11 @@
|
||||
FactoryGirl.define do
|
||||
factory :commit do
|
||||
repository_id 1
|
||||
version "MyString"
|
||||
committer "MyString"
|
||||
comments "MyText"
|
||||
committed_on "2016-07-21"
|
||||
project_id 1
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Commit, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in new issue