From aef2dd8d1a83b82cc48f5a55073799a5fc92a767 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 25 Feb 2016 11:06:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E4=BF=AE=E8=AE=A2=E5=A5=BD=EF=BC=8C=E5=AF=BC=E5=87=BA=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E7=9A=84=E6=96=87=E4=BB=B6=EF=BC=8C=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E5=86=85=E5=AE=B9=20=E9=AB=98=E4=BA=AE?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=86=85=E5=AE=B9=20=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E4=BF=AE=E8=AE=A2=E5=AF=B9=E6=AF=94=20=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 | 9 +-- app/helpers/repositories_helper.rb | 10 ++++ app/views/common/_file.html.erb | 2 +- .../repositories/_commit_details.html.erb | 15 +++++ .../repositories/_dir_list_content.html.erb | 8 +-- app/views/repositories/_revisions.html.erb | 18 +----- app/views/repositories/changes.html.erb | 2 +- app/views/repositories/commit_diff.html.erb | 55 ++++++++++++++++++ public/images/vlicon/file.png | Bin 0 -> 1167 bytes public/stylesheets/project.css | 19 +++++- 10 files changed, 110 insertions(+), 28 deletions(-) create mode 100644 app/views/repositories/_commit_details.html.erb create mode 100644 app/views/repositories/commit_diff.html.erb create mode 100644 public/images/vlicon/file.png diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 95e9acc80..7655f1eb4 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -34,7 +34,7 @@ class RepositoriesController < ApplicationController 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] before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue] - before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked] + before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :commit_diff] accept_rss_auth :revisions # hidden repositories filter // 隐藏代码过滤器 before_filter :check_hidden_repo, :only => [:show, :stats, :revisions, :revision, :diff ] @@ -521,12 +521,13 @@ update end end - # 没次提交对应的文件差异 + # 每次提交对应的文件差异 def commit_diff - + @commit_diff = $g.commit_diff(@project.gpid, params[:changeset]) + @commit_details = $g.commit(@project.gpid, params[:changeset]) + render :layout => 'base_projects' end - def diff if params[:format] == 'diff' @diff = @repository.diff(@path, @rev, @rev_to) diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index ff4aa61fb..36187b460 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -41,6 +41,16 @@ module RepositoriesHelper identifiers.include?(iden) ? false :true end + # 获取diff内容行号 + def diff_line_num content + content.scan(/@@ -(\d+),\d+ \+\d+,\d+ @@/).first.join("").to_i + end + + # 处理内容 + def diff_content content + content.gsub!(/.*@@ -\d+,\d+ \+\d+,\d+ @@\n/m,'') + end + def format_revision(revision) if revision.respond_to? :format_identifier revision.format_identifier diff --git a/app/views/common/_file.html.erb b/app/views/common/_file.html.erb index 97443beea..486c760f1 100644 --- a/app/views/common/_file.html.erb +++ b/app/views/common/_file.html.erb @@ -8,7 +8,7 @@ <%= line_num %> -
<%= line.html_safe %>
+
<%= line.html_safe %>
<% line_num += 1 %> diff --git a/app/views/repositories/_commit_details.html.erb b/app/views/repositories/_commit_details.html.erb new file mode 100644 index 000000000..ef8faecd7 --- /dev/null +++ b/app/views/repositories/_commit_details.html.erb @@ -0,0 +1,15 @@ +
+ <% if !user_commit_rep(changeset.author_email).nil? %> + + <%= image_tag(url_to_avatar(user_commit_rep(changeset.author_email)), :width => "20", :height => "20", :class => "fl portraitRadius mt2 ml4 mr5") %> + <%= link_to user_commit_rep(changeset.author_email), user_path(user_commit_rep(changeset.author_email)), :length => 30 %>提交于 +
+   +
+ <% else %> + <%= changeset.author_email %>提交于 +
+   +
+ <% end %> +
\ No newline at end of file diff --git a/app/views/repositories/_dir_list_content.html.erb b/app/views/repositories/_dir_list_content.html.erb index 81706c25e..dda0cddbd 100644 --- a/app/views/repositories/_dir_list_content.html.erb +++ b/app/views/repositories/_dir_list_content.html.erb @@ -24,10 +24,10 @@ <% if @repository.report_last_commit %> -<%= link_to_revision(entry.changeset, @repository) if entry.changeset %> -<%= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %> -<%= entry.author %> -<%=h truncate(entry.changeset.comments, :length => 50) if entry.changeset %> + <%= link_to_revision(entry.changeset, @repository) if entry.changeset %> + <%= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %> + <%= entry.author %> + <%=h truncate(entry.changeset.comments, :length => 50) if entry.changeset %> <% end %> <% end %> diff --git a/app/views/repositories/_revisions.html.erb b/app/views/repositories/_revisions.html.erb index 6de04b1d2..a27789dc1 100644 --- a/app/views/repositories/_revisions.html.erb +++ b/app/views/repositories/_revisions.html.erb @@ -20,27 +20,13 @@
+
<%= @commit_details.message %>
+ + + + + + + + +<% @commit_diff.each do |cd| %> +
+ + <%= cd.new_path %> + +
+
+ + + <% line_num = diff_line_num(cd.diff) %> + <% diff_content = diff_content(cd.diff) %> + <% syntax_highlight_lines(cd.new_path, Redmine::CodesetUtil.to_utf8_by_setting(diff_content)).each do |line| %> + + + <% if line[0,1] == "-" %> + + <% elsif line[0,1] == "+" %> + + <% else%> + + <% end %> + + <% line_num += 1 %> + <% end %> + +
+ <%= line_num %> +
<%= line.html_safe %>
<%= line.html_safe %>
<%= line.html_safe %>
+
+<% end %> \ No newline at end of file diff --git a/public/images/vlicon/file.png b/public/images/vlicon/file.png new file mode 100644 index 0000000000000000000000000000000000000000..bbfa6078d3d01782244c2c3eab309b009087e03a GIT binary patch literal 1167 zcmaJ>TWHi+7>*WQZP$mY*miU=#D`UIlF3}snb@($$&8)VlrkN#g34r)(>8RH6O&UX z?SpuuC{9tq^;*j=K8aFA6x3QPC>6Do)d!JXx-TLq6sn-m2i@*T?bLnPF(f$`zVG}0 z|NI~4Xj9{sCFP!Sf*_V88^jbIm*Q{vqJ{Xs|BU_%9%@j$1vSG~l$R|)2rA41GO5dL zAO&Q#YtIuM;3vl z?FDMWf;u@8eQDN?s2Dcw#AD%;{yY`-NLqZ z8s66u#JsYkD5RY~v!AD@>&rsKva(-^io%E26Mg$%jP2@U_FTE8Wd4}08oHg+h#&r9 z&yu5C%tO`v_fI*OtF8>)eaTdfAD*lqd+Mdn4Htyt2V^Z*`S5CB_|c1PuecMFp-cXr zIJ@-d;D%#65A-a^eDXYhFqHe7>KT~0-FW@kCTe9v@a>zz_{HZngEiGRexJYN%-F7d zW0{rOp-Y5=i&K&#~k#&;| literal 0 HcmV?d00001 diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css index 2ca1d56d8..1a231b8a0 100644 --- a/public/stylesheets/project.css +++ b/public/stylesheets/project.css @@ -896,9 +896,9 @@ a:hover.Reply_pic{border:1px solid #64bdd9;} /*end*/ /***** Diff *****/ .diff_out { background: #fcc; } -.diff_out span { background: #faa; } +/*.diff_out span { background: #faa; }*/ .diff_in { background: #cfc; } -.diff_in span { background: #afa; } +/*.diff_in span { background: #afa; }*/ .text-diff { padding: 1em; @@ -1169,3 +1169,18 @@ div.disable_link {background-color: #c1c1c1 !important;} .proInfoBox2{ border:1px solid #dddddd; height:45px; padding:10px 0; background-color:#f1f1f1;} .proInfoBox2 ul li{ height:24px; position:relative;} .maxwidth150{max-width: 150px;} + +/*版本库diff*/ +.showing-changes-info {width:650px; padding:10px; background-color:#ffffff; line-height:2;} +.showing-changes-project {width:650px; padding:10px; border-top:1px solid #dce0e6; border-bottom:1px solid #dce0e6; background-color:#f1f1f1;} +.showing-changes-row {width:650px; padding:10px; border-bottom:1px solid #dce0e6; background-color:#f1f1f1;} +#changed-files-detail {display:none;} +#changed-files-detail li {list-style-type:disc; margin-left:15px;} +.showing-changes-detail {width:670px; border-bottom:1px solid #dce0e6; background-color:#f1f1f1;} +.changes-detail-chart {width:100%; overflow:auto; border-collapse:collapse; margin:0px; padding:0px; background-color:#f1f1f1;} +.diff-line-number {width:35px; min-width:35px; max-width:50px; border-right:1px solid #c1c1c1; padding:0px 5px; text-align:right; background-color:#f1f1f1;} +.code-line-old {background-color:#ffecec;} +.number-line-old {background-color:#ffdddd; border-color:#f1c0c0;} +.code-line-new {background-color:#eaffea;} +.number-line-new {background-color:#dbffdb; border-color:#c1e9c1;} +.branch-label {padding-right: 5px; border-radius:2px; color:#888888; display:inline-block; background-color:#f8fafc;} \ No newline at end of file