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:
commit
db2c15369c
276 changed files with 4466 additions and 2603 deletions
|
@ -47,7 +47,7 @@ module Account
|
|||
end
|
||||
|
||||
def cared_merge_requests
|
||||
MergeRequest.where("author_id = :id or assignee_id = :id", id: self.id).opened
|
||||
MergeRequest.where("author_id = :id or assignee_id = :id", id: self.id)
|
||||
end
|
||||
|
||||
def project_ids
|
||||
|
@ -105,4 +105,20 @@ module Account
|
|||
def namespace_id
|
||||
namespace.try :id
|
||||
end
|
||||
|
||||
def authorized_groups
|
||||
@authorized_groups ||= begin
|
||||
groups = Group.where(id: self.projects.pluck(:namespace_id)).all
|
||||
groups = groups + self.groups
|
||||
groups.uniq
|
||||
end
|
||||
end
|
||||
|
||||
def authorized_projects
|
||||
Project.authorized_for(self)
|
||||
end
|
||||
|
||||
def my_own_projects
|
||||
Project.personal(self)
|
||||
end
|
||||
end
|
||||
|
|
59
app/roles/namespaced_project.rb
Normal file
59
app/roles/namespaced_project.rb
Normal file
|
@ -0,0 +1,59 @@
|
|||
module NamespacedProject
|
||||
def transfer(new_namespace)
|
||||
Project.transaction do
|
||||
old_namespace = namespace
|
||||
self.namespace = new_namespace
|
||||
|
||||
old_dir = old_namespace.try(:path) || ''
|
||||
new_dir = new_namespace.try(:path) || ''
|
||||
|
||||
old_repo = if old_dir.present?
|
||||
File.join(old_dir, self.path)
|
||||
else
|
||||
self.path
|
||||
end
|
||||
|
||||
if Project.where(path: self.path, namespace_id: new_namespace.try(:id)).present?
|
||||
raise TransferError.new("Project with same path in target namespace already exists")
|
||||
end
|
||||
|
||||
Gitlab::ProjectMover.new(self, old_dir, new_dir).execute
|
||||
|
||||
git_host.move_repository(old_repo, self)
|
||||
|
||||
save!
|
||||
end
|
||||
rescue Gitlab::ProjectMover::ProjectMoveError => ex
|
||||
raise TransferError.new(ex.message)
|
||||
end
|
||||
|
||||
def name_with_namespace
|
||||
@name_with_namespace ||= begin
|
||||
if namespace
|
||||
namespace.human_name + " / " + name
|
||||
else
|
||||
name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def namespace_owner
|
||||
namespace.try(:owner)
|
||||
end
|
||||
|
||||
def chief
|
||||
if namespace
|
||||
namespace_owner
|
||||
else
|
||||
owner
|
||||
end
|
||||
end
|
||||
|
||||
def path_with_namespace
|
||||
if namespace
|
||||
namespace.path + '/' + path
|
||||
else
|
||||
path
|
||||
end
|
||||
end
|
||||
end
|
37
app/roles/note_event.rb
Normal file
37
app/roles/note_event.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
module NoteEvent
|
||||
def note_commit_id
|
||||
target.commit_id
|
||||
end
|
||||
|
||||
def note_short_commit_id
|
||||
note_commit_id[0..8]
|
||||
end
|
||||
|
||||
def note_commit?
|
||||
target.noteable_type == "Commit"
|
||||
end
|
||||
|
||||
def note_target
|
||||
target.noteable
|
||||
end
|
||||
|
||||
def note_target_id
|
||||
if note_commit?
|
||||
target.commit_id
|
||||
else
|
||||
target.noteable_id.to_s
|
||||
end
|
||||
end
|
||||
|
||||
def wall_note?
|
||||
target.noteable_type.blank?
|
||||
end
|
||||
|
||||
def note_target_type
|
||||
if target.noteable_type.present?
|
||||
target.noteable_type.titleize
|
||||
else
|
||||
"Wall"
|
||||
end.downcase
|
||||
end
|
||||
end
|
|
@ -114,7 +114,7 @@ module PushObserver
|
|||
id: commit.id,
|
||||
message: commit.safe_message,
|
||||
timestamp: commit.date.xmlschema,
|
||||
url: "#{Gitlab.config.url}/#{path}/commits/#{commit.id}",
|
||||
url: "#{Gitlab.config.gitlab.url}/#{path_with_namespace}/commit/#{commit.id}",
|
||||
author: {
|
||||
name: commit.author_name,
|
||||
email: commit.author_email
|
||||
|
|
|
@ -45,8 +45,22 @@ module Repository
|
|||
end
|
||||
|
||||
def has_post_receive_file?
|
||||
hook_file = File.join(path_to_repo, 'hooks', 'post-receive')
|
||||
File.exists?(hook_file)
|
||||
!!hook_file
|
||||
end
|
||||
|
||||
def valid_post_receive_file?
|
||||
valid_hook_file == hook_file
|
||||
end
|
||||
|
||||
def valid_hook_file
|
||||
@valid_hook_file ||= File.read(Rails.root.join('lib', 'hooks', 'post-receive'))
|
||||
end
|
||||
|
||||
def hook_file
|
||||
@hook_file ||= begin
|
||||
hook_path = File.join(path_to_repo, 'hooks', 'post-receive')
|
||||
File.read(hook_path) if File.exists?(hook_path)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns an Array of branch names
|
||||
|
@ -83,7 +97,7 @@ module Repository
|
|||
end
|
||||
|
||||
def path_to_repo
|
||||
File.join(Gitlab.config.git_base_path, "#{path_with_namespace}.git")
|
||||
File.join(Gitlab.config.gitolite.repos_path, "#{path_with_namespace}.git")
|
||||
end
|
||||
|
||||
def namespace_dir
|
||||
|
@ -185,7 +199,7 @@ module Repository
|
|||
end
|
||||
|
||||
def http_url_to_repo
|
||||
http_url = [Gitlab.config.url, "/", path_with_namespace, ".git"].join('')
|
||||
http_url = [Gitlab.config.gitlab.url, "/", path_with_namespace, ".git"].join('')
|
||||
end
|
||||
|
||||
# Check if current branch name is marked as protected in the system
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue