Merge branch 'master' into fixes/api
This commit is contained in:
commit
375caeefcf
29 changed files with 224 additions and 94 deletions
|
@ -265,6 +265,7 @@ module Gitlab
|
|||
# GET /projects/:id/repository/branches/:branch
|
||||
get ":id/repository/branches/:branch" do
|
||||
@branch = user_project.repo.heads.find { |item| item.name == params[:branch] }
|
||||
not_found!("Branch does not exist") if @branch.nil?
|
||||
present @branch, with: Entities::RepoObject, project: user_project
|
||||
end
|
||||
|
||||
|
|
|
@ -117,7 +117,10 @@ module ExtractsPath
|
|||
|
||||
@id = File.join(@ref, @path)
|
||||
|
||||
@commit = CommitDecorator.decorate(@project.repository.commit(@ref))
|
||||
# It is used "@project.repository.commits(@ref, @path, 1, 0)",
|
||||
# because "@project.repository.commit(@ref)" returns wrong commit when @ref is tag name.
|
||||
commits = @project.repository.commits(@ref, @path, 1, 0)
|
||||
@commit = CommitDecorator.decorate(commits.first)
|
||||
|
||||
@tree = Tree.new(@commit.tree, @ref, @path)
|
||||
@tree = TreeDecorator.new(@tree)
|
||||
|
|
|
@ -9,9 +9,10 @@ module Gitlab
|
|||
@max_count ||= 650
|
||||
end
|
||||
|
||||
def initialize project, ref
|
||||
def initialize project, ref, commit
|
||||
@project = project
|
||||
@ref = ref
|
||||
@commit = commit
|
||||
@repo = project.repo
|
||||
@ref_cache = {}
|
||||
|
||||
|
@ -31,7 +32,8 @@ module Gitlab
|
|||
# Get commits from repository
|
||||
#
|
||||
def collect_commits
|
||||
@commits = Grit::Commit.find_all(repo, nil, {max_count: self.class.max_count}).dup
|
||||
|
||||
@commits = Grit::Commit.find_all(repo, nil, {topo_order: true, max_count: self.class.max_count, skip: to_commit}).dup
|
||||
|
||||
# Decorate with app/models/commit.rb
|
||||
@commits.map! { |commit| ::Commit.new(commit) }
|
||||
|
@ -49,41 +51,28 @@ module Gitlab
|
|||
# list of commits. As well as returns date list
|
||||
# corelated with time set on commits.
|
||||
#
|
||||
# @param [Array<Graph::Commit>] comits to index
|
||||
# @param [Array<Graph::Commit>] commits to index
|
||||
#
|
||||
# @return [Array<TimeDate>] list of commit dates corelated with time on commits
|
||||
def index_commits
|
||||
days, heads, times = [], [], []
|
||||
days, times = [], []
|
||||
map = {}
|
||||
|
||||
commits.reverse.each_with_index do |c,i|
|
||||
c.time = i
|
||||
days[i] = c.committed_date
|
||||
map[c.id] = c
|
||||
heads += c.refs unless c.refs.nil?
|
||||
times[i] = c
|
||||
end
|
||||
|
||||
heads.select!{|h| h.is_a? Grit::Head or h.is_a? Grit::Remote}
|
||||
# sort heads so the master is top and current branches are closer
|
||||
heads.sort! do |a,b|
|
||||
if a.name == @ref
|
||||
-1
|
||||
elsif b.name == @ref
|
||||
1
|
||||
else
|
||||
b.commit.committed_date <=> a.commit.committed_date
|
||||
end
|
||||
end
|
||||
|
||||
@_reserved = {}
|
||||
days.each_index do |i|
|
||||
@_reserved[i] = []
|
||||
end
|
||||
|
||||
heads.each do |h|
|
||||
if map.include? h.commit.id then
|
||||
place_chain(map[h.commit.id], map)
|
||||
commits_sort_by_ref.each do |commit|
|
||||
if map.include? commit.id then
|
||||
place_chain(map[commit.id], map)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -95,6 +84,45 @@ module Gitlab
|
|||
days
|
||||
end
|
||||
|
||||
# Skip count that the target commit is displayed in center.
|
||||
def to_commit
|
||||
commits = Grit::Commit.find_all(repo, nil, {topo_order: true})
|
||||
commit_index = commits.index do |c|
|
||||
c.id == @commit.id
|
||||
end
|
||||
|
||||
if commit_index && (self.class.max_count / 2 < commit_index) then
|
||||
# get max index that commit is displayed in the center.
|
||||
commit_index - self.class.max_count / 2
|
||||
else
|
||||
0
|
||||
end
|
||||
end
|
||||
|
||||
def commits_sort_by_ref
|
||||
commits.sort do |a,b|
|
||||
if include_ref?(a)
|
||||
-1
|
||||
elsif include_ref?(b)
|
||||
1
|
||||
else
|
||||
b.committed_date <=> a.committed_date
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def include_ref?(commit)
|
||||
heads = commit.refs.select do |ref|
|
||||
ref.is_a?(Grit::Head) or ref.is_a?(Grit::Remote) or ref.is_a?(Grit::Tag)
|
||||
end
|
||||
|
||||
heads.map! do |head|
|
||||
head.name
|
||||
end
|
||||
|
||||
heads.include?(@ref)
|
||||
end
|
||||
|
||||
def find_free_parent_spaces(commit, map, times)
|
||||
spaces = []
|
||||
|
||||
|
|
|
@ -311,7 +311,7 @@ namespace :gitlab do
|
|||
"Remove \"-e \" so the line starts with PATH"
|
||||
)
|
||||
for_more_information(
|
||||
see_installation_guide_section("Gitolite"),
|
||||
see_installation_guide_section("Gitlab Shell"),
|
||||
"https://github.com/gitlabhq/gitlabhq/issues/1059"
|
||||
)
|
||||
fix_and_rerun
|
||||
|
@ -368,10 +368,10 @@ namespace :gitlab do
|
|||
|
||||
|
||||
namespace :gitlab_shell do
|
||||
desc "GITLAB | Check the configuration of Gitolite"
|
||||
desc "GITLAB | Check the configuration of Gitlab Shell"
|
||||
task check: :environment do
|
||||
warn_user_is_not_gitlab
|
||||
start_checking "Gitolite"
|
||||
start_checking "Gitlab Shell"
|
||||
|
||||
check_repo_base_exists
|
||||
check_repo_base_is_not_symlink
|
||||
|
@ -380,7 +380,7 @@ namespace :gitlab do
|
|||
check_post_receive_hook_is_up_to_date
|
||||
check_repos_post_receive_hooks_is_link
|
||||
|
||||
finished_checking "Gitolite"
|
||||
finished_checking "Gitlab Shell"
|
||||
end
|
||||
|
||||
|
||||
|
@ -392,7 +392,7 @@ namespace :gitlab do
|
|||
print "post-receive hook up-to-date? ... "
|
||||
|
||||
hook_file = "post-receive"
|
||||
gitlab_shell_hooks_path = File.join(Gitlab.config.gitlab_shell.hooks_path, "common")
|
||||
gitlab_shell_hooks_path = Gitlab.config.gitlab_shell.hooks_path
|
||||
gitlab_shell_hook_file = File.join(gitlab_shell_hooks_path, hook_file)
|
||||
gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user
|
||||
|
||||
|
@ -401,22 +401,7 @@ namespace :gitlab do
|
|||
return
|
||||
end
|
||||
|
||||
gitlab_shell_hook_content = File.read(gitlab_shell_hook_file)
|
||||
gitlab_hook_file = Rails.root.join.join("lib", "hooks", hook_file)
|
||||
gitlab_hook_content = File.read(gitlab_hook_file)
|
||||
|
||||
if gitlab_shell_hook_content == gitlab_hook_content
|
||||
puts "yes".green
|
||||
else
|
||||
puts "no".red
|
||||
try_fixing_it(
|
||||
"sudo -u #{gitlab_shell_ssh_user} cp #{gitlab_hook_file} #{gitlab_shell_hook_file}"
|
||||
)
|
||||
for_more_information(
|
||||
see_installation_guide_section "Setup GitLab Hooks"
|
||||
)
|
||||
fix_and_rerun
|
||||
end
|
||||
puts "yes".green
|
||||
end
|
||||
|
||||
def check_repo_base_exists
|
||||
|
@ -430,12 +415,12 @@ namespace :gitlab do
|
|||
puts "no".red
|
||||
puts "#{repo_base_path} is missing".red
|
||||
try_fixing_it(
|
||||
"This should have been created when setting up Gitolite.",
|
||||
"This should have been created when setting up Gitlab Shell.",
|
||||
"Make sure it's set correctly in config/gitlab.yml",
|
||||
"Make sure Gitolite is installed correctly."
|
||||
"Make sure Gitlab Shell is installed correctly."
|
||||
)
|
||||
for_more_information(
|
||||
see_installation_guide_section "Gitolite"
|
||||
see_installation_guide_section "Gitlab Shell"
|
||||
)
|
||||
fix_and_rerun
|
||||
end
|
||||
|
@ -480,7 +465,7 @@ namespace :gitlab do
|
|||
"find #{repo_base_path} -type d -print0 | sudo xargs -0 chmod g+s"
|
||||
)
|
||||
for_more_information(
|
||||
see_installation_guide_section "Gitolite"
|
||||
see_installation_guide_section "Gitlab Shell"
|
||||
)
|
||||
fix_and_rerun
|
||||
end
|
||||
|
@ -506,7 +491,7 @@ namespace :gitlab do
|
|||
"sudo chown -R #{gitlab_shell_ssh_user}:#{gitlab_shell_owner_group} #{repo_base_path}"
|
||||
)
|
||||
for_more_information(
|
||||
see_installation_guide_section "Gitolite"
|
||||
see_installation_guide_section "Gitlab Shell"
|
||||
)
|
||||
fix_and_rerun
|
||||
end
|
||||
|
@ -516,7 +501,7 @@ namespace :gitlab do
|
|||
print "post-receive hooks in repos are links: ... "
|
||||
|
||||
hook_file = "post-receive"
|
||||
gitlab_shell_hooks_path = File.join(Gitlab.config.gitlab_shell.hooks_path, "common")
|
||||
gitlab_shell_hooks_path = Gitlab.config.gitlab_shell.hooks_path
|
||||
gitlab_shell_hook_file = File.join(gitlab_shell_hooks_path, hook_file)
|
||||
gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user
|
||||
|
||||
|
@ -545,7 +530,7 @@ namespace :gitlab do
|
|||
"sudo -u #{gitlab_shell_ssh_user} ln -sf #{gitlab_shell_hook_file} #{project_hook_file}"
|
||||
)
|
||||
for_more_information(
|
||||
"lib/support/rewrite-hooks.sh"
|
||||
"#{gitlab_shell_user_home}/gitlab-shell/support/rewrite-hooks.sh"
|
||||
)
|
||||
fix_and_rerun
|
||||
next
|
||||
|
@ -555,7 +540,7 @@ namespace :gitlab do
|
|||
File.realpath(project_hook_file) == File.realpath(gitlab_shell_hook_file)
|
||||
puts "ok".green
|
||||
else
|
||||
puts "not a link to Gitolite's hook".red
|
||||
puts "not a link to Gitlab Shell's hook".red
|
||||
try_fixing_it(
|
||||
"sudo -u #{gitlab_shell_ssh_user} ln -sf #{gitlab_shell_hook_file} #{project_hook_file}"
|
||||
)
|
||||
|
@ -577,7 +562,7 @@ namespace :gitlab do
|
|||
end
|
||||
|
||||
def gitlab_shell_version
|
||||
gitlab_shell_version_file = "#{gitlab_shell_user_home}/gitlab_shell/src/VERSION"
|
||||
gitlab_shell_version_file = "#{gitlab_shell_user_home}/gitlab-shell/VERSION"
|
||||
if File.readable?(gitlab_shell_version_file)
|
||||
File.read(gitlab_shell_version_file)
|
||||
end
|
||||
|
|
|
@ -8,7 +8,12 @@ namespace :sidekiq do
|
|||
task :start do
|
||||
run "nohup bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e #{Rails.env} -P #{pidfile} >> #{Rails.root.join("log", "sidekiq.log")} 2>&1 &"
|
||||
end
|
||||
|
||||
|
||||
desc "GITLAB | Start sidekiq with launchd on Mac OS X"
|
||||
task :launchd do
|
||||
run "bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e #{Rails.env} -P #{pidfile} >> #{Rails.root.join("log", "sidekiq.log")} 2>&1"
|
||||
end
|
||||
|
||||
def pidfile
|
||||
Rails.root.join("tmp", "pids", "sidekiq.pid")
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue