From 08eac512bdcd9181476afc3e4bc0b132ebd48478 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 31 Mar 2015 12:30:09 +0200 Subject: [PATCH 1/7] Move EmailsOnPush highlight CSS inline instead of being in every notification email. --- app/helpers/emails_helper.rb | 6 +----- app/views/layouts/notify.html.haml | 3 +-- app/views/notify/repository_push_email.html.haml | 3 +-- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/app/helpers/emails_helper.rb b/app/helpers/emails_helper.rb index 08476f8516..6c253213c3 100644 --- a/app/helpers/emails_helper.rb +++ b/app/helpers/emails_helper.rb @@ -33,12 +33,8 @@ module EmailsHelper end end - def add_email_highlight_css - Rugments::Themes::Github.render(scope: '.highlight') - end - def color_email_diff(diffcontent) - formatter = Rugments::Formatters::HTML.new(cssclass: 'highlight') + formatter = Rugments::Formatters::HTML.new(cssclass: "highlight", inline_theme: :github) lexer = Rugments::Lexers::Diff.new raw formatter.format(lexer.lex(diffcontent)) end diff --git a/app/views/layouts/notify.html.haml b/app/views/layouts/notify.html.haml index 7eec93abdf..00c7cedce4 100644 --- a/app/views/layouts/notify.html.haml +++ b/app/views/layouts/notify.html.haml @@ -27,8 +27,7 @@ } .file-stats .deleted-file { color: #B00; - } - #{add_email_highlight_css} + }} %body %div.content = yield diff --git a/app/views/notify/repository_push_email.html.haml b/app/views/notify/repository_push_email.html.haml index bbf7004c90..a374a66233 100644 --- a/app/views/notify/repository_push_email.html.haml +++ b/app/views/notify/repository_push_email.html.haml @@ -59,8 +59,7 @@ %strong = diff.new_path %hr - %pre - = color_email_diff(diff.diff) + = color_email_diff(diff.diff) %br - if @compare.timeout From 5ad0eb4378ce3da98fed210c0383687900e9414a Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 31 Mar 2015 12:34:07 +0200 Subject: [PATCH 2/7] Update gitlab_git to 7.1.5, to fix final line in EmailsOnPush email diff being rendered as error. --- CHANGELOG | 1 + Gemfile | 2 +- Gemfile.lock | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 37054da46b..4623a1f1a4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -48,6 +48,7 @@ v 7.10.0 (unreleased) - Prevent note form from being cleared when submitting failed. - Improve file icons rendering on tree (Sullivan Sénéchal) - API: Add pagination to project events + - Fix final line in EmailsOnPush email diff being rendered as error. v 7.9.0 - Send EmailsOnPush email when branch or tag is created or deleted. diff --git a/Gemfile b/Gemfile index e767aec505..05830dec82 100644 --- a/Gemfile +++ b/Gemfile @@ -39,7 +39,7 @@ gem "browser" # Extracting information from a git repository # Provide access to Gitlab::Git library -gem "gitlab_git", '~> 7.1.3' +gem "gitlab_git", '~> 7.1.5' # Ruby/Rack Git Smart-HTTP Server Handler gem 'gitlab-grack', '~> 2.0.0.rc2', require: 'grack' diff --git a/Gemfile.lock b/Gemfile.lock index ed8663b358..bc278a0e73 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -212,7 +212,7 @@ GEM mime-types (~> 1.19) gitlab_emoji (0.1.0) gemojione (~> 2.0) - gitlab_git (7.1.3) + gitlab_git (7.1.5) activesupport (~> 4.0) charlock_holmes (~> 0.6) gitlab-linguist (~> 3.0) @@ -703,7 +703,7 @@ DEPENDENCIES gitlab-grack (~> 2.0.0.rc2) gitlab-linguist (~> 3.0.1) gitlab_emoji (~> 0.1) - gitlab_git (~> 7.1.3) + gitlab_git (~> 7.1.5) gitlab_meta (= 7.0) gitlab_omniauth-ldap (= 1.2.1) gollum-lib (~> 4.0.2) From cef0fe244f4faf55bc1d4bd7402129ce80d427e9 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 31 Mar 2015 14:17:20 +0200 Subject: [PATCH 3/7] Update gitlab_git to 7.1.6 because 7.1.5 had broken language detection. --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 05830dec82..cce1f47ef1 100644 --- a/Gemfile +++ b/Gemfile @@ -39,7 +39,7 @@ gem "browser" # Extracting information from a git repository # Provide access to Gitlab::Git library -gem "gitlab_git", '~> 7.1.5' +gem "gitlab_git", '~> 7.1.6' # Ruby/Rack Git Smart-HTTP Server Handler gem 'gitlab-grack', '~> 2.0.0.rc2', require: 'grack' diff --git a/Gemfile.lock b/Gemfile.lock index bc278a0e73..d7a292d4e5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -212,7 +212,7 @@ GEM mime-types (~> 1.19) gitlab_emoji (0.1.0) gemojione (~> 2.0) - gitlab_git (7.1.5) + gitlab_git (7.1.6) activesupport (~> 4.0) charlock_holmes (~> 0.6) gitlab-linguist (~> 3.0) @@ -703,7 +703,7 @@ DEPENDENCIES gitlab-grack (~> 2.0.0.rc2) gitlab-linguist (~> 3.0.1) gitlab_emoji (~> 0.1) - gitlab_git (~> 7.1.5) + gitlab_git (~> 7.1.6) gitlab_meta (= 7.0) gitlab_omniauth-ldap (= 1.2.1) gollum-lib (~> 4.0.2) From e69e430ce70a0a679214669437c7521611e4b77c Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 6 Apr 2015 14:50:43 +0200 Subject: [PATCH 4/7] Allow projects to be imported into namespaces user is master of. --- app/controllers/import/base_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/import/base_controller.rb b/app/controllers/import/base_controller.rb index edb8bd4160..93a7ace353 100644 --- a/app/controllers/import/base_controller.rb +++ b/app/controllers/import/base_controller.rb @@ -8,7 +8,7 @@ class Import::BaseController < ApplicationController namespace.add_owner(current_user) rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid namespace = Namespace.find_by_path_or_name(@target_namespace) - unless namespace.owner == current_user + unless current_user.can?(:create_projects, namespace) @already_been_taken = true return false end From 99abbe7dbe5dfbeba5869ffa35cac2b36cd5578c Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 6 Apr 2015 14:51:09 +0200 Subject: [PATCH 5/7] Use Projects::CreateService to create imported projects so hooks are executed. --- .../bitbucket_import/project_creator.rb | 19 +++---------------- lib/gitlab/github_import/project_creator.rb | 19 +++---------------- lib/gitlab/gitlab_import/project_creator.rb | 19 +++---------------- .../gitorious_import/project_creator.rb | 19 +++---------------- 4 files changed, 12 insertions(+), 64 deletions(-) diff --git a/lib/gitlab/bitbucket_import/project_creator.rb b/lib/gitlab/bitbucket_import/project_creator.rb index db33af2c2d..54420e62c9 100644 --- a/lib/gitlab/bitbucket_import/project_creator.rb +++ b/lib/gitlab/bitbucket_import/project_creator.rb @@ -10,29 +10,16 @@ module Gitlab end def execute - @project = Project.new( + ::Projects::CreateService.new(current_user, name: repo["name"], path: repo["slug"], description: repo["description"], - namespace: namespace, - creator: current_user, + namespace_id: namespace.id, visibility_level: repo["is_private"] ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::VisibilityLevel::PUBLIC, import_type: "bitbucket", import_source: "#{repo["owner"]}/#{repo["slug"]}", import_url: "ssh://git@bitbucket.org/#{repo["owner"]}/#{repo["slug"]}.git" - ) - - if @project.save! - @project.reload - - if @project.import_failed? - @project.import_retry - else - @project.import_start - end - end - - @project + ).execute end end end diff --git a/lib/gitlab/github_import/project_creator.rb b/lib/gitlab/github_import/project_creator.rb index 9439ca6cbf..2723eec933 100644 --- a/lib/gitlab/github_import/project_creator.rb +++ b/lib/gitlab/github_import/project_creator.rb @@ -10,29 +10,16 @@ module Gitlab end def execute - @project = Project.new( + ::Projects::CreateService.new(current_user, name: repo.name, path: repo.name, description: repo.description, - namespace: namespace, - creator: current_user, + namespace_id: namespace.id, visibility_level: repo.private ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::VisibilityLevel::PUBLIC, import_type: "github", import_source: repo.full_name, import_url: repo.clone_url.sub("https://", "https://#{current_user.github_access_token}@") - ) - - if @project.save! - @project.reload - - if @project.import_failed? - @project.import_retry - else - @project.import_start - end - end - - @project + ).execute end end end diff --git a/lib/gitlab/gitlab_import/project_creator.rb b/lib/gitlab/gitlab_import/project_creator.rb index 6424d56f8f..f0d7141bf5 100644 --- a/lib/gitlab/gitlab_import/project_creator.rb +++ b/lib/gitlab/gitlab_import/project_creator.rb @@ -10,29 +10,16 @@ module Gitlab end def execute - @project = Project.new( + ::Projects::CreateService.new(current_user, name: repo["name"], path: repo["path"], description: repo["description"], - namespace: namespace, - creator: current_user, + namespace_id: namespace.id, visibility_level: repo["visibility_level"], import_type: "gitlab", import_source: repo["path_with_namespace"], import_url: repo["http_url_to_repo"].sub("://", "://oauth2:#{current_user.gitlab_access_token}@") - ) - - if @project.save! - @project.reload - - if @project.import_failed? - @project.import_retry - else - @project.import_start - end - end - - @project + ).execute end end end diff --git a/lib/gitlab/gitorious_import/project_creator.rb b/lib/gitlab/gitorious_import/project_creator.rb index 3cbebe5399..cc9a91c91f 100644 --- a/lib/gitlab/gitorious_import/project_creator.rb +++ b/lib/gitlab/gitorious_import/project_creator.rb @@ -10,29 +10,16 @@ module Gitlab end def execute - @project = Project.new( + ::Projects::CreateService.new(current_user, name: repo.name, path: repo.path, description: repo.description, - namespace: namespace, - creator: current_user, + namespace_id: namespace.id, visibility_level: Gitlab::VisibilityLevel::PUBLIC, import_type: "gitorious", import_source: repo.full_name, import_url: repo.import_url - ) - - if @project.save! - @project.reload - - if @project.import_failed? - @project.import_retry - else - @project.import_start - end - end - - @project + ).execute end end end From 4740242a67f10749b9d8ad213d259c9f5d0eea98 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 6 Apr 2015 14:51:41 +0200 Subject: [PATCH 6/7] Change text of project creation event for imports. --- app/models/event.rb | 6 +++++- app/views/events/event/_created_project.html.haml | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index 57f6d5cd4e..c9a88ffa8e 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -183,7 +183,11 @@ class Event < ActiveRecord::Base elsif commented? "commented on" elsif created_project? - "created" + if project.import? + "imported" + else + "created" + end else "opened" end diff --git a/app/views/events/event/_created_project.html.haml b/app/views/events/event/_created_project.html.haml index 3c7153d235..552525f4a0 100644 --- a/app/views/events/event/_created_project.html.haml +++ b/app/views/events/event/_created_project.html.haml @@ -18,10 +18,10 @@ %a.twitter-share-button{ | href: "https://twitter.com/share", | "data-url" => event.project.web_url, | - "data-text" => "I just created a new project in GitLab! GitLab is version control on your server.", | + "data-text" => "I just #{event.project.imported? ? "imported" : "created"} a new project in GitLab! GitLab is version control on your server.", | "data-size" => "medium", | "data-related" => "gitlab", | "data-hashtags" => "gitlab", | "data-count" => "none"} Tweet - %script{src: "//platform.twitter.com/widgets.js"} \ No newline at end of file + %script{src: "//platform.twitter.com/widgets.js"} From cf0e84cf04162bf63b36ebc3b6034c3d44abe997 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 6 Apr 2015 15:12:26 +0200 Subject: [PATCH 7/7] Add icons to Add dropdown items. --- CHANGELOG | 2 +- app/views/projects/_dropdown.html.haml | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index db3e5744b0..6b3d32d261 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -62,7 +62,7 @@ v 7.10.0 (unreleased) - Project labels are now available over the API under the "tag_list" field (Cristian Medina) - Fixed link paths for HTTP and SSH on the admin project view (Jeremy Maziarz) - Fix and improve help rendering (Sullivan Sénéchal) - + - Add icons to Add dropdown items. v 7.9.2 - Contains no changes diff --git a/app/views/projects/_dropdown.html.haml b/app/views/projects/_dropdown.html.haml index 3adb308728..3036f11bb2 100644 --- a/app/views/projects/_dropdown.html.haml +++ b/app/views/projects/_dropdown.html.haml @@ -6,28 +6,32 @@ - if @project.issues_enabled && can?(current_user, :write_issue, @project) %li = link_to url_for_new_issue(@project, only_path: true), title: "New Issue" do + %i.fa.fa-fw.fa-exclamation-circle New issue - if @project.merge_requests_enabled && can?(current_user, :write_merge_request, @project) %li = link_to new_namespace_project_merge_request_path(@project.namespace, @project), title: "New Merge Request" do + %i.fa.fa-fw.fa-tasks New merge request - if @project.snippets_enabled && can?(current_user, :write_snippet, @project) %li = link_to new_namespace_project_snippet_path(@project.namespace, @project), title: "New Snippet" do + %i.fa.fa-fw.fa-file-text-o New snippet - if can?(current_user, :admin_project_member, @project) %li = link_to namespace_project_project_members_path(@project.namespace, @project), title: "New project member" do + %i.fa.fa-fw.fa-users New project member - if can? current_user, :push_code, @project %li.divider %li = link_to new_namespace_project_branch_path(@project.namespace, @project) do - %i.fa.fa-code-fork - Git branch + %i.fa.fa-fw.fa-code-fork + New branch %li = link_to new_namespace_project_tag_path(@project.namespace, @project) do - %i.fa.fa-tag - Git tag + %i.fa.fa-fw.fa-tag + New tag