diff --git a/Gemfile b/Gemfile index d392c6561..789c2011e 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,8 @@ unless RUBY_PLATFORM =~ /w32/ gem 'iconv' end +gem 'net-ssh' + gem 'certified' gem 'wechat',path: 'lib/wechat' diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 857f98afc..b2bf7b42d 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -30,11 +30,11 @@ class RepositoriesController < ApplicationController menu_item :settings, :only => [:new, :create, :edit, :update, :destroy, :committers] default_search_scope :changesets - before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats] + before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats, :quality_analyses] before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked, :project_archive] before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue] - before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :commit_diff, :project_archive] + before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :commit_diff, :project_archive, :quality_analyses] accept_rss_auth :revisions # hidden repositories filter // 隐藏代码过滤器 before_filter :check_hidden_repo, :only => [:show, :stats, :revisions, :revision, :diff ] @@ -43,6 +43,7 @@ class RepositoriesController < ApplicationController helper :project_score #@root_path = RepositoriesHelper::ROOT_PATH $g=Gitlab.client + require 'net/ssh' rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed def new @@ -306,6 +307,27 @@ update end end + def quality_analyses + host = "192.168.0.200" + port = "1125" + username = "git" + password = "123123" + ##显示文件和系统版本 + server_cmd1 = 'll' + server_cmd2 = 'cat /etc/issue' + # 连接到远程主机 foobar + ssh = Net::SSH.start(host, username, :port => port, :password => password) do |ssh| + result = ssh.exec!(server_cmd1) + logger.error("#################") + puts result + result = ssh.exec!(server_cmd2) + puts result + end + respond_to do |format| + format.html + end + end + def destroy DestroyRepositoryTask.new.destroy(User.current.id, @repository.id) @repository.hidden = true @@ -557,6 +579,24 @@ update render 404 return end + host = "http://192.168.0.200:8893" + username = "git" + password = "123123" + +##显示文件和系统版本 + server_cmd1 = 'ls -l' + server_cmd2 = 'cat /etc/issue' + + +# 连接到远程主机 foobar + ssh = Net::SSH.start(host, username, :password => password) do |ssh| + result = ssh.exec!(server_cmd1) + puts result + result = ssh.exec!(server_cmd2) + puts result + end + + project_id = @project.gpid # @repository_id = @repository.identifier # creator = params[:creator] diff --git a/app/views/repositories/quality_analyses.html.erb b/app/views/repositories/quality_analyses.html.erb new file mode 100644 index 000000000..30d74d258 --- /dev/null +++ b/app/views/repositories/quality_analyses.html.erb @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 43be57760..bbcb48bdf 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -2,6 +2,7 @@

<%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %>

ZIP下载 + <%= link_to "质量分析", quality_analyses_path(:id => @project.id, :repository_id => @repository.identifier) %>
diff --git a/config/routes.rb b/config/routes.rb index e4b462d93..438925878 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -902,6 +902,7 @@ RedmineApp::Application.routes.draw do # repositories routes get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats', :as => "stats_repository_project" + get 'projects/:id/repository/:repository_id/quality_analyses', :to => 'repositories#quality_analyses', :as => "quality_analyses" get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph' get 'projects/:id/repository/:repository_id/changes(/*path(.:ext))', :to => 'repositories#changes' @@ -920,6 +921,7 @@ RedmineApp::Application.routes.draw do } get 'projects/:id/repository/statistics', :to => 'repositories#stats' + get 'projects/:id/repository/graph', :to => 'repositories#graph' get 'projects/:id/repository/changes(/*path(.:ext))', :to => 'repositories#changes'