From 1875141a963a4238bda29011d8f7105839485253 Mon Sep 17 00:00:00 2001 From: Dale Hamel Date: Tue, 8 Oct 2013 13:36:16 -0500 Subject: Ensure directory exists before changing in popen If the directory does not exist, we want to ensure that it does. Forking repos will fail in some situations because of this issue. --- lib/gitlab/popen.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib') diff --git a/lib/gitlab/popen.rb b/lib/gitlab/popen.rb index 2f30fde2078..369d6cc1f5d 100644 --- a/lib/gitlab/popen.rb +++ b/lib/gitlab/popen.rb @@ -1,9 +1,16 @@ + +require 'fileutils' + module Gitlab module Popen def popen(cmd, path) vars = { "PWD" => path } options = { chdir: path } + unless File.directory?(path) + FileUtils.mkdir_p(path) + end + @cmd_output = "" @cmd_status = 0 Open3.popen3(vars, cmd, options) do |stdin, stdout, stderr, wait_thr| -- cgit v1.2.1 From 6d7ced4a2311eeff037c5575cca1868a6d3f586f Mon Sep 17 00:00:00 2001 From: Dale Hamel Date: Tue, 8 Oct 2013 13:53:22 -0500 Subject: Whitespace fixes to patch --- lib/gitlab/popen.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/gitlab/popen.rb b/lib/gitlab/popen.rb index 369d6cc1f5d..5283cf0b821 100644 --- a/lib/gitlab/popen.rb +++ b/lib/gitlab/popen.rb @@ -1,4 +1,3 @@ - require 'fileutils' module Gitlab @@ -8,7 +7,7 @@ module Gitlab options = { chdir: path } unless File.directory?(path) - FileUtils.mkdir_p(path) + FileUtils.mkdir_p(path) end @cmd_output = "" -- cgit v1.2.1 From 17105038caf237687ad0fc9f34bf5f368d0cc8a5 Mon Sep 17 00:00:00 2001 From: Gabe Martin-Dempesy Date: Sat, 2 Nov 2013 17:12:29 -0500 Subject: add rake gitlab:import: all_users_to_all_groups and user_to_groups I opted for admins to be added as "owners" instead of "masters" because project masters can managers members, but only group owners can manage members. --- lib/tasks/gitlab/bulk_add_permission.rake | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lib') diff --git a/lib/tasks/gitlab/bulk_add_permission.rake b/lib/tasks/gitlab/bulk_add_permission.rake index c270232edba..22f6a1544bd 100644 --- a/lib/tasks/gitlab/bulk_add_permission.rake +++ b/lib/tasks/gitlab/bulk_add_permission.rake @@ -20,5 +20,29 @@ namespace :gitlab do puts "Importing #{user.email} users into #{project_ids.size} projects" UsersProject.add_users_into_projects(project_ids, Array.wrap(user.id), UsersProject::DEVELOPER) end + + desc "GITLAB | Add all users to all groups (admin users are added as owners)" + task all_users_to_all_groups: :environment do |t, args| + user_ids = User.where(admin: false).pluck(:id) + admin_ids = User.where(admin: true).pluck(:id) + groups = Group.all + + puts "Importing #{user_ids.size} users into #{groups.size} groups" + puts "Importing #{admin_ids.size} admins into #{groups.size} groups" + groups.each do |group| + group.add_users(user_ids, UsersGroup::DEVELOPER) + group.add_users(admin_ids, UsersGroup::OWNER) + end + end + + desc "GITLAB | Add a specific user to all groups (as a developer)" + task :user_to_groups, [:email] => :environment do |t, args| + user = User.find_by_email args.email + groups = Group.all + puts "Importing #{user.email} users into #{groups.size} groups" + groups.each do |group| + group.add_users(Array.wrap(user.id), UsersGroup::DEVELOPER) + end + end end end -- cgit v1.2.1 From 78b2fb5de9d96390110f469d057a2081be34a69b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 27 Jan 2014 13:12:58 +0200 Subject: Add highlight.js support to markdown, snippets etc Signed-off-by: Dmitriy Zaporozhets --- lib/redcarpet/render/gitlab_html.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/redcarpet/render/gitlab_html.rb b/lib/redcarpet/render/gitlab_html.rb index 2d1e0aec5e5..b3e8ed2ade5 100644 --- a/lib/redcarpet/render/gitlab_html.rb +++ b/lib/redcarpet/render/gitlab_html.rb @@ -12,10 +12,6 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML end def block_code(code, language) - options = { options: {encoding: 'utf-8'} } - lexer = Pygments::Lexer.find(language) # language can be an alias - options.merge!(lexer: lexer.aliases[0].downcase) if lexer # downcase is required - # New lines are placed to fix an rendering issue # with code wrapped inside

tag for next case: # @@ -25,7 +21,13 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML # <<-HTML -
#{Pygments.highlight(code, options)}
+
+
+
+      #{code}
+    
+
+
HTML end -- cgit v1.2.1 From 891ea6f6e66c753d9a2f7a4e261f4d37e118c253 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 27 Jan 2014 18:18:18 +0200 Subject: Improve highlight for notes Signed-off-by: Dmitriy Zaporozhets --- lib/redcarpet/render/gitlab_html.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/redcarpet/render/gitlab_html.rb b/lib/redcarpet/render/gitlab_html.rb index b3e8ed2ade5..6da0c1d6f96 100644 --- a/lib/redcarpet/render/gitlab_html.rb +++ b/lib/redcarpet/render/gitlab_html.rb @@ -23,9 +23,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
-
-      #{code}
-    
+
#{code}
-- cgit v1.2.1 From 5de16dee768f4482d8db48b58fad1cf55c1320ee Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Tue, 28 Jan 2014 10:19:22 +0100 Subject: Add a custom 502 page --- lib/support/nginx/gitlab | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/support/nginx/gitlab b/lib/support/nginx/gitlab index 0860d2a8693..882f0386046 100644 --- a/lib/support/nginx/gitlab +++ b/lib/support/nginx/gitlab @@ -53,5 +53,7 @@ server { proxy_pass http://gitlab; } + + error_page 502 /502.html; } -- cgit v1.2.1 From e2e900a338894010e7ba4dac89fa7b926803a977 Mon Sep 17 00:00:00 2001 From: Jurnell Cockhren Date: Tue, 28 Jan 2014 15:10:36 -0600 Subject: In the case when a user can and has authenticated with ldap, however ldap is disabled in the gitlab config, this fixes the API still calling the ldap backend. --- lib/api/internal.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/api/internal.rb b/lib/api/internal.rb index ed6b50c3a6a..ebc9fef07b4 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -35,7 +35,9 @@ module API user = key.user return false if user.blocked? - return false if user.ldap_user? && Gitlab::LDAP::User.blocked?(user.extern_uid) + if Gitlab.config.ldap.enabled + return false if user.ldap_user? && Gitlab::LDAP::User.blocked?(user.extern_uid) + end action = case git_cmd when *DOWNLOAD_COMMANDS -- cgit v1.2.1 From 9e181d36ead37ace996c5ec8a25f7639bc308345 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 31 Jan 2014 13:09:10 +0200 Subject: Dont check for python any more Signed-off-by: Dmitriy Zaporozhets --- lib/tasks/gitlab/check.rake | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib') diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index f48d26433c0..7391773860e 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -279,8 +279,6 @@ namespace :gitlab do start_checking "Environment" check_gitlab_git_config - check_python2_exists - check_python2_version finished_checking "Environment" end -- cgit v1.2.1 From 7085892e470f02363d8b2c305adb3968be7177a2 Mon Sep 17 00:00:00 2001 From: Johannes Schleifenbaum Date: Mon, 3 Feb 2014 11:24:42 +0100 Subject: remove remaining python references --- lib/tasks/gitlab/check.rake | 46 --------------------------------------------- 1 file changed, 46 deletions(-) (limited to 'lib') diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 7391773860e..c91dedf74c7 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -312,52 +312,6 @@ namespace :gitlab do fix_and_rerun end end - - def check_python2_exists - print "Has python2? ... " - - # Python prints its version to STDERR - # so we can't just use run("python2 --version") - if run_and_match("which python2", /python2$/) - puts "yes".green - else - puts "no".red - try_fixing_it( - "Make sure you have Python 2.5+ installed", - "Link it to python2" - ) - for_more_information( - see_installation_guide_section "Packages / Dependencies" - ) - fix_and_rerun - end - end - - def check_python2_version - print "python2 is supported version? ... " - - # Python prints its version to STDERR - # so we can't just use run("python2 --version") - - unless run_and_match("which python2", /python2$/) - puts "can't check because of previous errors".magenta - return - end - - if `python2 --version 2>&1` =~ /2\.[567]\.\d/ - puts "yes".green - else - puts "no".red - try_fixing_it( - "Make sure you have Python 2.5+ installed", - "Link it to python2" - ) - for_more_information( - see_installation_guide_section "Packages / Dependencies" - ) - fix_and_rerun - end - end end -- cgit v1.2.1 From 97a4d8aea46fb45894f6e47597320ed2f6a12495 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 4 Feb 2014 14:46:15 +0200 Subject: Improve code according to new gitlab_git Signed-off-by: Dmitriy Zaporozhets --- lib/api/entities.rb | 21 ++++++++++++++++++++- lib/api/repositories.rb | 13 +++---------- lib/extracts_path.rb | 2 +- 3 files changed, 24 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 4f636fc54a3..8f54d0d4d84 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -79,7 +79,16 @@ module API end class RepoObject < Grape::Entity - expose :name, :commit + expose :name + + expose :commit do |repo_obj, options| + if repo_obj.respond_to?(:commit) + repo_obj.commit + elsif options[:project] + options[:project].repository.commit(repo_obj.target) + end + end + expose :protected do |repo, options| if options[:project] options[:project].protected_branch? repo.name @@ -87,6 +96,16 @@ module API end end + class RepoTreeObject < Grape::Entity + expose :id, :name, :type + + expose :mode do |obj, options| + filemode = obj.mode.to_s(8) + filemode = "0" + filemode if filemode.length < 6 + filemode + end + end + class RepoCommit < Grape::Entity expose :id, :short_id, :title, :author_name, :author_email, :created_at end diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb index 878929b8032..cad64760abb 100644 --- a/lib/api/repositories.rb +++ b/lib/api/repositories.rb @@ -82,7 +82,7 @@ module API # Example Request: # GET /projects/:id/repository/tags get ":id/repository/tags" do - present user_project.repo.tags.sort_by(&:name).reverse, with: Entities::RepoObject + present user_project.repo.tags.sort_by(&:name).reverse, with: Entities::RepoObject, project: user_project end # Get a project repository commits @@ -141,15 +141,9 @@ module API path = params[:path] || nil commit = user_project.repository.commit(ref) - tree = Tree.new(user_project.repository, commit.id, path) + tree = user_project.repository.tree(commit.id, path) - trees = [] - - %w(trees blobs submodules).each do |type| - trees += tree.send(type).map { |t| {name: t.name, type: type.singularize, mode: t.mode, id: t.id} } - end - - trees + present tree.sorted_entries, with: Entities::RepoTreeObject end # Get a raw file contents @@ -233,4 +227,3 @@ module API end end end - diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb index 6e7872dcd03..e51cb30bdd9 100644 --- a/lib/extracts_path.rb +++ b/lib/extracts_path.rb @@ -117,7 +117,7 @@ module ExtractsPath end def tree - @tree ||= Tree.new(@repo, @commit.id, @path) + @tree ||= @repo.tree(@commit.id, @path) end private -- cgit v1.2.1 From 61748c993de8a38300c0c038cec5a07e6c324cd6 Mon Sep 17 00:00:00 2001 From: Ciro Santillli Date: Tue, 4 Feb 2014 08:48:33 +0100 Subject: Headers have ids and link to their own id. --- lib/redcarpet/render/gitlab_html.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib') diff --git a/lib/redcarpet/render/gitlab_html.rb b/lib/redcarpet/render/gitlab_html.rb index 6da0c1d6f96..42f6316910a 100644 --- a/lib/redcarpet/render/gitlab_html.rb +++ b/lib/redcarpet/render/gitlab_html.rb @@ -8,6 +8,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML @project = @template.instance_variable_get("@project") @ref = @template.instance_variable_get("@ref") @request_path = @template.instance_variable_get("@path") + @options = options.dup super options end @@ -34,6 +35,16 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML h.link_to_gfm(content, link, title: title) end + def header(text, level) + if @options[:no_header_anchors] + "#{text}" + else + id = ActionController::Base.helpers.strip_tags(h.gfm(text)).downcase() \ + .gsub(/[^a-z0-9_-]/, '-').gsub(/-+/, '-').gsub(/^-/, '').gsub(/-$/, '') + "#{text}" + end + end + def preprocess(full_document) if @project h.create_relative_links(full_document, @project, @ref, @request_path, is_wiki?) -- cgit v1.2.1 From 1d48904ac807c6d382c8965329085b321381cc3d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 13 Feb 2014 15:45:24 +0200 Subject: Show avatars in ajax user selectbox Signed-off-by: Dmitriy Zaporozhets --- lib/api/entities.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 8f54d0d4d84..8557fa074d4 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -6,6 +6,12 @@ module API expose :is_admin?, as: :is_admin expose :can_create_group?, as: :can_create_group expose :can_create_project?, as: :can_create_project + + expose :avatar_url do |user, options| + if user.avatar.present? + user.avatar.url + end + end end class UserSafe < Grape::Entity -- cgit v1.2.1 From f0f88390c1309b0d5a8cead701477e21c2174f05 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 13 Feb 2014 16:08:26 +0200 Subject: project_user selectbox with ajax autocomplete Signed-off-by: Dmitriy Zaporozhets --- lib/api/projects.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 888aa7e77d2..bcca69ff49a 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -11,7 +11,7 @@ module API end not_found! end - + def map_public_to_visibility_level(attrs) publik = attrs.delete(:public) publik = [ true, 1, '1', 't', 'T', 'true', 'TRUE', 'on', 'ON' ].include?(publik) @@ -308,6 +308,18 @@ module API projects = Project.where("(id in (?) OR visibility_level in (?)) AND (name LIKE (?))", ids, visibility_levels, "%#{params[:query]}%") present paginate(projects), with: Entities::Project end + + + # Get a users list + # + # Example Request: + # GET /users + get ':id/users' do + @users = User.where(id: user_project.team.users.map(&:id)) + @users = @users.search(params[:search]) if params[:search].present? + @users = paginate @users + present @users, with: Entities::User + end end end end -- cgit v1.2.1 From 3c742dad27d298fae9aa8ee68cf1a83178fb8704 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 18 Feb 2014 11:40:45 +0200 Subject: Fixed bug with json files content being escaped in api After update to recent grape env['api.format'] does not work any more. Use content_type for rendering raw json files content Signed-off-by: Dmitriy Zaporozhets --- lib/api/api.rb | 2 ++ lib/api/repositories.rb | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/api/api.rb b/lib/api/api.rb index 283f7642f67..9022cf7375a 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -22,6 +22,8 @@ module API end format :json + content_type :txt, "text/plain" + helpers APIHelpers mount Groups diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb index cad64760abb..c305c889fc2 100644 --- a/lib/api/repositories.rb +++ b/lib/api/repositories.rb @@ -167,9 +167,7 @@ module API blob = Gitlab::Git::Blob.find(repo, commit.id, params[:filepath]) not_found! "File" unless blob - env['api.format'] = :txt - - content_type blob.mime_type + content_type 'text/plain' present blob.data end -- cgit v1.2.1 From ddbe978041753d7851780165f8c6c66865570862 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 18 Feb 2014 12:27:02 +0200 Subject: Complete api files CRUD Signed-off-by: Dmitriy Zaporozhets --- lib/api/files.rb | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/api/files.rb b/lib/api/files.rb index 213604915a6..e0c46f92b84 100644 --- a/lib/api/files.rb +++ b/lib/api/files.rb @@ -5,10 +5,61 @@ module API before { authorize! :push_code, user_project } resource :projects do + # Get file from repository + # File content is Base64 encoded + # + # Parameters: + # file_path (required) - The path to the file. Ex. lib/class.rb + # ref (required) - The name of branch, tag or commit + # + # Example Request: + # GET /projects/:id/repository/files + # + # Example response: + # { + # "file_name": "key.rb", + # "file_path": "app/models/key.rb", + # "size": 1476, + # "encoding": "base64", + # "content": "IyA9PSBTY2hlbWEgSW5mb3...", + # "ref": "master", + # "blob_id": "79f7bbd25901e8334750839545a9bd021f0e4c83", + # "commit_id": "d5a3ff139356ce33e37e73add446f16869741b50" + # } + # + get ":id/repository/files" do + required_attributes! [:file_path, :ref] + attrs = attributes_for_keys [:file_path, :ref] + ref = attrs.delete(:ref) + file_path = attrs.delete(:file_path) + + commit = user_project.repository.commit(ref) + not_found! "Commit" unless commit + + blob = user_project.repository.blob_at(commit.sha, file_path) + + if blob + status(200) + + { + file_name: blob.name, + file_path: blob.path, + size: blob.size, + encoding: "base64", + content: Base64.encode64(blob.data), + ref: ref, + blob_id: blob.id, + commit_id: commit.id, + } + else + render_api_error!('File not found', 404) + end + end + # Create new file in repository # # Parameters: - # file_path (optional) - The path to new file. Ex. lib/class.rb + # file_path (required) - The path to new file. Ex. lib/class.rb # branch_name (required) - The name of branch # content (required) - File content # commit_message (required) - Commit message -- cgit v1.2.1 From 6cf39fe10ddf6f90a17d52ba6b50425f58215eeb Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 18 Feb 2014 12:41:21 +0200 Subject: Extract commits API to separate file Signed-off-by: Dmitriy Zaporozhets --- lib/api/api.rb | 1 + lib/api/commits.rb | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/api/repositories.rb | 44 ---------------------------------- 3 files changed, 65 insertions(+), 44 deletions(-) create mode 100644 lib/api/commits.rb (limited to 'lib') diff --git a/lib/api/api.rb b/lib/api/api.rb index 283f7642f67..4157397b5e2 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -40,6 +40,7 @@ module API mount ProjectHooks mount Services mount Files + mount Commits mount Namespaces end end diff --git a/lib/api/commits.rb b/lib/api/commits.rb new file mode 100644 index 00000000000..33b8b3d2244 --- /dev/null +++ b/lib/api/commits.rb @@ -0,0 +1,64 @@ +require 'mime/types' + +module API + # Projects API + class Commits < Grape::API + before { authenticate! } + before { authorize! :download_code, user_project } + + resource :projects do + helpers do + def handle_project_member_errors(errors) + if errors[:project_access].any? + error!(errors[:project_access], 422) + end + not_found! + end + end + + # Get a project repository commits + # + # Parameters: + # id (required) - The ID of a project + # ref_name (optional) - The name of a repository branch or tag, if not given the default branch is used + # Example Request: + # GET /projects/:id/repository/commits + get ":id/repository/commits" do + page = (params[:page] || 0).to_i + per_page = (params[:per_page] || 20).to_i + ref = params[:ref_name] || user_project.try(:default_branch) || 'master' + + commits = user_project.repository.commits(ref, nil, per_page, page * per_page) + present commits, with: Entities::RepoCommit + end + + # Get a specific commit of a project + # + # Parameters: + # id (required) - The ID of a project + # sha (required) - The commit hash or name of a repository branch or tag + # Example Request: + # GET /projects/:id/repository/commits/:sha + get ":id/repository/commits/:sha" do + sha = params[:sha] + commit = user_project.repository.commit(sha) + not_found! "Commit" unless commit + present commit, with: Entities::RepoCommitDetail + end + + # Get the diff for a specific commit of a project + # + # Parameters: + # id (required) - The ID of a project + # sha (required) - The commit or branch name + # Example Request: + # GET /projects/:id/repository/commits/:sha/diff + get ":id/repository/commits/:sha/diff" do + sha = params[:sha] + commit = user_project.repository.commit(sha) + not_found! "Commit" unless commit + commit.diffs + end + end + end +end diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb index cad64760abb..00a0c919b4d 100644 --- a/lib/api/repositories.rb +++ b/lib/api/repositories.rb @@ -85,50 +85,6 @@ module API present user_project.repo.tags.sort_by(&:name).reverse, with: Entities::RepoObject, project: user_project end - # Get a project repository commits - # - # Parameters: - # id (required) - The ID of a project - # ref_name (optional) - The name of a repository branch or tag, if not given the default branch is used - # Example Request: - # GET /projects/:id/repository/commits - get ":id/repository/commits" do - page = (params[:page] || 0).to_i - per_page = (params[:per_page] || 20).to_i - ref = params[:ref_name] || user_project.try(:default_branch) || 'master' - - commits = user_project.repository.commits(ref, nil, per_page, page * per_page) - present commits, with: Entities::RepoCommit - end - - # Get a specific commit of a project - # - # Parameters: - # id (required) - The ID of a project - # sha (required) - The commit hash or name of a repository branch or tag - # Example Request: - # GET /projects/:id/repository/commits/:sha - get ":id/repository/commits/:sha" do - sha = params[:sha] - commit = user_project.repository.commit(sha) - not_found! "Commit" unless commit - present commit, with: Entities::RepoCommitDetail - end - - # Get the diff for a specific commit of a project - # - # Parameters: - # id (required) - The ID of a project - # sha (required) - The commit or branch name - # Example Request: - # GET /projects/:id/repository/commits/:sha/diff - get ":id/repository/commits/:sha/diff" do - sha = params[:sha] - commit = user_project.repository.commit(sha) - not_found! "Commit" unless commit - commit.diffs - end - # Get a project repository tree # # Parameters: -- cgit v1.2.1 From 1c61ac1c64e136b391d472a24bbc5538352e299d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 18 Feb 2014 20:17:26 +0200 Subject: Refactor MR code reload Signed-off-by: Dmitriy Zaporozhets --- lib/api/merge_requests.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib') diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index 0f62cac9a0c..58d2f79faff 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -116,8 +116,6 @@ module API authorize! :modify_merge_request, merge_request if merge_request.update_attributes attrs - merge_request.reload_code - merge_request.mark_as_unchecked present merge_request, with: Entities::MergeRequest else handle_merge_request_errors! merge_request.errors -- cgit v1.2.1