Merge commit 'master' into discussions

Conflicts:
	app/assets/stylesheets/sections/notes.scss
	app/contexts/notes/load_context.rb
	app/models/project.rb
	app/observers/note_observer.rb
	app/roles/votes.rb
	app/views/commit/show.html.haml
	app/views/merge_requests/_show.html.haml
	app/views/merge_requests/diffs.js.haml
	app/views/merge_requests/show.js.haml
	app/views/notes/_note.html.haml
	features/steps/project/project_merge_requests.rb
	spec/models/note_spec.rb
This commit is contained in:
Riyad Preukschas 2013-01-15 00:52:25 +01:00
commit 3022786948
930 changed files with 80374 additions and 103682 deletions

View file

@ -82,7 +82,7 @@ module Gitlab
end
def destroy_project(project)
FileUtils.rm_rf(project.path_to_repo)
FileUtils.rm_rf(project.repository.path_to_repo)
conf.rm_repo(project.path_with_namespace)
end
@ -138,9 +138,9 @@ module Gitlab
::Gitolite::Config::Repo.new(repo_name)
end
name_readers = project.repository_readers
name_writers = project.repository_writers
name_masters = project.repository_masters
name_readers = project.team.repository_readers
name_writers = project.team.repository_writers
name_masters = project.team.repository_masters
pr_br = project.protected_branches.map(&:name).join("$ ")

View file

@ -17,10 +17,6 @@ module Grack
# Pass Gitolite update hook
ENV['GL_BYPASS_UPDATE_HOOK'] = "true"
# Need this patch due to the rails mount
@env['PATH_INFO'] = @request.path
@env['SCRIPT_NAME'] = ""
# Find project by PATH_INFO from env
if m = /^\/([\w\.\/-]+)\.git/.match(@request.path_info).to_a
self.project = Project.find_with_namespace(m.last)

View file

@ -22,14 +22,16 @@ module Gitlab
h[:parents] = self.parents.collect do |p|
[p.id,0,0]
end
h[:author] = author.name
h[:author] = {
name: author.name,
email: author.email
}
h[:time] = time
h[:space] = space
h[:refs] = refs.collect{|r|r.name}.join(" ") unless refs.nil?
h[:id] = sha
h[:date] = date
h[:message] = message
h[:login] = author.email
h
end

View file

@ -17,14 +17,14 @@ module Gitlab
@commits = collect_commits
@days = index_commits
end
def to_json(*args)
{
days: @days.compact.map { |d| [d.day, d.strftime("%b")] },
commits: @commits.map(&:to_graph_hash)
}.to_json(*args)
end
protected
# Get commits from repository
@ -97,7 +97,7 @@ module Gitlab
if leaves.empty?
return
end
space = find_free_space(leaves.last.time..leaves.first.time)
space = find_free_space(leaves, map)
leaves.each{|l| l.space = space}
# and mark it as reserved
min_time = leaves.last.time
@ -119,7 +119,7 @@ module Gitlab
# Visit branching chains
leaves.each do |l|
parents = l.parents.collect.select{|p| map.include? p.id and map[p.id].space == 0}
parents = l.parents.collect.select{|p| map.include? p.id and map[p.id].space.zero?}
for p in parents
place_chain(map[p.id], map, l.time)
end
@ -132,18 +132,29 @@ module Gitlab
end
end
def find_free_space(time_range)
def find_free_space(leaves, map)
time_range = leaves.last.time..leaves.first.time
reserved = []
for day in time_range
reserved += @_reserved[day]
end
space = 1
space = base_space(leaves, map)
while reserved.include? space do
space += 1
end
space
end
def base_space(leaves, map)
parents = []
leaves.each do |l|
parents.concat l.parents.collect.select{|p| map.include? p.id and map[p.id].space.nonzero?}
end
space = parents.map{|p| map[p.id].space}.max || 0
space += 1
end
# Takes most left subtree branch of commits
# which don't have space mark yet.
#
@ -156,13 +167,13 @@ module Gitlab
leaves.push(commit) if commit.space.zero?
while true
parent = commit.parents.collect.select do |p|
map.include? p.id and map[p.id].space == 0
end
return leaves if commit.parents.count.zero?
return leaves unless map.include? commit.parents.first.id
return leaves if parent.count.zero?
commit = map[commit.parents.first.id]
return leaves unless commit.space.zero?
commit = map[parent.first.id]
leaves.push(commit)
end
end

View file

@ -170,7 +170,7 @@ module Gitlab
end
def reference_commit(identifier)
if @project.valid_repo? && commit = @project.commit(identifier)
if @project.valid_repo? && commit = @project.repository.commit(identifier)
link_to(identifier, project_commit_path(@project, commit), html_options.merge(title: CommitDecorator.new(commit).link_title, class: "gfm gfm-commit #{html_options[:class]}"))
end
end

View file

@ -16,7 +16,7 @@ module Gitlab
def execute
# Create new dir if missing
new_dir_path = File.join(Gitlab.config.gitolite.repos_path, new_dir)
system("mkdir -m 770 #{new_dir_path}") unless File.exists?(new_dir_path)
FileUtils.mkdir( new_dir_path, mode: 0770 ) unless File.exists?(new_dir_path)
old_path = File.join(Gitlab.config.gitolite.repos_path, old_dir, "#{project.path}.git")
new_path = File.join(new_dir_path, "#{project.path}.git")
@ -25,17 +25,18 @@ module Gitlab
raise ProjectMoveError.new("Destination #{new_path} already exists")
end
if system("mv #{old_path} #{new_path}")
begin
FileUtils.mv( old_path, new_path )
log_info "Project #{project.name} was moved from #{old_path} to #{new_path}"
true
else
rescue Exception => e
message = "Project #{project.name} cannot be moved from #{old_path} to #{new_path}"
log_info "Error! #{message}"
log_info "Error! #{message} (#{e.message})"
raise ProjectMoveError.new(message)
end
end
protected
protected
def log_info message
Gitlab::AppLogger.info message

View file

@ -6,6 +6,10 @@ module Gitlab
default_regex
end
def project_name_regex
/\A[a-zA-Z][a-zA-Z0-9_\-\. ]*\z/
end
def path_regex
default_regex
end

View file

@ -31,7 +31,7 @@ module Gitlab
merge_repo.git.push({raise: true, timeout: true}, :origin, merge_request.target_branch)
# remove source branch
if merge_request.should_remove_source_branch && !project.root_ref?(merge_request.source_branch)
if merge_request.should_remove_source_branch && !project.repository.root_ref?(merge_request.source_branch)
# will raise CommandFailed when push fails
merge_repo.git.push({raise: true, timeout: true}, :origin, ":#{merge_request.source_branch}")
end

View file

@ -1,4 +1,6 @@
module Gitlab
class SatelliteNotExistError < StandardError; end
module Satellite
class Satellite
PARKING_BRANCH = "__parking_branch"
@ -9,8 +11,12 @@ module Gitlab
@project = project
end
def raise_no_satellite
raise SatelliteNotExistError.new("Satellite doesn't exist")
end
def clear_and_update!
raise "Satellite doesn't exist" unless exists?
raise_no_satellite unless exists?
delete_heads!
clear_working_dir!
@ -18,7 +24,13 @@ module Gitlab
end
def create
`git clone #{project.url_to_repo} #{path}`
create_cmd = "git clone #{project.url_to_repo} #{path}"
if system(create_cmd)
true
else
Gitlab::GitLogger.error("Failed to create satellite for #{project.name_with_namespace}")
false
end
end
def exists?
@ -29,7 +41,7 @@ module Gitlab
# * Changes the current directory to the satellite's working dir
# * Yields
def lock
raise "Satellite doesn't exist" unless exists?
raise_no_satellite unless exists?
File.open(lock_file, "w+") do |f|
f.flock(File::LOCK_EX)
@ -49,7 +61,7 @@ module Gitlab
end
def repo
raise "Satellite doesn't exist" unless exists?
raise_no_satellite unless exists?
@repo ||= Grit::Repo.new(path)
end