parent
ea2033eb30
commit
aef2dd8d1a
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<a href="#L<%= line_num %>" style="padding-top: 0px;"><%= line_num %></a>
|
||||
</th>
|
||||
<td class="line-code">
|
||||
<pre style="width:auto;white-space: nowrap; "><%= line.html_safe %></pre>
|
||||
<pre style="width:auto;white-space: nowrap;overflow: auto; "><%= line.html_safe %></pre>
|
||||
</td>
|
||||
</tr>
|
||||
<% line_num += 1 %>
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<div class="commit-row-info">
|
||||
<% if !user_commit_rep(changeset.author_email).nil? %>
|
||||
<a class="commit-author-link has_tooltip"> <span class="commit-author-name">
|
||||
<%= 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 %></span></a>提交于
|
||||
<div class="committed_ago">
|
||||
<time class="time_ago js-timeago" title="<%= changeset.created_at %>"><%= time_tag(changeset.created_at) %>前 </time>
|
||||
</div>
|
||||
<% else %>
|
||||
<span class="commit-author-name"><%= changeset.author_email %></span>提交于
|
||||
<div class="committed_ago">
|
||||
<time class="time_ago js-timeago" title="<%= changeset.created_at %>"><%= time_tag(changeset.created_at) %> 前</time>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
|
@ -24,10 +24,10 @@
|
|||
<!--<td class="size"><%#= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>-->
|
||||
<!--<td class="size"><%#= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>-->
|
||||
<% if @repository.report_last_commit %>
|
||||
<td class="revision"><%= link_to_revision(entry.changeset, @repository) if entry.changeset %></td>
|
||||
<td class="age"><%= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %></td>
|
||||
<td class="author"><%= entry.author %></td>
|
||||
<td class="comments"><%=h truncate(entry.changeset.comments, :length => 50) if entry.changeset %></td>
|
||||
<td class="revision"><%= link_to_revision(entry.changeset, @repository) if entry.changeset %></td>
|
||||
<td class="age"><%= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %></td>
|
||||
<td class="author"><%= entry.author %></td>
|
||||
<td class="comments"><%=h truncate(entry.changeset.comments, :length => 50) if entry.changeset %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
|
|
@ -20,27 +20,13 @@
|
|||
<div class="col-md-10 col-sm-12">
|
||||
<ul class="bordered-list">
|
||||
<li class="commit js-toggle-container">
|
||||
<div class="commit-row-info">
|
||||
<% if !user_commit_rep(changeset.author_email).nil? %>
|
||||
<a class="commit-author-link has_tooltip"> <span class="commit-author-name">
|
||||
<%= 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 %></span></a>提交于
|
||||
<div class="committed_ago">
|
||||
<time class="time_ago js-timeago" title="<%= changeset.created_at %>"><%= time_tag(changeset.created_at) %>前 </time>
|
||||
</div>
|
||||
<% else %>
|
||||
<span class="commit-author-name"><%= changeset.author_email %></span>提交于
|
||||
<div class="committed_ago">
|
||||
<time class="time_ago js-timeago" title="<%= changeset.created_at %>"><%= time_tag(changeset.created_at) %> 前</time>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= render :partial => 'commit_details', :locals => {:changeset => changeset} %>
|
||||
<div style="padding-left:30px;" class="commit-row-title">
|
||||
<strong class="str-truncated">
|
||||
<a class="commit-row-message"><%= textilizable(truncate_at_line_break(changeset.message)) %></a>
|
||||
</strong>
|
||||
<div class="pull-right" title="修订号">
|
||||
<%= link_to truncate(changeset.short_id.to_s, :length => 20), :controller => 'repositories', :action => 'revision', :id => repository.project, :repository_id => repository.identifier_param, :rev => rev %>
|
||||
<%= link_to truncate(changeset.short_id.to_s, :length => 20), {:controller => 'repositories', :action => 'commit_diff', :id => project.id, :changeset => changeset.id} %>
|
||||
</div>
|
||||
<div class="notes_count">
|
||||
</div>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
<div class="mt10">
|
||||
|
||||
<%= render(:partial => 'revisions', :locals => {:project => @project, :path => @path ,:revisions => @commits, :entry => @entry ,:commits_pages =>@commits_pages , :commits_count => @commits_count}) unless @commits.empty? %>
|
||||
<%= render(:partial => 'revisions', :locals => {:project => @project, :path => @path , :revisions => @commits, :entry => @entry , :commits_pages => @commits_pages , :commits_count => @commits_count}) unless @commits.empty? %>
|
||||
|
||||
</div>
|
||||
<% content_for :header_tags do %>
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
<div class="project_r_h">
|
||||
<div class="fl"><h2 class="project_h2_repository"><%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %></h2></div>
|
||||
</div>
|
||||
<!--<script>-->
|
||||
<!--// $(document).ready(function(){-->
|
||||
<!--// $("#changed-files").click(function(){-->
|
||||
<!--// $("#changed-files-detail").toggle();-->
|
||||
<!--// });-->
|
||||
<!--// });-->
|
||||
<!--</script>-->
|
||||
<div class="showing-changes-info fontGrey2"> Commit <a href="javascript:void()" class="linkGrey3">
|
||||
<%= @commit_details.id %></a><br />
|
||||
<li class="commit js-toggle-container">
|
||||
<%= render :partial => 'commit_details', :locals => {:changeset => @commit_details} %>
|
||||
</li>
|
||||
</div>
|
||||
<div class="showing-changes-project f14"><%= @commit_details.message %></div>
|
||||
<!--<div class="showing-changes-row fontGrey2">Showing <a href="javascript:void()" class="linkGrey3" id="changed-files">3 changed files</a> with <span class="c_green">3 additions</span> and <span class="c_red">3 deletions</span>-->
|
||||
<!--<ol class="mt10" id="changed-files-detail">-->
|
||||
<!--<li><a href="javascript:void()" class="linkGrey3" id="changed-files">app/views/organizations/_org_course_homework.html.erb</a> </li>-->
|
||||
<!--<li><a href="javascript:void()" class="linkGrey3" id="changed-files">app/views/users/_course_homework.html.erb</a> </li>-->
|
||||
<!--<li><a href="javascript:void()" class="linkGrey3" id="changed-files">app/views/users/_user_homework_detail.html.erb</a> </li>-->
|
||||
<!--</ol>-->
|
||||
<!--</div>-->
|
||||
|
||||
<% @commit_diff.each do |cd| %>
|
||||
<div class="showing-changes-row fontGrey2">
|
||||
<a href="javascript:void()" class="linkGrey3" id="changed-files">
|
||||
<img src="/images/vlicon/file.png" width="18" height="20" style="vertical-align:middle;" class="mr5" /><%= cd.new_path %>
|
||||
</a>
|
||||
</div>
|
||||
<div class="autoscroll">
|
||||
<table class="filecontent syntaxhl" >
|
||||
<tbody>
|
||||
<% 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| %>
|
||||
<tr>
|
||||
<th class="line-num" id="L<%= line_num %>" style="vertical-align: top;">
|
||||
<a href="#L<%= line_num %>" style="padding-top: 0px;"><%= line_num %></a>
|
||||
</th>
|
||||
<% if line[0,1] == "-" %>
|
||||
<td class="line-code diff_out"><pre style="width:auto;white-space: nowrap; "><%= line.html_safe %></pre></td>
|
||||
<% elsif line[0,1] == "+" %>
|
||||
<td class="line-code diff_in"><pre style="width:auto;white-space: nowrap; "><%= line.html_safe %></pre></td>
|
||||
<% else%>
|
||||
<td class="line-code"><pre style="width:auto;white-space: nowrap; "><%= line.html_safe %></pre></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% line_num += 1 %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<% end %>
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
|
@ -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;}
|
Loading…
Reference in New Issue