From 6daa97f47212d89bfa0dcbb7f549ecb68d1b3783 Mon Sep 17 00:00:00 2001 From: Nilton Moura Date: Thu, 26 Dec 2013 17:13:25 -0200 Subject: Changed sudo by su -c The sudo command needs a tty to run. If you put this file on a CentOS 6, for example, it will not run in the host startup process. Instead, the 'su -c' runs the command apart if it has or not a tty. I tested this change in a fresh install of gitlab on a CentOS 6.5 with successful. --- lib/support/init.d/gitlab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/support/init.d/gitlab b/lib/support/init.d/gitlab index f1b94087b6a..42bd4785d56 100755 --- a/lib/support/init.d/gitlab +++ b/lib/support/init.d/gitlab @@ -41,7 +41,7 @@ test -f /etc/default/gitlab && . /etc/default/gitlab # Switch to the app_user if it is not he/she who is running the script. if [ "$USER" != "$app_user" ]; then - sudo -u "$app_user" -H -i $0 "$@"; exit; + eval su - "$app_user" -c $(echo \")$0 "$@"$(echo \"); exit; fi # Switch to the gitlab path, exit on failure. -- cgit v1.2.1 From 058aae5940762c18b3f099a6c3cb734041641390 Mon Sep 17 00:00:00 2001 From: Kyle Fazzari Date: Tue, 25 Feb 2014 19:10:35 -0500 Subject: Fixed Unicorn-Sidekiq confusion in GitLab init script. There were a few places in the included init script where Unicorn was referred to as Sidekiq and vice-versa. This fixes #126. --- lib/support/init.d/gitlab | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/support/init.d/gitlab b/lib/support/init.d/gitlab index c6e570784e0..d6716cdecce 100755 --- a/lib/support/init.d/gitlab +++ b/lib/support/init.d/gitlab @@ -131,7 +131,7 @@ check_stale_pids(){ fi fi if [ "$spid" != "0" -a "$sidekiq_status" != "0" ]; then - echo "Removing stale Sidekiq web server pid. This is most likely caused by the Sidekiq crashing the last time it ran." + echo "Removing stale Sidekiq job dispatcher pid. This is most likely caused by Sidekiq crashing the last time it ran." if ! rm "$sidekiq_pid_path"; then echo "Unable to remove stale pid, exiting" exit 1 @@ -155,9 +155,9 @@ start() { if [ "$web_status" != "0" -a "$sidekiq_status" != "0" ]; then echo -n "Starting both the GitLab Unicorn and Sidekiq" elif [ "$web_status" != "0" ]; then - echo -n "Starting GitLab Sidekiq" - elif [ "$sidekiq_status" != "0" ]; then echo -n "Starting GitLab Unicorn" + elif [ "$sidekiq_status" != "0" ]; then + echo -n "Starting GitLab Sidekiq" fi # Then check if the service is running. If it is: don't start again. @@ -190,9 +190,9 @@ stop() { if [ "$web_status" = "0" -a "$sidekiq_status" = "0" ]; then echo -n "Shutting down both Unicorn and Sidekiq" elif [ "$web_status" = "0" ]; then - echo -n "Shutting down Sidekiq" - elif [ "$sidekiq_status" = "0" ]; then echo -n "Shutting down Unicorn" + elif [ "$sidekiq_status" = "0" ]; then + echo -n "Shutting down Sidekiq" fi # If the Unicorn web server is running, tell it to stop; -- cgit v1.2.1 From 9886998f24b3d6e44aafc412b87980cb1755544c Mon Sep 17 00:00:00 2001 From: Stuart Pook Date: Wed, 19 Mar 2014 19:07:51 +0100 Subject: Add method to get the comments on a merge request Add method to get the comments for a merge request and document that you can change the status of a merge request. --- lib/api/merge_requests.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib') diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index e2458198411..3a1a00d0719 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -125,6 +125,22 @@ module API end end + # Get a merge request's comments + # + # Parameters: + # id (required) - The ID of a project + # merge_request_id (required) - ID of MR + # Examples: + # GET /projects/:id/merge_request/:merge_request_id/comments + # + get ":id/merge_request/:merge_request_id/comments" do + merge_request = user_project.merge_requests.find(params[:merge_request_id]) + + authorize! :read_merge_request, merge_request + + present paginate(merge_request.notes), with: Entities::MRNote + end + # Post comment to merge request # # Parameters: -- cgit v1.2.1 From 19c28822ef60da0f4eda380e6cab3be4a4cb18e5 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Mar 2014 21:01:00 +0200 Subject: Add Gitlab::GitAccess class to resolve auth issues during pull/push Signed-off-by: Dmitriy Zaporozhets --- lib/gitlab/git_access.rb | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 lib/gitlab/git_access.rb (limited to 'lib') diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb new file mode 100644 index 00000000000..5fb5505743f --- /dev/null +++ b/lib/gitlab/git_access.rb @@ -0,0 +1,74 @@ +module Gitlab + class GitAccess + DOWNLOAD_COMMANDS = %w{ git-upload-pack git-upload-archive } + PUSH_COMMANDS = %w{ git-receive-pack } + + attr_reader :params, :project, :git_cmd, :user + + def allowed?(actor, cmd, project, ref = nil, oldrev = nil, newrev = nil) + case cmd + when *DOWNLOAD_COMMANDS + if actor.is_a? User + download_allowed?(actor, project) + elsif actor.is_a? DeployKey + actor.projects.include?(project) + elsif actor.is_a? Key + download_allowed?(actor.user, project) + else + raise 'Wrong actor' + end + when *PUSH_COMMANDS + if actor.is_a? User + push_allowed?(actor, project, ref, oldrev, newrev) + elsif actor.is_a? DeployKey + # Deploy key not allowed to push + return false + elsif actor.is_a? Key + push_allowed?(actor.user, project, ref, oldrev, newrev) + else + raise 'Wrong actor' + end + else + false + end + end + + def download_allowed?(user, project) + if user_allowed?(user) + user.can?(:download_code, project) + else + false + end + end + + def push_allowed?(user, project, ref, oldrev, newrev) + if user_allowed?(user) + action = if project.protected_branch?(ref) + :push_code_to_protected_branches + else + :push_code + end + user.can?(action, project) + else + false + end + end + + private + + def user_allowed?(user) + return false if user.blocked? + + if Gitlab.config.ldap.enabled + if user.ldap_user? + # Check if LDAP user exists and match LDAP user_filter + unless Gitlab::LDAP::Access.new.allowed?(user) + return false + end + end + end + + true + end + end +end -- cgit v1.2.1 From f18a714f357405a87031250f4350343ae54d528f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Mar 2014 21:02:12 +0200 Subject: Use GitAccess in internal api Signed-off-by: Dmitriy Zaporozhets --- lib/api/internal.rb | 60 +++++++++++++++++------------------------------------ 1 file changed, 19 insertions(+), 41 deletions(-) (limited to 'lib') diff --git a/lib/api/internal.rb b/lib/api/internal.rb index 69aad3748b3..bcf97574673 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -1,16 +1,12 @@ module API # Internal access API class Internal < Grape::API - - DOWNLOAD_COMMANDS = %w{ git-upload-pack git-upload-archive } - PUSH_COMMANDS = %w{ git-receive-pack } - namespace 'internal' do - # - # Check if ssh key has access to project code + # Check if git command is allowed to project # # Params: - # key_id - SSH Key id + # key_id - ssh key id for Git over SSH + # user_id - user id for Git over HTTP # project - project path with namespace # action - git action (git-upload-pack or git-receive-pack) # ref - branch name @@ -22,43 +18,25 @@ module API # the wiki repository as well. project_path = params[:project] project_path.gsub!(/\.wiki/,'') if project_path =~ /\.wiki/ - - key = Key.find(params[:key_id]) project = Project.find_with_namespace(project_path) - git_cmd = params[:action] return false unless project - - if key.is_a? DeployKey - key.projects.include?(project) && DOWNLOAD_COMMANDS.include?(git_cmd) - else - user = key.user - - return false if user.blocked? - - if Gitlab.config.ldap.enabled - if user.ldap_user? - # Check if LDAP user exists and match LDAP user_filter - unless Gitlab::LDAP::Access.new.allowed?(user) - return false - end - end - end - - action = case git_cmd - when *DOWNLOAD_COMMANDS - then :download_code - when *PUSH_COMMANDS - then - if project.protected_branch?(params[:ref]) - :push_code_to_protected_branches - else - :push_code - end - end - - user.can?(action, project) - end + actor = if params[:key_id] + Key.find(params[:key_id]) + elsif params[:user_id] + User.find(params[:user_id]) + end + + return false unless actor + + Gitlab::GitAccess.new.allowed?( + actor, + params[:action], + project, + params[:ref], + params[:oldrev], + params[:newrev] + ) end # -- cgit v1.2.1 From 729b358ff2981d8931e27fdc33d29b9528232c32 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Mar 2014 21:02:39 +0200 Subject: push via http now served via /allowed API Signed-off-by: Dmitriy Zaporozhets --- lib/gitlab/backend/grack_auth.rb | 47 +++++----------------------------------- 1 file changed, 5 insertions(+), 42 deletions(-) (limited to 'lib') diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb index 60c03ce1c04..ee99bd5f7de 100644 --- a/lib/gitlab/backend/grack_auth.rb +++ b/lib/gitlab/backend/grack_auth.rb @@ -5,7 +5,7 @@ module Grack class Auth < Rack::Auth::Basic include Helpers - attr_accessor :user, :project, :ref, :env + attr_accessor :user, :project, :env def call(env) @env = env @@ -80,24 +80,11 @@ module Grack def authorize_request(service) case service when 'git-upload-pack' - can?(user, :download_code, project) - when'git-receive-pack' - refs.each do |ref| - action = if project.protected_branch?(ref) - :push_code_to_protected_branches - else - :push_code - end - - return false unless can?(user, action, project) - end - - # Never let git-receive-pack trough unauthenticated; it's - # harmless but git < 1.8 doesn't like it - return false if user.nil? - true + # Serve only upload request. + # Authorization on push will be serverd by update hook in repository + Gitlab::GitAccess.new.download_allowed?(user, project) else - false + true end end @@ -114,29 +101,5 @@ module Grack def project @project ||= project_by_path(@request.path_info) end - - def refs - @refs ||= parse_refs - end - - def parse_refs - input = if @env["HTTP_CONTENT_ENCODING"] =~ /gzip/ - Zlib::GzipReader.new(@request.body).read - else - @request.body.read - end - - # Need to reset seek point - @request.body.rewind - - # Parse refs - refs = input.force_encoding('ascii-8bit').scan(/refs\/heads\/([\/\w\.-]+)/n).flatten.compact - - # Cleanup grabare from refs - # if push to multiple branches - refs.map do |ref| - ref.gsub(/00.*/, "") - end - end end end -- cgit v1.2.1 From 83e83b6617694c03457ca3a36230b54560ce6833 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 20 Mar 2014 10:53:03 +0200 Subject: Improve grack auth Signed-off-by: Dmitriy Zaporozhets --- lib/gitlab/backend/grack_auth.rb | 21 +++++++++++++++++---- lib/gitlab/backend/grack_helpers.rb | 28 ---------------------------- 2 files changed, 17 insertions(+), 32 deletions(-) delete mode 100644 lib/gitlab/backend/grack_helpers.rb (limited to 'lib') diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb index ee99bd5f7de..b3e111354f5 100644 --- a/lib/gitlab/backend/grack_auth.rb +++ b/lib/gitlab/backend/grack_auth.rb @@ -1,9 +1,7 @@ require_relative 'shell_env' -require_relative 'grack_helpers' module Grack class Auth < Rack::Auth::Basic - include Helpers attr_accessor :user, :project, :env @@ -79,12 +77,14 @@ module Grack def authorize_request(service) case service - when 'git-upload-pack' + when *Gitlab::GitAccess::DOWNLOAD_COMMANDS # Serve only upload request. # Authorization on push will be serverd by update hook in repository Gitlab::GitAccess.new.download_allowed?(user, project) - else + when *Gitlab::GitAccess::PUSH_COMMANDS true + else + false end end @@ -101,5 +101,18 @@ module Grack def project @project ||= project_by_path(@request.path_info) end + + def project_by_path(path) + if m = /^([\w\.\/-]+)\.git/.match(path).to_a + path_with_namespace = m.last + path_with_namespace.gsub!(/\.wiki$/, '') + + Project.find_with_namespace(path_with_namespace) + end + end + + def render_not_found + [404, {"Content-Type" => "text/plain"}, ["Not Found"]] + end end end diff --git a/lib/gitlab/backend/grack_helpers.rb b/lib/gitlab/backend/grack_helpers.rb deleted file mode 100644 index cb747fe0137..00000000000 --- a/lib/gitlab/backend/grack_helpers.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Grack - module Helpers - def project_by_path(path) - if m = /^([\w\.\/-]+)\.git/.match(path).to_a - path_with_namespace = m.last - path_with_namespace.gsub!(/\.wiki$/, '') - - Project.find_with_namespace(path_with_namespace) - end - end - - def render_not_found - [404, {"Content-Type" => "text/plain"}, ["Not Found"]] - end - - def can?(object, action, subject) - abilities.allowed?(object, action, subject) - end - - def abilities - @abilities ||= begin - abilities = Six.new - abilities << Ability - abilities - end - end - end -end -- cgit v1.2.1 From e013be10d7185dcdc814c11a65537ecd903e404d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 20 Mar 2014 13:37:35 +0200 Subject: GitLab requires gitlab-shell v1.9.0 Signed-off-by: Dmitriy Zaporozhets --- lib/tasks/gitlab/check.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index d4d5e48ce3f..067735d66b1 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -742,7 +742,7 @@ namespace :gitlab do end def check_gitlab_shell - required_version = Gitlab::VersionInfo.new(1, 8, 5) + required_version = Gitlab::VersionInfo.new(1, 9, 0) current_version = Gitlab::VersionInfo.parse(gitlab_shell_version) print "GitLab Shell version >= #{required_version} ? ... " -- cgit v1.2.1 From 5f595be4b80ae57c92d01dc1c0026566f80e67d4 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Thu, 20 Mar 2014 13:30:27 +0100 Subject: Use new gems methods. --- lib/gitlab/markdown.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index e72f4f5d0ce..80bb00821f7 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -152,7 +152,7 @@ module Gitlab # # Returns boolean def valid_emoji?(emoji) - Emoji.names.include? emoji + Emoji.find_by_name emoji end # Private: Dispatches to a dedicated processing method based on reference -- cgit v1.2.1 From 44aa6b90ddde3a7babc6ed9f50d73040d6184789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81bner=20Silva=20de=20Oliveira?= Date: Fri, 21 Mar 2014 06:18:19 -0300 Subject: added api method to return labels of a given project --- lib/api/entities.rb | 4 ++++ lib/api/projects.rb | 9 +++++++++ 2 files changed, 13 insertions(+) (limited to 'lib') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 8b4519af2d1..9fa8506926c 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -187,5 +187,9 @@ module API end end end + + class Label < Grape::Entity + expose :name + end end end diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 4d48d2194f8..40b5ce86c93 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -215,6 +215,15 @@ module API @users = paginate @users present @users, with: Entities::User end + + # Get a labels list + # + # Example Request: + # GET /users + get ':id/labels' do + @labels = user_project.issues_labels + present @labels, with: Entities::Label + end end end end -- cgit v1.2.1 From 895c913247e0444374316ea46dec9304ce1efdf4 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Fri, 21 Mar 2014 12:42:59 +0100 Subject: Use the latest tag, 1.9.1 for gitlab-shell. --- lib/tasks/gitlab/check.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 067735d66b1..071760c0c36 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -742,7 +742,7 @@ namespace :gitlab do end def check_gitlab_shell - required_version = Gitlab::VersionInfo.new(1, 9, 0) + required_version = Gitlab::VersionInfo.new(1, 9, 1) current_version = Gitlab::VersionInfo.parse(gitlab_shell_version) print "GitLab Shell version >= #{required_version} ? ... " -- cgit v1.2.1 From 7dd18a3ec832cb5e49932dff33f3a4ced30fe1e8 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Mar 2014 14:52:30 +0200 Subject: Fix http clone for public project Signed-off-by: Dmitriy Zaporozhets --- lib/gitlab/backend/grack_auth.rb | 60 ++++++++++++++++++++++++---------------- lib/gitlab/git_access.rb | 4 +-- 2 files changed, 38 insertions(+), 26 deletions(-) (limited to 'lib') diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb index b3e111354f5..de18d904916 100644 --- a/lib/gitlab/backend/grack_auth.rb +++ b/lib/gitlab/backend/grack_auth.rb @@ -22,14 +22,16 @@ module Grack @env['SCRIPT_NAME'] = "" - auth! + if project + auth! + else + render_not_found + end end private def auth! - return render_not_found unless project - if @auth.provided? return bad_request unless @auth.basic? @@ -38,12 +40,8 @@ module Grack # Allow authentication for GitLab CI service # if valid token passed - if login == "gitlab-ci-token" && project.gitlab_ci? - token = project.gitlab_ci_service.token - - if token.present? && token == password && service_name == 'git-upload-pack' - return @app.call(env) - end + if gitlab_ci_request?(login, password) + return @app.call(env) end @user = authenticate_user(login, password) @@ -51,23 +49,26 @@ module Grack if @user Gitlab::ShellEnv.set_env(@user) @env['REMOTE_USER'] = @auth.username - else - return unauthorized end - - else - return unauthorized unless project.public? end - if authorized_git_request? + if authorized_request? @app.call(env) else unauthorized end end - def authorized_git_request? - authorize_request(service_name) + def gitlab_ci_request?(login, password) + if login == "gitlab-ci-token" && project.gitlab_ci? + token = project.gitlab_ci_service.token + + if token.present? && token == password && git_cmd == 'git-upload-pack' + true + end + end + + false end def authenticate_user(login, password) @@ -75,20 +76,31 @@ module Grack auth.find(login, password) end - def authorize_request(service) - case service + def authorized_request? + case git_cmd when *Gitlab::GitAccess::DOWNLOAD_COMMANDS - # Serve only upload request. - # Authorization on push will be serverd by update hook in repository - Gitlab::GitAccess.new.download_allowed?(user, project) + if user + Gitlab::GitAccess.new.download_allowed?(user, project) + elsif project.public? + # Allow clone/fetch for public projects + true + else + false + end when *Gitlab::GitAccess::PUSH_COMMANDS - true + if user + # Skip user authorization on upload request. + # It will be serverd by update hook in repository + true + else + false + end else false end end - def service_name + def git_cmd if @request.get? @request.params['service'] elsif @request.post? diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index 5fb5505743f..1ab8f9213a3 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -34,7 +34,7 @@ module Gitlab end def download_allowed?(user, project) - if user_allowed?(user) + if user && user_allowed?(user) user.can?(:download_code, project) else false @@ -42,7 +42,7 @@ module Gitlab end def push_allowed?(user, project, ref, oldrev, newrev) - if user_allowed?(user) + if user && user_allowed?(user) action = if project.protected_branch?(ref) :push_code_to_protected_branches else -- cgit v1.2.1 From 5c038d949f1e40939548c530214d65d33ab94904 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Mar 2014 23:04:57 +0200 Subject: Fix gitlab-ci integration Signed-off-by: Dmitriy Zaporozhets --- lib/gitlab/backend/grack_auth.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb index de18d904916..c2f3b851c07 100644 --- a/lib/gitlab/backend/grack_auth.rb +++ b/lib/gitlab/backend/grack_auth.rb @@ -64,7 +64,7 @@ module Grack token = project.gitlab_ci_service.token if token.present? && token == password && git_cmd == 'git-upload-pack' - true + return true end end -- cgit v1.2.1 From ae1a3148242907b21e9952f1964919622b4f3129 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Mar 2014 23:08:36 +0200 Subject: Fix upgrader Signed-off-by: Dmitriy Zaporozhets --- lib/gitlab/upgrader.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/gitlab/upgrader.rb b/lib/gitlab/upgrader.rb index 0fe4888665d..0846359f9b1 100644 --- a/lib/gitlab/upgrader.rb +++ b/lib/gitlab/upgrader.rb @@ -1,3 +1,4 @@ +require_relative "popen" require_relative "version_info" module Gitlab -- cgit v1.2.1 From fa340595746ba18fae3c6422ff4c9ea4af8e3023 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 22 Mar 2014 15:36:54 -0400 Subject: Default message for SatelliteNotExistError --- lib/gitlab/satellite/satellite.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/gitlab/satellite/satellite.rb b/lib/gitlab/satellite/satellite.rb index bcf3012bd92..9e3c3997e55 100644 --- a/lib/gitlab/satellite/satellite.rb +++ b/lib/gitlab/satellite/satellite.rb @@ -1,5 +1,9 @@ module Gitlab - class SatelliteNotExistError < StandardError; end + class SatelliteNotExistError < StandardError + def initialize(msg = "Satellite doesn't exist") + super + end + end module Satellite class Satellite @@ -17,12 +21,8 @@ module Gitlab Gitlab::Satellite::Logger.error(message) end - def raise_no_satellite - raise SatelliteNotExistError.new("Satellite doesn't exist") - end - def clear_and_update! - raise_no_satellite unless exists? + raise SatelliteNotExistError unless exists? File.exists? path @repo = nil @@ -55,7 +55,7 @@ module Gitlab # * Changes the current directory to the satellite's working dir # * Yields def lock - raise_no_satellite unless exists? + raise SatelliteNotExistError unless exists? File.open(lock_file, "w+") do |f| begin @@ -77,7 +77,7 @@ module Gitlab end def repo - raise_no_satellite unless exists? + raise SatelliteNotExistError unless exists? @repo ||= Grit::Repo.new(path) end -- cgit v1.2.1 From 760f827ba0257d6664f429a832d1962fcac6e58e Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 22 Mar 2014 15:40:42 -0400 Subject: Remove code that does nothing ping @karlhungus --- lib/gitlab/satellite/satellite.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'lib') diff --git a/lib/gitlab/satellite/satellite.rb b/lib/gitlab/satellite/satellite.rb index 9e3c3997e55..bdfcf254e9e 100644 --- a/lib/gitlab/satellite/satellite.rb +++ b/lib/gitlab/satellite/satellite.rb @@ -24,7 +24,6 @@ module Gitlab def clear_and_update! raise SatelliteNotExistError unless exists? - File.exists? path @repo = nil clear_working_dir! delete_heads! -- cgit v1.2.1 From e153469f31db106d0720e357a5e22431635f2b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81bner=20Silva=20de=20Oliveira?= Date: Sun, 23 Mar 2014 19:07:18 -0300 Subject: changed doc comment for get labels of a project --- lib/api/projects.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 40b5ce86c93..9d290c75ba9 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -216,10 +216,12 @@ module API present @users, with: Entities::User end - # Get a labels list + # Get a project labels # + # Parameters: + # id (required) - The ID of a project # Example Request: - # GET /users + # GET /projects/:id/labels get ':id/labels' do @labels = user_project.issues_labels present @labels, with: Entities::Label -- cgit v1.2.1 From 8af94ed75505f0253823b9b2d44320fecea5b5fb Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Mon, 24 Mar 2014 14:59:09 +0100 Subject: Add gzip compression for assets to nginx example. --- lib/support/nginx/gitlab | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib') diff --git a/lib/support/nginx/gitlab b/lib/support/nginx/gitlab index 7a0f3efbb53..5bff362da0e 100644 --- a/lib/support/nginx/gitlab +++ b/lib/support/nginx/gitlab @@ -54,6 +54,14 @@ server { proxy_pass http://gitlab; } + # Enable gzip compression as per rails guide: http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression + location ~ ^/(assets)/ { + root /home/git/gitlab/public; + gzip_static on; # to serve pre-gzipped version + expires max; + add_header Cache-Control public; + } + error_page 502 /502.html; } -- cgit v1.2.1 From 73a987ea6bedd569e24f37d323883a7dbeb3ae56 Mon Sep 17 00:00:00 2001 From: Nick Downs Date: Fri, 31 Jan 2014 21:14:05 -0800 Subject: Removed the backgrounding of the unicorn_rails webapp start call. --- lib/support/init.d/gitlab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/support/init.d/gitlab b/lib/support/init.d/gitlab index ff584e69058..701db3e7d52 100755 --- a/lib/support/init.d/gitlab +++ b/lib/support/init.d/gitlab @@ -167,7 +167,7 @@ start() { # Remove old socket if it exists rm -f "$socket_path"/gitlab.socket 2>/dev/null # Start the web server - RAILS_ENV=$RAILS_ENV script/web start & + RAILS_ENV=$RAILS_ENV script/web start fi # If sidekiq is already running, don't start it again. -- cgit v1.2.1 From 02850210b6694983bed0c3eb7ad8dedfc7d95c54 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 25 Mar 2014 09:52:27 +0100 Subject: Allow referencing an existing user. --- lib/gitlab/markdown.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index 80bb00821f7..1d3c6ac6eea 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -166,8 +166,8 @@ module Gitlab end def reference_user(identifier) - if member = @project.team_members.find { |user| user.username == identifier } - link_to("@#{identifier}", user_url(identifier), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) if member + if user = User.find_by_username(identifier) + link_to("@#{identifier}", user_url(identifier), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) if user end end -- cgit v1.2.1 From 9dd58c320a38cbcaf8134157103b2b2a2fad76d2 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 25 Mar 2014 17:54:32 +0100 Subject: Add to changelog. --- lib/gitlab/markdown.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index 1d3c6ac6eea..de14a3eca27 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -167,7 +167,7 @@ module Gitlab def reference_user(identifier) if user = User.find_by_username(identifier) - link_to("@#{identifier}", user_url(identifier), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) if user + link_to("@#{identifier}", user_url(identifier), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) end end -- cgit v1.2.1 From 9422b451eb622196036ec3429bb61ac9a7078c2a Mon Sep 17 00:00:00 2001 From: Pawel Krzaczkowski Date: Thu, 19 Dec 2013 10:52:29 +0100 Subject: Init script - change start() stop() restart() reload() to xxxx_gitlab() --- lib/support/init.d/gitlab | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/support/init.d/gitlab b/lib/support/init.d/gitlab index ff584e69058..0308181b86b 100755 --- a/lib/support/init.d/gitlab +++ b/lib/support/init.d/gitlab @@ -149,7 +149,7 @@ exit_if_not_running(){ } ## Starts Unicorn and Sidekiq if they're not running. -start() { +start_gitlab() { check_stale_pids if [ "$web_status" != "0" -a "$sidekiq_status" != "0" ]; then @@ -184,7 +184,7 @@ start() { } ## Asks the Unicorn and the Sidekiq if they would be so kind as to stop, if not kills them. -stop() { +stop_gitlab() { exit_if_not_running if [ "$web_status" = "0" -a "$sidekiq_status" = "0" ]; then @@ -246,7 +246,7 @@ print_status() { } ## Tells unicorn to reload it's config and Sidekiq to restart -reload(){ +reload_gitlab(){ exit_if_not_running if [ "$wpid" = "0" ];then echo "The GitLab Unicorn Web server is not running thus its configuration can't be reloaded." @@ -263,12 +263,12 @@ reload(){ } ## Restarts Sidekiq and Unicorn. -restart(){ +restart_gitlab(){ check_status if [ "$web_status" = "0" -o "$sidekiq_status" = "0" ]; then - stop + stop_gitlab fi - start + start_gitlab } @@ -276,16 +276,16 @@ restart(){ case "$1" in start) - start + start_gitlab ;; stop) - stop + stop_gitlab ;; restart) - restart + restart_gitlab ;; reload|force-reload) - reload + reload_gitlab ;; status) print_status -- cgit v1.2.1 From 7bf92b368fae70c835c729515f9dac1fb766c185 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Wed, 26 Mar 2014 15:38:14 +0100 Subject: Ldap check recognize ldap user filter. --- lib/tasks/gitlab/check.rake | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 071760c0c36..3b9b2531bf7 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -677,7 +677,20 @@ namespace :gitlab do end def filter - Net::LDAP::Filter.present?(ldap_config.uid) + uid_filter = Net::LDAP::Filter.present?(ldap_config.uid) + if user_filter + Net::LDAP::Filter.join(uid_filter, user_filter) + else + uid_filter + end + end + + def user_filter + if ldap_config['user_filter'] && ldap_config.user_filter.present? + Net::LDAP::Filter.construct(ldap_config.user_filter) + else + nil + end end def ldap -- cgit v1.2.1