Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop
commit
ce5cf8bf4f
@ -0,0 +1,6 @@
|
||||
class AddTypeToChangeset < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :changesets, :project_id, :integer
|
||||
add_column :changesets, :type, :integer, :default => false
|
||||
end
|
||||
end
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,25 @@
|
||||
namespace :gitlab do
|
||||
desc "sync gitlab's commit acts to trustie"
|
||||
task :forge_acts => :environment do
|
||||
begin
|
||||
g = Gitlab.client
|
||||
projects = Project.find_by_sql("select * from projects where gpid is not null")
|
||||
projects.each do |project|
|
||||
g_project = g.project(project.gpid)
|
||||
# 获取默认分支
|
||||
g_default_branch = g_project.default_branch.nil? ? "master" : g_project.default_branch
|
||||
# 总的提交次数
|
||||
commit_count = g.user_static(project.gpid, :rev => g_default_branch).count
|
||||
pages = commit_count / 20 + 1
|
||||
pages.each do |page|
|
||||
commits = g.commits(g_project.gpid, :ref_name => g_default_branch, :page => page)
|
||||
commits.each do |commit|
|
||||
Changeset.create(:project_id => project.id, :repository_id => project.gpid, :revision => commit.id, :committer => commit.author_email, :comments => Redmine::CodesetUtil.to_utf8(commit.title, 'UTF-8'), :committed_on => commit.created_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
puts e
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in new issue