mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-10 21:26:07 +10:00
Add option to mirror an upstream repository. Closes internal https://dev.gitlab.org/gitlab/gitlab-ee/issues/279 Depends on gitlab-org/gitlab-shell!29 To do: - [x] Decide on what user should be the author of the activity feed events. The initial project creator perhaps? That makes sense for personal projects, but less so for group projects, where it's even possible that the creator has since left the team. - [x] Write specs! - [x] Write documentation - [x] Port back relevant commits to CE: gitlab-org/gitlab-ce!1822 ---- ## Mirror status on project homepage  ## Settings navigation item  ## Mirroring settings  ## Activity feed with new "pushes" (mirror updates)  I have yet to decide on what user should be the author of these events. The initial project creator perhaps? That makes sense for personal projects, but less so for group projects, where it's even possible that the creator has since left the team. ## Warning that branch has diverged from upstream  ## Commits heading after failed update  Link send user to the mirroring settings if they are a project admin. ## Mirroring settings after failed update  ## New project page  ## Import form after failed import (Screenshot outdated)  Shown when the initial import of a project fails, not when an update of an existing project fails. cc @dzaporozhets @sytses @JobV See merge request !51
58 lines
1.6 KiB
Ruby
58 lines
1.6 KiB
Ruby
class AutocompleteController < ApplicationController
|
|
skip_before_action :authenticate_user!, only: [:users]
|
|
|
|
def users
|
|
begin
|
|
@users =
|
|
if params[:project_id].present?
|
|
project = Project.find(params[:project_id])
|
|
|
|
if can?(current_user, :read_project, project)
|
|
project.team.users
|
|
end
|
|
elsif params[:group_id]
|
|
group = Group.find(params[:group_id])
|
|
|
|
if can?(current_user, :read_group, group)
|
|
group.users
|
|
end
|
|
elsif current_user
|
|
User.all
|
|
end
|
|
rescue ActiveRecord::RecordNotFound
|
|
if current_user
|
|
return render json: {}, status: 404
|
|
end
|
|
end
|
|
|
|
if @users.nil? && current_user.nil?
|
|
authenticate_user!
|
|
end
|
|
|
|
@users ||= User.none
|
|
@users = @users.non_ldap if params[:skip_ldap] == 'true'
|
|
@users = @users.search(params[:search]) if params[:search].present?
|
|
@users = @users.active
|
|
@users = @users.reorder(:name)
|
|
if params[:push_code_to_protected_branches] && project
|
|
@users = @users.to_a.select { |user| user.can?(:push_code_to_protected_branches, project) }.take(PER_PAGE)
|
|
else
|
|
@users = @users.page(params[:page]).per(PER_PAGE)
|
|
end
|
|
|
|
unless params[:search].present?
|
|
# Include current user if available to filter by "Me"
|
|
if params[:current_user] && current_user
|
|
@users = [*@users, current_user].uniq
|
|
end
|
|
end
|
|
|
|
render json: @users, only: [:name, :username, :id], methods: [:avatar_url]
|
|
end
|
|
|
|
def user
|
|
@user = User.find(params[:id])
|
|
render json: @user, only: [:name, :username, :id], methods: [:avatar_url]
|
|
end
|
|
end
|