Merge branch 'master' into discussions

Conflicts:
	app/assets/stylesheets/main.scss
	app/models/project.rb
	app/views/notes/_common_form.html.haml
	app/views/notes/_per_line_form.html.haml
	lib/gitlab/markdown.rb
	spec/models/note_spec.rb
This commit is contained in:
Riyad Preukschas 2012-12-23 01:03:57 +01:00
commit db2c15369c
276 changed files with 4466 additions and 2603 deletions

View file

@ -38,7 +38,7 @@ module Gitlab
email: email,
password: password,
password_confirmation: password,
projects_limit: Gitlab.config.default_projects_limit,
projects_limit: Gitlab.config.gitlab.default_projects_limit,
}, as: :admin)
if Gitlab.config.omniauth['block_auto_created_users'] && !ldap
@user.blocked = true

View file

@ -38,7 +38,7 @@ module Gitlab
end
def url_to_repo path
Gitlab.config.ssh_path + "#{path}.git"
Gitlab.config.gitolite.ssh_path_prefix + "#{path}.git"
end
def enable_automerge

View file

@ -16,7 +16,7 @@ module Gitlab
def ga_repo
@ga_repo ||= ::Gitolite::GitoliteAdmin.new(
File.join(config_tmp_dir,'gitolite'),
conf: Gitlab.config.gitolite_config_file
conf: Gitlab.config.gitolite.config_file
)
end
@ -167,7 +167,7 @@ module Gitlab
# Enable access to all repos for gitolite admin.
# We use it for accept merge request feature
def admin_all_repo
owner_name = Gitlab.config.gitolite_admin_key
owner_name = Gitlab.config.gitolite.admin_key
# @ALL repos premission for gitolite owner
repo_name = "@all"
@ -189,7 +189,7 @@ module Gitlab
def pull tmp_dir
Dir.mkdir tmp_dir
`git clone #{Gitlab.config.gitolite_admin_uri} #{tmp_dir}/gitolite`
`git clone #{Gitlab.config.gitolite.admin_uri} #{tmp_dir}/gitolite`
unless File.exists?(File.join(tmp_dir, 'gitolite', 'conf', 'gitolite.conf'))
raise PullError, "unable to clone gitolite-admin repo"

View file

@ -38,12 +38,12 @@ module Grack
end
def validate_get_request
true
can?(user, :download_code, project)
end
def validate_post_request
if @request.path_info.end_with?('git-upload-pack')
can?(user, :push_code, project)
can?(user, :download_code, project)
elsif @request.path_info.end_with?('git-receive-pack')
action = if project.protected_branch?(current_ref)
:push_code_to_protected_branches

View file

@ -28,7 +28,7 @@ module Gitlab
h[:refs] = refs.collect{|r|r.name}.join(" ") unless refs.nil?
h[:id] = sha
h[:date] = date
h[:message] = escape_once(message)
h[:message] = message
h[:login] = author.email
h
end

View file

@ -17,16 +17,15 @@ module Gitlab
@commits = collect_commits
@days = index_commits
end
def days_json
@days_json = @days.compact.map { |d| [d.day, d.strftime("%b")] }.to_json
def to_json(*args)
{
days: @days.compact.map { |d| [d.day, d.strftime("%b")] },
commits: @commits.map(&:to_graph_hash)
}.to_json(*args)
end
def commits_json
@commits_json = @commits.map(&:to_graph_hash).to_json
end
protected
protected
# Get commits from repository
#

View file

@ -14,6 +14,11 @@ module Gitlab
logs = `tail -n 2000 #{path}`.split("\n")
end
def self.read_latest_for filename
path = Rails.root.join("log", filename)
logs = `tail -n 2000 #{path}`.split("\n")
end
def self.build
new(Rails.root.join("log", file_name))
end

View file

@ -81,28 +81,32 @@ module Gitlab
end
REFERENCE_PATTERN = %r{
(\W)? # Prefix (1)
( # Reference (2)
@([\w\._]+) # User name (3)
|[#!$](\d+) # Issue/MR/Snippet ID (4)
|([\h]{6,40}) # Commit ID (5)
(?<prefix>\W)? # Prefix
( # Reference
@(?<user>[a-zA-Z][a-zA-Z0-9_\-\.]*) # User name
|\#(?<issue>\d+) # Issue ID
|!(?<merge_request>\d+) # MR ID
|\$(?<snippet>\d+) # Snippet ID
|(?<commit>[\h]{6,40}) # Commit ID
)
(\W)? # Suffix (6)
(?<suffix>\W)? # Suffix
}x.freeze
TYPES = [:user, :issue, :merge_request, :snippet, :commit].freeze
def parse_references(text)
# parse reference links
text.gsub!(REFERENCE_PATTERN) do |match|
prefix = $1 || ''
reference = $2
identifier = $3 || $4 || $5
suffix = $6 || ''
prefix = $~[:prefix]
suffix = $~[:suffix]
type = TYPES.select{|t| !$~[t].nil?}.first
identifier = $~[type]
# Avoid HTML entities
if prefix.ends_with?('&') || suffix.starts_with?(';')
if prefix && suffix && prefix[0] == '&' && suffix[-1] == ';'
match
elsif ref_link = reference_link(reference, identifier)
prefix + ref_link + suffix
elsif ref_link = reference_link(type, identifier)
"#{prefix}#{ref_link}#{suffix}"
else
match
end
@ -115,7 +119,7 @@ module Gitlab
# parse emoji
text.gsub!(EMOJI_PATTERN) do |match|
if valid_emoji?($2)
image_tag("emoji/#{$2}.png", class: 'emoji', title: $1, alt: $1)
image_tag("emoji/#{$2}.png", class: 'emoji', title: $1, alt: $1, size: "20x20")
else
match
end
@ -137,19 +141,12 @@ module Gitlab
# identifier - Object identifier (Issue ID, SHA hash, etc.)
#
# Returns string rendered by the processing method
def reference_link(reference, identifier)
case reference
when /^@/ then reference_user(identifier)
when /^#/ then reference_issue(identifier)
when /^!/ then reference_merge_request(identifier)
when /^\$/ then reference_snippet(identifier)
when /^\h/ then reference_commit(identifier)
end
def reference_link(type, identifier)
send("reference_#{type}", identifier)
end
def reference_user(identifier)
if user = @project.users.where(name: identifier).first
member = @project.users_projects.where(user_id: user).first
if member = @project.users_projects.joins(:user).where(users: { username: identifier }).first
link_to("@#{identifier}", project_team_member_path(@project, member), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) if member
end
end

View file

@ -15,10 +15,10 @@ module Gitlab
def execute
# Create new dir if missing
new_dir_path = File.join(Gitlab.config.git_base_path, new_dir)
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)
old_path = File.join(Gitlab.config.git_base_path, old_dir, "#{project.path}.git")
old_path = File.join(Gitlab.config.gitolite.repos_path, old_dir, "#{project.path}.git")
new_path = File.join(new_dir_path, "#{project.path}.git")
if File.exists? new_path