From acbd690bc651e266066a1c82a8a0f7d796c8f780 Mon Sep 17 00:00:00 2001
From: guange <8863824@gmail.com>
Date: Sun, 18 Oct 2015 21:04:04 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BD=AC=E6=8D=A2=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/repositories_controller.rb | 18 +++++++++++++++++-
app/views/repositories/to_gitlab.html.erb | 4 ++++
config/routes.rb | 1 +
3 files changed, 22 insertions(+), 1 deletion(-)
create mode 100644 app/views/repositories/to_gitlab.html.erb
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 72af09448..492efbf75 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -32,7 +32,7 @@ class RepositoriesController < ApplicationController
before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo]
before_filter :find_repository, :only => [:edit, :update, :destroy, :committers]
- before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo]
+ before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo,:to_gitlab]
before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue]
before_filter :authorize , :except => [:newrepo,:newcreate,:fork]
accept_rss_auth :revisions
@@ -247,6 +247,16 @@ update
redirect_to settings_project_url(@project, :tab => 'repositories')
end
+ def to_gitlab
+ @project = Project.find(params[:project_id])
+ @repository = Repository.find(params[:id])
+ s = Trustie::Gitlab::Sync.new
+ s.sync_project(@project, path: params[:repo_name], import_url: @repository.url)
+ @repository.type = 'Repository::Gitlab'
+ @repository.save
+ redirect_to :controller => 'repositories', :action => 'show', :id => @project.id, to: 'gitlab'
+ end
+
def show
## TODO: the below will move to filter, done.
if !User.current.member_of?(@project)
@@ -256,6 +266,12 @@ update
end
end
+ unless @repository && @repository.type == 'Repository::Gitlab'
+ # redirect_to to_gitlab_project_repository_path(@project, @repository)
+ render :to_gitlab
+ return
+ end
+
#if( !User.current.member_of?(@project) || @project.hidden_repo)
@repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
diff --git a/app/views/repositories/to_gitlab.html.erb b/app/views/repositories/to_gitlab.html.erb
new file mode 100644
index 000000000..eccf7259d
--- /dev/null
+++ b/app/views/repositories/to_gitlab.html.erb
@@ -0,0 +1,4 @@
+<%= form_for(@repository, url: to_gitlab_project_repository_path(@project, @repository)) do |f| %>
+
+
+<% end %>
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 810c22e7a..7a07c86db 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -533,6 +533,7 @@ RedmineApp::Application.routes.draw do
resources :repositories, :except => [:index, :show] do
member do
get 'newrepo', :via => [:get, :post]
+ put 'to_gitlab'
# get 'create', :via=>[:get, :post]
end
end