Merge branch 'dev_newrep' into dev_newproject
Conflicts: app/controllers/projects_controller.rb app/views/projects/settings/_new_repositories.html.erb
This commit is contained in:
commit
207273839b
|
@ -364,7 +364,6 @@ class ProjectsController < ApplicationController
|
|||
applied_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type =? and viewed =?", User.current.id, @project, "AppliedProject", 0)
|
||||
applied_messages.update_all(:viewed => true)
|
||||
|
||||
# end
|
||||
@issue_custom_fields = IssueCustomField.sorted.all
|
||||
@issue_category ||= IssueCategory.new
|
||||
@member ||= @project.members.new
|
||||
|
@ -408,6 +407,7 @@ class ProjectsController < ApplicationController
|
|||
@repository = Repository.factory(scm)
|
||||
@repository.is_default = @project.repository.nil?
|
||||
@repository.project = @project
|
||||
@gitlab_rep = Repository.where(:type => "Repository::Gitlab", :project_id => @project).first
|
||||
unless @project.gpid.nil?
|
||||
g = Gitlab.client
|
||||
@gitlab_branches = g.branches(@project.gpid)
|
||||
|
|
|
@ -34,16 +34,18 @@ class RepositoriesController < ApplicationController
|
|||
|
||||
before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats, :quality_analysis]
|
||||
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, :export_rep_static]
|
||||
# 连接gitlab
|
||||
# before_filter :connect_gitlab, :only => [:quality_analysis, :commit_diff]
|
||||
|
||||
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, :quality_analysis]
|
||||
# 链接gitlab
|
||||
before_filter :connect_gitlab, :only => [:quality_analysis, :show, :commit_diff, :find_project_repository]
|
||||
# 版本库新增权限
|
||||
before_filter :show_rep, :only => [:show]
|
||||
accept_rss_auth :revisions
|
||||
# hidden repositories filter // 隐藏代码过滤器
|
||||
before_filter :check_hidden_repo, :only => [:show, :stats, :revisions, :revision, :diff ]
|
||||
before_filter :check_hidden_repo, :only => [:stats, :revisions, :revision, :diff ]
|
||||
helper :repositories
|
||||
include RepositoriesHelper
|
||||
helper :project_score
|
||||
|
@ -329,7 +331,7 @@ update
|
|||
def quality_analysis
|
||||
gitlab_branches = @g.branches(@project.gpid)
|
||||
@branch_names = gitlab_branches.map{|b| b.name}
|
||||
@gitlab_default_branch = @g.project(@project.gpid).default_branch
|
||||
@gitlab_default_branch = @g_project.default_branch
|
||||
# language = params[:language]
|
||||
# branch = params[:branch]
|
||||
# path = params[:path]
|
||||
|
@ -385,16 +387,22 @@ update
|
|||
if request.xhr?
|
||||
@entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
|
||||
else
|
||||
@changesets = @g.commits(@project.gpid, :ref_name => @rev)
|
||||
# 最近一次提交
|
||||
@changesets_latest_coimmit = @changesets[0]
|
||||
g_project = @g.project(@project.gpid)
|
||||
@changesets_latest_coimmit = @g.commit(@project.gpid, @entries.first.try(:lastrev))
|
||||
# @changesets_latest_coimmit = @g.commits(@project.gpid, :ref_name => @rev)[0]
|
||||
|
||||
# 总的提交数
|
||||
@changesets_all_count = @g.user_static(@project.gpid, :rev => @rev).count
|
||||
|
||||
# 获取默认分支
|
||||
@g_default_branch = g_project.default_branch.nil? ? "master" : g_project.default_branch
|
||||
@g_default_branch = @g_project.default_branch.nil? ? "master" : @g_project.default_branch
|
||||
|
||||
@creator = @project.owner.to_s
|
||||
gitlab_address = Redmine::Configuration['gitlab_address']
|
||||
# REDO:需优化,仅测试用
|
||||
@zip_path = Gitlab.endpoint.to_s + "/projects/" + @project.gpid.to_s + "/repository/archive?&private_token=" + Gitlab.private_token
|
||||
@repos_url = gitlab_address.to_s+"/" + @creator + "/" + @repository.identifier+"."+"git"
|
||||
|
||||
# 一些数据的异步同步更新
|
||||
# 访问版本庫后更新project_score表数据;changeset_num为提交总数
|
||||
project_score = @project.project_score
|
||||
if project_score.nil?
|
||||
|
@ -402,28 +410,21 @@ update
|
|||
else
|
||||
project_score.update_column(:changeset_num, @changesets_all_count)
|
||||
end
|
||||
|
||||
unless @changesets_latest_coimmit.blank?
|
||||
update_commits_date(@project, @changesets_latest_coimmit)
|
||||
end
|
||||
@creator = @project.owner.to_s
|
||||
gitlab_address = Redmine::Configuration['gitlab_address']
|
||||
|
||||
# REDO:需优化,仅测试用
|
||||
@zip_path = Gitlab.endpoint.to_s + "/projects/" + @project.gpid.to_s + "/repository/archive?&private_token=" + Gitlab.private_token
|
||||
|
||||
# 获取版本库路径,主要分为两种,一种随Gitlab类型,另一种为Git类型,Git类型为无用数据,最终需要删掉这种类型。
|
||||
if @repository.type.to_s == "Repository::Gitlab"
|
||||
@repos_url = gitlab_address.to_s+"/" + @creator + "/" + @repository.identifier+"."+"git"
|
||||
else
|
||||
@repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s + @repository.url.slice(project_path_cut, @repository.url.length).to_s
|
||||
end
|
||||
render :action => 'show', :layout => 'base_projects'
|
||||
render :layout => 'base_projects'
|
||||
end
|
||||
end
|
||||
|
||||
alias_method :browse, :show
|
||||
|
||||
# 获取版本文件目录的
|
||||
def tree_head_message
|
||||
|
||||
end
|
||||
|
||||
def changes
|
||||
@entry = @repository.entry(@path, @rev)
|
||||
(show_error_not_found; return) unless @entry
|
||||
|
@ -675,7 +676,7 @@ update
|
|||
@g_project = @g.project(@project.gpid)
|
||||
end
|
||||
rescue => e
|
||||
logger.error("failed to connect gitlab ==> #{e}")
|
||||
logger.error("connect gitlab failed ==> #{e}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -694,31 +695,19 @@ update
|
|||
end
|
||||
|
||||
REV_PARAM_RE = %r{\A[a-f0-9]*\Z}i
|
||||
REP_TYPE = "Repository::Gitlab"
|
||||
|
||||
# 获取项目、版本库、路劲、默认分支
|
||||
def find_project_repository
|
||||
@project = Project.find(params[:id])
|
||||
if params[:repository_id].present?
|
||||
@repository = @project.repositories.find_by_identifier_param(params[:repository_id])
|
||||
else
|
||||
# 多版本库,如果一个版本库为空则去下一个
|
||||
rep_count = @project.repositories.count
|
||||
if @project.repository.nil?
|
||||
for i in 0..rep_count
|
||||
unless @project.repositories[i].nil?
|
||||
@repository = @project.repositories[i]
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
@repository = @project.repository
|
||||
end
|
||||
end
|
||||
(render_404; return false) unless @repository
|
||||
@repository = Repository.where(:type => REP_TYPE, :project_id => @project).first
|
||||
(render_404; return false) unless (@repository || @project.gpid)
|
||||
@path = params[:path].is_a?(Array) ? params[:path].join('/') : params[:path].to_s
|
||||
@g = Gitlab.client
|
||||
@g_project = @g.project(@project.gpid)
|
||||
@g_default_branch = @g_project.default_branch
|
||||
# gitlab端获取默认分支
|
||||
g = Gitlab.client
|
||||
gitlab_branchs = g.project(@project.gpid).default_branch
|
||||
@project.gpid.nil? ? (@rev = params[:rev].blank? ? @repository.default_branch : params[:rev].to_s.strip) : (@rev = params[:rev].blank? ? gitlab_branchs : params[:rev].to_s.strip)
|
||||
@rev = params[:rev].blank? ? @g_default_branch : params[:rev].to_s.strip
|
||||
@rev_to = params[:rev_to]
|
||||
unless @rev.to_s.match(REV_PARAM_RE) && @rev_to.to_s.match(REV_PARAM_RE)
|
||||
if @repository.branches.blank?
|
||||
|
|
|
@ -422,8 +422,8 @@ class Repository < ActiveRecord::Base
|
|||
def load_entries_changesets(entries)
|
||||
if entries
|
||||
entries.each do |entry|
|
||||
if entry.lastrev && entry.lastrev.identifier
|
||||
entry.changeset = find_changeset_by_name(entry.lastrev.identifier)
|
||||
if entry.lastrev
|
||||
entry.changeset = entry.lastrev
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<% project_file_num = Attachment.where(:container_type => "Project", :container_id => @project.id).count %>
|
||||
<% project_issue_count =Issue.where(:project_id => @project.id).count%>
|
||||
<% acts_count = ForgeActivity.where("project_id = ?", @project.id).count %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_activity), {:controller => 'projects', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
|
||||
<% unless ForgeActivity.where("project_id = ?", @project.id).count == 0 %>
|
||||
<a class="subnav_num">(<%= ForgeActivity.where("project_id = ?", @project.id).count %>)</a>
|
||||
<% unless acts_count == 0 %>
|
||||
<a class="subnav_num">(<%= acts_count %>)</a>
|
||||
<% end %>
|
||||
</div>
|
||||
<% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %>
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
<div class="autoscroll">
|
||||
<table class="list entries" id="browser" style="table-layout: fixed;">
|
||||
|
||||
<tbody>
|
||||
<%= render :partial => 'dir_list_content' %>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="list entries" id="browser" style="table-layout: fixed;">
|
||||
<tbody>
|
||||
<%= render :partial => 'dir_list_content' %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Load last commit log for each file in tree
|
||||
$('#tree-slider').waitForImages(function() {
|
||||
ajaxGet('#{@logs_path}');
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<% sub_path = entry.path[0] == "/" ? entry.path.sub("/", "") : entry.path %>
|
||||
<% ent_path = Redmine::CodesetUtil.replace_invalid_utf8(sub_path) %>
|
||||
<% ent_name = Redmine::CodesetUtil.replace_invalid_utf8(entry.name) %>
|
||||
<% latest_changes = get_trees_last_changes(@project.gpid, @rev, ent_path, @g) %>
|
||||
<%# latest_changes = get_trees_last_changes(@project.gpid, @rev, ent_path, @g) %>
|
||||
|
||||
<tr id="<%= tr_id %>" class="<%= h params[:parent_id] %> entry <%= entry.kind %>">
|
||||
<td style="padding-left: <%=18 * depth%>px;" class="filename_no_report hidden">
|
||||
|
@ -16,7 +16,7 @@
|
|||
:repository_id => @repository.identifier_param,
|
||||
:path => to_path_param(ent_path),
|
||||
:rev => @rev,
|
||||
:latest_changes => latest_changes,
|
||||
# :latest_changes => latest_changes,
|
||||
:depth => (depth + 1),
|
||||
:parent_id => tr_id)) %>');"> </span>
|
||||
<% end %>
|
||||
|
@ -26,21 +26,49 @@
|
|||
</td>
|
||||
<div id="children_tree">
|
||||
<td class="tree-comments c_grey hidden">
|
||||
<div class="hidden" title="<%= (latest_changes.message) if latest_changes %>">
|
||||
<%= (latest_changes.message) if latest_changes %>
|
||||
<div class="hidden" id="changes_message_<%= tr_id %>">
|
||||
</div>
|
||||
</td>
|
||||
<td class="tree-author c_grey">
|
||||
<div class="hidden" title="<%= (latest_changes.author_name) if latest_changes %>">
|
||||
<%= (latest_changes.author_name) if latest_changes %>
|
||||
<div class="hidden" id="changes_author_<%= tr_id %>">
|
||||
</div>
|
||||
</td>
|
||||
<td class="tree-age c_grey">
|
||||
<div class="hidden" title="<%= format_time(latest_changes.time) if latest_changes %>">
|
||||
<div class="hidden" id="changes_time_<%= tr_id %>">
|
||||
<%# 为了转换UTC时间,时差8小时 %>
|
||||
<%= distance_of_time_in_words(latest_changes.time, Time.now) if latest_changes %>
|
||||
<%= link_to tree_head_message_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch) %>
|
||||
</div>
|
||||
</td>
|
||||
</div>
|
||||
</tr>
|
||||
|
||||
<!--<!–<script>–>-->
|
||||
<!--// $("#changes_message_<%#=tr_id %>").html("999")-->
|
||||
<!--// $("#changes_author_<%#=tr_id %>").html("<%#= get_trees_last_changes(@project.gpid, @rev, ent_path, @g).author_name %>")-->
|
||||
<!--// $("#changes_time_<%#=tr_id %>").html("<%#= distance_of_time_in_words(get_trees_last_changes(@project.gpid, @rev, ent_path, @g).time, Time.now) %>")-->
|
||||
<!--<!–</script>–>-->
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$.ajax({
|
||||
type:"GET",
|
||||
url:"Venue.aspx?act=init",
|
||||
dataType:"html",
|
||||
success:function(result){ //function1()
|
||||
f1();
|
||||
f2();
|
||||
}
|
||||
|
||||
failure:function (result) {
|
||||
alert('Failed');
|
||||
}
|
||||
}
|
||||
|
||||
alert("test");
|
||||
alert(<%#= get_trees_last_changes(@project.gpid, @rev, ent_path, @g).author_name %>);
|
||||
document.getElementById('changes_author_<%=tr_id %>').html(<%= get_trees_last_changes(@project.gpid, @rev, ent_path, @g).author_name %>);
|
||||
});
|
||||
</script>
|
||||
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
<div class="cl"></div>
|
||||
|
||||
<div class="recordBanner mt10" style="width:730px;">
|
||||
<% if @changesets && !@changesets.empty? %>
|
||||
<% if @changesets_latest_coimmit %>
|
||||
<% if !user_commit_rep(@changesets_latest_coimmit.author_email).nil? %>
|
||||
<%= image_tag(url_to_avatar(user_commit_rep(@changesets_latest_coimmit.author_email)), :width => "25", :height => "25", :class => "fl portraitRadius mt2 ml4 mr5") %>
|
||||
<span class="fl"><div class="fb fontGrey3 mr5 fl hidden maxwidth150"><%=link_to user_commit_rep(@changesets_latest_coimmit.author_email), user_path(user_commit_rep(@changesets_latest_coimmit.author_email)) %></div>
|
||||
|
|
|
@ -989,6 +989,7 @@ RedmineApp::Application.routes.draw do
|
|||
get 'projects/:id/repository/changes(/*path(.:ext))', :to => 'repositories#changes'
|
||||
|
||||
get 'projects/:id/repository/forked', :to => 'repositories#forked'
|
||||
get 'projects/:id/repository/tree_head_message', :to => 'repositories#tree_head_message', :as => "tree_head_message"
|
||||
get 'projects/:id/repository/export_rep_static', :to => 'repositories#export_rep_static'
|
||||
get 'projects/:id/repository/project_archive', :to => 'repositories#project_archive', :as => 'project_archive'
|
||||
get 'projects/:id/repository/revisions', :to => 'repositories#revisions'
|
||||
|
|
|
@ -96,7 +96,7 @@ module Redmine
|
|||
:path => File.join(path,tree.name),
|
||||
:kind => tree.type == 'tree' ? 'dir' : 'file',
|
||||
:size => nil,
|
||||
:lastrev => nil
|
||||
:lastrev => tree.commit_id
|
||||
})
|
||||
end
|
||||
entries.sort_by_name
|
||||
|
|
Loading…
Reference in New Issue