添加转换页面
This commit is contained in:
parent
f1af041f24
commit
acbd690bc6
|
@ -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?
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<%= form_for(@repository, url: to_gitlab_project_repository_path(@project, @repository)) do |f| %>
|
||||
<input type="text" name="repo_name"/>
|
||||
<button type="submit">转换到新版本</button>
|
||||
<% end %>
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue