From aadba839ae9b45a453df5fb86c5df180dee949b7 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 8 Nov 2017 19:01:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BB=A3=E7=A0=81=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E7=BC=96=E8=BE=91=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 1 + app/views/repositories/_entry_content.html.erb | 6 ++++-- app/views/repositories/_latest_commit.html.erb | 4 +++- app/views/repositories/_link_to_functions.html.erb | 6 ++++-- app/views/repositories/entry.html.erb | 4 +++- config/routes.rb | 2 ++ lib/gitlab-cli/lib/gitlab/client/repositories.rb | 5 +++++ 7 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 835b0c0c6..df9171097 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -601,6 +601,7 @@ update end def entry_edit + entry_and_raw(false) @content = @repository.cat(@path, @rev) # @changesets_latest_coimmit = @g.commit(@project.gpid, @entry.try(:lastrev)) @changesets_latest_coimmit = @g.rep_last_changes(@project.gpid, :rev => @rev, :path => @path) diff --git a/app/views/repositories/_entry_content.html.erb b/app/views/repositories/_entry_content.html.erb index 0ea9def12..1d6670a99 100644 --- a/app/views/repositories/_entry_content.html.erb +++ b/app/views/repositories/_entry_content.html.erb @@ -1,5 +1,7 @@ -
+
  • - +
    + +
  • diff --git a/app/views/repositories/_latest_commit.html.erb b/app/views/repositories/_latest_commit.html.erb index acce15cd8..458e361d1 100644 --- a/app/views/repositories/_latest_commit.html.erb +++ b/app/views/repositories/_latest_commit.html.erb @@ -5,7 +5,9 @@
    提交于 <%= time_tag(@changesets_latest_coimmit.try(:time)) %> 前:
    <%= @changesets_latest_coimmit.message %>
    <% if @entry && @entry.kind == 'file' %> - <%= render :partial => 'link_to_functions' %> +
    + <%= render :partial => 'link_to_functions' %> +
    <% end %> <% end %> \ No newline at end of file diff --git a/app/views/repositories/_link_to_functions.html.erb b/app/views/repositories/_link_to_functions.html.erb index 132c7f032..d1f555d28 100644 --- a/app/views/repositories/_link_to_functions.html.erb +++ b/app/views/repositories/_link_to_functions.html.erb @@ -24,8 +24,10 @@ <%= "(#{number_to_human_size(@entry.size)})" if @entry.size %> <% if params[:action] == "entry_edit" %> - 保存 + 保存 <% elsif params[:action] == "entry" || params[:action] == "entry_update" %> - <%= link_to "编辑", entry_edit_repository_path(@project, :path => @path, :rev => @rev), :class => "fl mr5", :remote => true %> + <%= link_to "编辑", {:controller => "repositories", :action => "entry_edit", :id => @project.id, :repository_id => @repository.identifier, :path => @path, :rev => @rev}, :class => "fr mr5", :remote => true %> + + <% end %> <% end %> diff --git a/app/views/repositories/entry.html.erb b/app/views/repositories/entry.html.erb index 14cd1c3e3..fc6aa0213 100644 --- a/app/views/repositories/entry.html.erb +++ b/app/views/repositories/entry.html.erb @@ -10,7 +10,9 @@
    <%= render :partial => 'latest_commit' %> - <%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content} %> +
    + <%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content} %> +
    <% content_for :header_tags do %> <%= stylesheet_link_tag "scm" %> diff --git a/config/routes.rb b/config/routes.rb index 6b01ff9e7..21c931592 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1211,6 +1211,8 @@ RedmineApp::Application.routes.draw do :action => /(browse|show|entry|raw|changes|annotate|diff|commit_diff)/ get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil + get 'projects/:id/repository/:repository_id/entry_edit', :to => 'repositories#entry_edit', :path => nil + post 'projects/:id/repository/:repository_id/entry_update', :to => 'repositories#entry_update', :path => nil get 'projects/:id/repository', :to => 'repositories#show', :path => nil get 'projects/:id/exit', :to => 'projects#exit_project', :as => 'exit_cur_project' diff --git a/lib/gitlab-cli/lib/gitlab/client/repositories.rb b/lib/gitlab-cli/lib/gitlab/client/repositories.rb index 4b458ecee..5ce94c54e 100644 --- a/lib/gitlab-cli/lib/gitlab/client/repositories.rb +++ b/lib/gitlab-cli/lib/gitlab/client/repositories.rb @@ -192,6 +192,11 @@ class Gitlab::Client get("/projects/#{project}/repository/contributors") end + # update file + def edit_file(project, options={}) + put("/projects/#{project}/repository/files", :body => options) + end + # Get an archive of the repository # @param [Integer] project the ID fo a project. # sha (optional) - The commit SHA to download defaults to the tip of the default branch