From 27bf7ae59eb95bff0254b8ad3c001ea2397ec544 Mon Sep 17 00:00:00 2001 From: ZJ van de Weg Date: Fri, 27 May 2016 11:00:56 +0200 Subject: Refactor Gitlab::Gitignores --- app/helpers/blob_helper.rb | 8 ++-- lib/api/api.rb | 2 +- lib/api/entities.rb | 4 +- lib/api/gitignores.rb | 29 -------------- lib/api/templates.rb | 35 +++++++++++++++++ lib/gitlab/gitignore.rb | 56 --------------------------- lib/gitlab/template/base_template.rb | 54 ++++++++++++++++++++++++++ lib/gitlab/template/gitignore.rb | 23 +++++++++++ lib/tasks/gitlab/update_gitignore.rake | 46 ---------------------- lib/tasks/gitlab/update_templates.rake | 61 ++++++++++++++++++++++++++++++ spec/lib/gitlab/gitignore_spec.rb | 40 -------------------- spec/lib/gitlab/template/gitignore_spec.rb | 40 ++++++++++++++++++++ spec/requests/api/gitignores_spec.rb | 2 +- 13 files changed, 220 insertions(+), 180 deletions(-) delete mode 100644 lib/api/gitignores.rb create mode 100644 lib/api/templates.rb delete mode 100644 lib/gitlab/gitignore.rb create mode 100644 lib/gitlab/template/base_template.rb create mode 100644 lib/gitlab/template/gitignore.rb delete mode 100644 lib/tasks/gitlab/update_gitignore.rake create mode 100644 lib/tasks/gitlab/update_templates.rake delete mode 100644 spec/lib/gitlab/gitignore_spec.rb create mode 100644 spec/lib/gitlab/template/gitignore_spec.rb diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 5b54b34070c..2d42cce95ce 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -188,10 +188,8 @@ module BlobHelper def gitignore_names return @gitignore_names if defined?(@gitignore_names) - @gitignore_names = { - Global: Gitlab::Gitignore.global.map { |gitignore| { name: gitignore.name } }, - # Note that the key here doesn't cover it really - Languages: Gitlab::Gitignore.languages_frameworks.map{ |gitignore| { name: gitignore.name } } - } + @gitignore_names = Gitlab::Template::Gitignore.categories.map do |k, _| + [k, Gitlab::Template::Gitignore.by_category(k)] + end.to_h end end diff --git a/lib/api/api.rb b/lib/api/api.rb index 0e7a1cc2623..f8f680a6311 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -33,7 +33,6 @@ module API mount ::API::Commits mount ::API::DeployKeys mount ::API::Files - mount ::API::Gitignores mount ::API::GroupMembers mount ::API::Groups mount ::API::Internal @@ -58,6 +57,7 @@ module API mount ::API::Subscriptions mount ::API::SystemHooks mount ::API::Tags + mount ::API::Templates mount ::API::Triggers mount ::API::Users mount ::API::Variables diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 2e397643ed1..0c9fc5604fd 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -472,11 +472,11 @@ module API expose :content end - class GitignoresList < Grape::Entity + class TemplatesList < Grape::Entity expose :name end - class Gitignore < Grape::Entity + class Template < Grape::Entity expose :name, :content end end diff --git a/lib/api/gitignores.rb b/lib/api/gitignores.rb deleted file mode 100644 index 270c9501dd2..00000000000 --- a/lib/api/gitignores.rb +++ /dev/null @@ -1,29 +0,0 @@ -module API - class Gitignores < Grape::API - - # Get the list of the available gitignore templates - # - # Example Request: - # GET /gitignores - get 'gitignores' do - present Gitlab::Gitignore.all, with: Entities::GitignoresList - end - - # Get the text for a specific gitignore - # - # Parameters: - # name (required) - The name of a license - # - # Example Request: - # GET /gitignores/Elixir - # - get 'gitignores/:name' do - required_attributes! [:name] - - gitignore = Gitlab::Gitignore.find(params[:name]) - not_found!('.gitignore') unless gitignore - - present gitignore, with: Entities::Gitignore - end - end -end diff --git a/lib/api/templates.rb b/lib/api/templates.rb new file mode 100644 index 00000000000..4c770c0b9dd --- /dev/null +++ b/lib/api/templates.rb @@ -0,0 +1,35 @@ +module API + class Templates < Grape::API + TEMPLATE_TYPES = { + gitignores: Gitlab::Template::Gitignore + }.freeze + + TEMPLATE_TYPES.each do |template, klass| + # Get the list of the available template + # + # Example Request: + # GET /gitignores + # GET /gitlab_ci_ymls + get template.to_s do + present klass.all, with: Entities::TemplatesList + end + + # Get the text for a specific template + # + # Parameters: + # name (required) - The name of a template + # + # Example Request: + # GET /gitignores/Elixir + # GET /gitlab_ci_ymls/Ruby + get "#{template}/:name" do + required_attributes! [:name] + + new_template = klass.find(params[:name]) + not_found!("#{template.to_s.singularize}") unless new_template + + present new_template, with: Entities::Template + end + end + end +end diff --git a/lib/gitlab/gitignore.rb b/lib/gitlab/gitignore.rb deleted file mode 100644 index f46b43b61a4..00000000000 --- a/lib/gitlab/gitignore.rb +++ /dev/null @@ -1,56 +0,0 @@ -module Gitlab - class Gitignore - FILTER_REGEX = /\.gitignore\z/.freeze - - def initialize(path) - @path = path - end - - def name - File.basename(@path, '.gitignore') - end - - def content - File.read(@path) - end - - class << self - def all - languages_frameworks + global - end - - def find(key) - file_name = "#{key}.gitignore" - - directory = select_directory(file_name) - directory ? new(File.join(directory, file_name)) : nil - end - - def global - files_for_folder(global_dir).map { |file| new(File.join(global_dir, file)) } - end - - def languages_frameworks - files_for_folder(gitignore_dir).map { |file| new(File.join(gitignore_dir, file)) } - end - - private - - def select_directory(file_name) - [gitignore_dir, global_dir].find { |dir| File.exist?(File.join(dir, file_name)) } - end - - def global_dir - File.join(gitignore_dir, 'Global') - end - - def gitignore_dir - Rails.root.join('vendor/gitignore') - end - - def files_for_folder(dir) - Dir.glob("#{dir.to_s}/*.gitignore").map { |file| file.gsub(FILTER_REGEX, '') } - end - end - end -end diff --git a/lib/gitlab/template/base_template.rb b/lib/gitlab/template/base_template.rb new file mode 100644 index 00000000000..e1cdfc8f5f6 --- /dev/null +++ b/lib/gitlab/template/base_template.rb @@ -0,0 +1,54 @@ +module Gitlab + module Template + class BaseTemplate + def initialize(path) + @path = path + end + + def name + File.basename(@path, self.class.extension) + end + + def content + File.read(@path) + end + + class << self + def all + self.category_directories.flat_map do |dir| + templates_for_folder(dir) + end + end + + def find(key) + file_name = "#{key}#{self.extension}" + + directory = select_directory(file_name) + directory ? new(File.join(directory, file_name)) : nil + end + + def by_category(category) + templates_for_folder(categories[category]) + end + + def category_directories + self.categories.values.map { |subdir| File.join(base_dir, subdir)} + end + + private + + def select_directory(file_name) + category_directories.find { |dir| File.exist?(File.join(dir, file_name)) } + end + + def templates_for_folder(dir) + Dir.glob("#{dir.to_s}/*#{self.extension}").select { |f| f =~ filter_regex }.map { |f| new(f) } + end + + def filter_regex + /#{Regexp.escape(extension)}\z/ + end + end + end + end +end diff --git a/lib/gitlab/template/gitignore.rb b/lib/gitlab/template/gitignore.rb new file mode 100644 index 00000000000..73fb3b18c4d --- /dev/null +++ b/lib/gitlab/template/gitignore.rb @@ -0,0 +1,23 @@ +module Gitlab + module Template + class Gitignore < BaseTemplate + + class << self + def extension + '.gitignore' + end + + def categories + { + Languages: '', + Global: 'Global' + } + end + + def base_dir + Rails.root.join('vendor/gitignore') + end + end + end + end +end diff --git a/lib/tasks/gitlab/update_gitignore.rake b/lib/tasks/gitlab/update_gitignore.rake deleted file mode 100644 index 4fd48cccb1d..00000000000 --- a/lib/tasks/gitlab/update_gitignore.rake +++ /dev/null @@ -1,46 +0,0 @@ -namespace :gitlab do - desc "GitLab | Update gitignore" - task :update_gitignore do - unless clone_gitignores - puts "Cloning the gitignores failed".color(:red) - return - end - - remove_unneeded_files(gitignore_directory) - remove_unneeded_files(global_directory) - - puts "Done".color(:green) - end - - def clone_gitignores - FileUtils.rm_rf(gitignore_directory) if Dir.exist?(gitignore_directory) - FileUtils.cd vendor_directory - - system('git clone --depth=1 --branch=master https://github.com/github/gitignore.git') - end - - # Retain only certain files: - # - The LICENSE, because we have to - # - The sub dir global - # - The gitignores themself - # - Dir.entires returns also the entries '.' and '..' - def remove_unneeded_files(path) - Dir.foreach(path) do |file| - FileUtils.rm_rf(File.join(path, file)) unless file =~ /(\.{1,2}|LICENSE|Global|\.gitignore)\z/ - end - end - - private - - def vendor_directory - Rails.root.join('vendor') - end - - def gitignore_directory - File.join(vendor_directory, 'gitignore') - end - - def global_directory - File.join(gitignore_directory, 'Global') - end -end diff --git a/lib/tasks/gitlab/update_templates.rake b/lib/tasks/gitlab/update_templates.rake new file mode 100644 index 00000000000..36ffad8aae9 --- /dev/null +++ b/lib/tasks/gitlab/update_templates.rake @@ -0,0 +1,61 @@ +namespace :gitlab do + desc "GitLab | Update templates" + task :update_templates do + update("gitignore") + update("gitlab-ci-yml") + end + + def update(directory) + unless clone_repository(directory) + puts "Cloning the #{directory} templates failed".red + return + end + + remove_unneeded_files(directory) + puts "Done".green + end + + def clone_repository(directory) + dir = File.join(vendor_directory, directory) + FileUtils.rm_rf(dir) if Dir.exist?(dir) + FileUtils.cd vendor_directory + + system("git clone --depth=1 --branch=master #{TEMPLATE_DATA[directory]}") + end + + # Retain only certain files: + # - The LICENSE, because we have to + # - The sub dir global + # - The gitignores themself + # - Dir.entires returns also the entries '.' and '..' + def remove_unneeded_files(directory) + regex = CLEANUP_REGEX[directory] + Dir.foreach(directory) do |file| + FileUtils.rm_rf(File.join(directory, file)) unless file =~ regex + end + end + + private + + TEMPLATE_DATA = { + "gitignore" => "https://github.com/github/gitignore.git", + "gitlab-ci-yml" => "https://gitlab.com/gitlab-org/gitlab-ci-yml.git" + }.freeze + + CLEANUP_REGEX = { + "gitignore" => /(\.{1,2}|LICENSE|Global|\.gitignore)\z/, + "gitlab-ci-yml" => /(\.{1,2}|LICENSE|Pages|\.gitignore)\z/ + }.freeze + + def vendor_directory + Rails.root.join('vendor') + end + + def gitignore_directory + File.join(vendor_directory, 'gitignore') + end + + def gitlab_ci_directory + File.join(vendor_directory, 'gitlab-ci') + end +end diff --git a/spec/lib/gitlab/gitignore_spec.rb b/spec/lib/gitlab/gitignore_spec.rb deleted file mode 100644 index 72baa516cc4..00000000000 --- a/spec/lib/gitlab/gitignore_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'spec_helper' - -describe Gitlab::Gitignore do - subject { Gitlab::Gitignore } - - describe '.all' do - it 'strips the gitignore suffix' do - expect(subject.all.first.name).not_to end_with('.gitignore') - end - - it 'combines the globals and rest' do - all = subject.all.map(&:name) - - expect(all).to include('Vim') - expect(all).to include('Ruby') - end - end - - describe '.find' do - it 'returns nil if the file does not exist' do - expect(subject.find('mepmep-yadida')).to be nil - end - - it 'returns the Gitignore object of a valid file' do - ruby = subject.find('Ruby') - - expect(ruby).to be_a Gitlab::Gitignore - expect(ruby.name).to eq('Ruby') - end - end - - describe '#content' do - it 'loads the full file' do - gitignore = subject.new(Rails.root.join('vendor/gitignore/Ruby.gitignore')) - - expect(gitignore.name).to eq 'Ruby' - expect(gitignore.content).to start_with('*.gem') - end - end -end diff --git a/spec/lib/gitlab/template/gitignore_spec.rb b/spec/lib/gitlab/template/gitignore_spec.rb new file mode 100644 index 00000000000..bc0ec9325cc --- /dev/null +++ b/spec/lib/gitlab/template/gitignore_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' + +describe Gitlab::Template::Gitignore do + subject { described_class } + + describe '.all' do + it 'strips the gitignore suffix' do + expect(subject.all.first.name).not_to end_with('.gitignore') + end + + it 'combines the globals and rest' do + all = subject.all.map(&:name) + + expect(all).to include('Vim') + expect(all).to include('Ruby') + end + end + + describe '.find' do + it 'returns nil if the file does not exist' do + expect(subject.find('mepmep-yadida')).to be nil + end + + it 'returns the Gitignore object of a valid file' do + ruby = subject.find('Ruby') + + expect(ruby).to be_a Gitlab::Template::Gitignore + expect(ruby.name).to eq('Ruby') + end + end + + describe '#content' do + it 'loads the full file' do + gitignore = subject.new(Rails.root.join('vendor/gitignore/Ruby.gitignore')) + + expect(gitignore.name).to eq 'Ruby' + expect(gitignore.content).to start_with('*.gem') + end + end +end diff --git a/spec/requests/api/gitignores_spec.rb b/spec/requests/api/gitignores_spec.rb index aab2d8c81b9..9130312c057 100644 --- a/spec/requests/api/gitignores_spec.rb +++ b/spec/requests/api/gitignores_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::Gitignores, api: true do +describe API::Templates, api: true do include ApiHelpers describe 'Entity Gitignore' do -- cgit v1.2.1 From 567f6a7b4271d97afd6dea1545210b9aba858421 Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Thu, 9 Jun 2016 13:32:26 +0200 Subject: Add first templates for gitlab-ci dropdown --- vendor/gitlab-ci-yml/LICENSE | 21 +++++++++++++++++ vendor/gitlab-ci-yml/Pages/brunch.gitlab-ci.yml | 16 +++++++++++++ vendor/gitlab-ci-yml/Pages/doxygen.gitlab-ci.yml | 13 +++++++++++ vendor/gitlab-ci-yml/Pages/harp.gitlab-ci.yml | 16 +++++++++++++ vendor/gitlab-ci-yml/Pages/hexo.gitlab-ci.yml | 25 ++++++++++++++++++++ vendor/gitlab-ci-yml/Pages/html.gitlab-ci.yml | 12 ++++++++++ vendor/gitlab-ci-yml/Pages/hugo.gitlab-ci.yml | 11 +++++++++ vendor/gitlab-ci-yml/Pages/hyde.gitlab-ci.yml | 25 ++++++++++++++++++++ vendor/gitlab-ci-yml/Pages/jekyll.gitlab-ci.yml | 24 +++++++++++++++++++ vendor/gitlab-ci-yml/Pages/lektor.gitlab-ci.yml | 12 ++++++++++ .../gitlab-ci-yml/Pages/metalsmith.gitlab-ci.yml | 17 ++++++++++++++ vendor/gitlab-ci-yml/Pages/middleman.gitlab-ci.yml | 27 ++++++++++++++++++++++ vendor/gitlab-ci-yml/Pages/nanoc.gitlab-ci.yml | 12 ++++++++++ vendor/gitlab-ci-yml/Pages/octopress.gitlab-ci.yml | 15 ++++++++++++ vendor/gitlab-ci-yml/Pages/pelican.gitlab-ci.yml | 10 ++++++++ 15 files changed, 256 insertions(+) create mode 100644 vendor/gitlab-ci-yml/LICENSE create mode 100644 vendor/gitlab-ci-yml/Pages/brunch.gitlab-ci.yml create mode 100644 vendor/gitlab-ci-yml/Pages/doxygen.gitlab-ci.yml create mode 100644 vendor/gitlab-ci-yml/Pages/harp.gitlab-ci.yml create mode 100644 vendor/gitlab-ci-yml/Pages/hexo.gitlab-ci.yml create mode 100644 vendor/gitlab-ci-yml/Pages/html.gitlab-ci.yml create mode 100644 vendor/gitlab-ci-yml/Pages/hugo.gitlab-ci.yml create mode 100644 vendor/gitlab-ci-yml/Pages/hyde.gitlab-ci.yml create mode 100644 vendor/gitlab-ci-yml/Pages/jekyll.gitlab-ci.yml create mode 100644 vendor/gitlab-ci-yml/Pages/lektor.gitlab-ci.yml create mode 100644 vendor/gitlab-ci-yml/Pages/metalsmith.gitlab-ci.yml create mode 100644 vendor/gitlab-ci-yml/Pages/middleman.gitlab-ci.yml create mode 100644 vendor/gitlab-ci-yml/Pages/nanoc.gitlab-ci.yml create mode 100644 vendor/gitlab-ci-yml/Pages/octopress.gitlab-ci.yml create mode 100644 vendor/gitlab-ci-yml/Pages/pelican.gitlab-ci.yml diff --git a/vendor/gitlab-ci-yml/LICENSE b/vendor/gitlab-ci-yml/LICENSE new file mode 100644 index 00000000000..80f7b87b6c0 --- /dev/null +++ b/vendor/gitlab-ci-yml/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 GitLab.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/gitlab-ci-yml/Pages/brunch.gitlab-ci.yml b/vendor/gitlab-ci-yml/Pages/brunch.gitlab-ci.yml new file mode 100644 index 00000000000..7fcc0b436b5 --- /dev/null +++ b/vendor/gitlab-ci-yml/Pages/brunch.gitlab-ci.yml @@ -0,0 +1,16 @@ +# Full project: https://gitlab.com/pages/brunch +image: node:4.2.2 + +pages: + cache: + paths: + - node_modules/ + + script: + - npm install -g brunch + - brunch build --production + artifacts: + paths: + - public + only: + - master diff --git a/vendor/gitlab-ci-yml/Pages/doxygen.gitlab-ci.yml b/vendor/gitlab-ci-yml/Pages/doxygen.gitlab-ci.yml new file mode 100644 index 00000000000..791afdd23f1 --- /dev/null +++ b/vendor/gitlab-ci-yml/Pages/doxygen.gitlab-ci.yml @@ -0,0 +1,13 @@ +# Full project: https://gitlab.com/pages/doxygen +image: alpine + +pages: + script: + - apk update && apk add doxygen + - doxygen doxygen/Doxyfile + - mv doxygen/documentation/html/ public/ + artifacts: + paths: + - public + only: + - master diff --git a/vendor/gitlab-ci-yml/Pages/harp.gitlab-ci.yml b/vendor/gitlab-ci-yml/Pages/harp.gitlab-ci.yml new file mode 100644 index 00000000000..dd3ef149668 --- /dev/null +++ b/vendor/gitlab-ci-yml/Pages/harp.gitlab-ci.yml @@ -0,0 +1,16 @@ +# Full project: https://gitlab.com/pages/harp +image: node:4.2.2 + +pages: + cache: + paths: + - node_modules + + script: + - npm install -g harp + - harp compile ./ public + artifacts: + paths: + - public + only: + - master diff --git a/vendor/gitlab-ci-yml/Pages/hexo.gitlab-ci.yml b/vendor/gitlab-ci-yml/Pages/hexo.gitlab-ci.yml new file mode 100644 index 00000000000..b468d79bcad --- /dev/null +++ b/vendor/gitlab-ci-yml/Pages/hexo.gitlab-ci.yml @@ -0,0 +1,25 @@ +# Full project: https://gitlab.com/pages/hexo +image: python:2.7 + +cache: + paths: + - vendor/ + +test: + stage: test + script: + - pip install hyde + - hyde gen + except: + - master + +pages: + stage: deploy + script: + - pip install hyde + - hyde gen -d public + artifacts: + paths: + - public + only: + - master diff --git a/vendor/gitlab-ci-yml/Pages/html.gitlab-ci.yml b/vendor/gitlab-ci-yml/Pages/html.gitlab-ci.yml new file mode 100644 index 00000000000..249a168aa33 --- /dev/null +++ b/vendor/gitlab-ci-yml/Pages/html.gitlab-ci.yml @@ -0,0 +1,12 @@ +# Full project: https://gitlab.com/pages/plain-html +pages: + stage: deploy + script: + - mkdir .public + - cp -r * .public + - mv .public public + artifacts: + paths: + - public + only: + - master diff --git a/vendor/gitlab-ci-yml/Pages/hugo.gitlab-ci.yml b/vendor/gitlab-ci-yml/Pages/hugo.gitlab-ci.yml new file mode 100644 index 00000000000..45df6975259 --- /dev/null +++ b/vendor/gitlab-ci-yml/Pages/hugo.gitlab-ci.yml @@ -0,0 +1,11 @@ +# Full project: https://gitlab.com/pages/hugo +image: publysher/hugo + +pages: + script: + - hugo + artifacts: + paths: + - public + only: + - master diff --git a/vendor/gitlab-ci-yml/Pages/hyde.gitlab-ci.yml b/vendor/gitlab-ci-yml/Pages/hyde.gitlab-ci.yml new file mode 100644 index 00000000000..f5b40f2b9f1 --- /dev/null +++ b/vendor/gitlab-ci-yml/Pages/hyde.gitlab-ci.yml @@ -0,0 +1,25 @@ +# Full project: https://gitlab.com/pages/hyde +image: python:2.7 + +cache: + paths: + - vendor/ + +test: + stage: test + script: + - pip install hyde + - hyde gen + except: + - master + +pages: + stage: deploy + script: + - pip install hyde + - hyde gen -d public + artifacts: + paths: + - public + only: + - master diff --git a/vendor/gitlab-ci-yml/Pages/jekyll.gitlab-ci.yml b/vendor/gitlab-ci-yml/Pages/jekyll.gitlab-ci.yml new file mode 100644 index 00000000000..36918fc005a --- /dev/null +++ b/vendor/gitlab-ci-yml/Pages/jekyll.gitlab-ci.yml @@ -0,0 +1,24 @@ +# Full project: https://gitlab.com/pages/jekyll +image: ruby:2.3 + +test: + stage: test + script: + - gem install jekyll + - jekyll build -d test + artifacts: + paths: + - test + except: + - master + +pages: + stage: deploy + script: + - gem install jekyll + - jekyll build -d public + artifacts: + paths: + - public + only: + - master diff --git a/vendor/gitlab-ci-yml/Pages/lektor.gitlab-ci.yml b/vendor/gitlab-ci-yml/Pages/lektor.gitlab-ci.yml new file mode 100644 index 00000000000..c5c44a5d86c --- /dev/null +++ b/vendor/gitlab-ci-yml/Pages/lektor.gitlab-ci.yml @@ -0,0 +1,12 @@ +# Full project: https://gitlab.com/pages/hyde +image: python:2.7 + +pages: + script: + - pip install lektor + - lektor build --output-path public + artifacts: + paths: + - public + only: + - master diff --git a/vendor/gitlab-ci-yml/Pages/metalsmith.gitlab-ci.yml b/vendor/gitlab-ci-yml/Pages/metalsmith.gitlab-ci.yml new file mode 100644 index 00000000000..50e8b7ccd46 --- /dev/null +++ b/vendor/gitlab-ci-yml/Pages/metalsmith.gitlab-ci.yml @@ -0,0 +1,17 @@ +# Full project: https://gitlab.com/pages/metalsmith +image: node:4.2.2 + +pages: + cache: + paths: + - node_modules/ + + script: + - npm install -g metalsmith + - npm install + - make build + artifacts: + paths: + - public + only: + - master diff --git a/vendor/gitlab-ci-yml/Pages/middleman.gitlab-ci.yml b/vendor/gitlab-ci-yml/Pages/middleman.gitlab-ci.yml new file mode 100644 index 00000000000..9f4cc0574d6 --- /dev/null +++ b/vendor/gitlab-ci-yml/Pages/middleman.gitlab-ci.yml @@ -0,0 +1,27 @@ +# Full project: https://gitlab.com/pages/middleman +image: ruby:2.3 + +cache: + paths: + - vendor + +test: + script: + - apt-get update -yqqq + - apt-get install -y nodejs + - bundle install --path vendor + - bundle exec middleman build + except: + - master + +pages: + script: + - apt-get update -yqqq + - apt-get install -y nodejs + - bundle install --path vendor + - bundle exec middleman build + artifacts: + paths: + - public + only: + - master diff --git a/vendor/gitlab-ci-yml/Pages/nanoc.gitlab-ci.yml b/vendor/gitlab-ci-yml/Pages/nanoc.gitlab-ci.yml new file mode 100644 index 00000000000..b469b316ba5 --- /dev/null +++ b/vendor/gitlab-ci-yml/Pages/nanoc.gitlab-ci.yml @@ -0,0 +1,12 @@ +# Full project: https://gitlab.com/pages/nanoc +image: ruby:2.3 + +pages: + script: + - bundle install -j4 + - nanoc + artifacts: + paths: + - public + only: + - master diff --git a/vendor/gitlab-ci-yml/Pages/octopress.gitlab-ci.yml b/vendor/gitlab-ci-yml/Pages/octopress.gitlab-ci.yml new file mode 100644 index 00000000000..4762ec9acfd --- /dev/null +++ b/vendor/gitlab-ci-yml/Pages/octopress.gitlab-ci.yml @@ -0,0 +1,15 @@ +# Full project: https://gitlab.com/pages/octopress +image: ruby:2.3 + +pages: + script: + - apt-get update -qq && apt-get install -qq nodejs + - bundle install -j4 + - bundle exec rake generate + - mv public .public + - mv .public/octopress public + artifacts: + paths: + - public + only: + - master diff --git a/vendor/gitlab-ci-yml/Pages/pelican.gitlab-ci.yml b/vendor/gitlab-ci-yml/Pages/pelican.gitlab-ci.yml new file mode 100644 index 00000000000..c5f3154f587 --- /dev/null +++ b/vendor/gitlab-ci-yml/Pages/pelican.gitlab-ci.yml @@ -0,0 +1,10 @@ +# Full project: https://gitlab.com/pages/pelican +image: python:2.7-alpine + +pages: + script: + - pip install -r requirements.txt + - pelican -s publishconf.py + artifacts: + paths: + - public/ -- cgit v1.2.1 From 620d014aefd23030ed6ae043e223ccc5dc52fc8a Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Thu, 2 Jun 2016 18:20:08 +0200 Subject: Implement backend gitlab ci dropdown This commit builds on the groundwork in ee008e300b1ec0abcc90e6a30816ec0754cea0dd, which refactored the backend so the same code could be used for new dropdowns. In this commit its used for templates for the `.gitlab-ci.yml` files. --- app/helpers/blob_helper.rb | 14 ++++++--- lib/api/templates.rb | 3 +- lib/gitlab/template/base_template.rb | 35 +++++++++++++++------- lib/gitlab/template/gitignore.rb | 5 ++-- lib/gitlab/template/gitlab_ci_yml.rb | 22 ++++++++++++++ lib/tasks/gitlab/update_templates.rake | 55 ++++++++++++++-------------------- spec/requests/api/gitignores_spec.rb | 29 ------------------ spec/requests/api/templates_spec.rb | 43 ++++++++++++++++++++++++++ 8 files changed, 126 insertions(+), 80 deletions(-) create mode 100644 lib/gitlab/template/gitlab_ci_yml.rb delete mode 100644 spec/requests/api/gitignores_spec.rb create mode 100644 spec/requests/api/templates_spec.rb diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 2d42cce95ce..b30a01614be 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -186,10 +186,16 @@ module BlobHelper end def gitignore_names - return @gitignore_names if defined?(@gitignore_names) + @gitignore_names ||= + Gitlab::Template::Gitignore.categories.keys.map do |k| + [k, Gitlab::Template::Gitignore.by_category(k).map { |t| { name: t.name } }] + end.to_h + end - @gitignore_names = Gitlab::Template::Gitignore.categories.map do |k, _| - [k, Gitlab::Template::Gitignore.by_category(k)] - end.to_h + def gitlab_ci_ymls + @gitlab_ci_ymls ||= + Gitlab::Template::GitlabCIYml.categories.keys.map do |k| + [k, Gitlab::Template::GitlabCIYml.by_category(k).map { |t| { name: t.name } }] + end.to_h end end diff --git a/lib/api/templates.rb b/lib/api/templates.rb index 4c770c0b9dd..9f5f10a5088 100644 --- a/lib/api/templates.rb +++ b/lib/api/templates.rb @@ -1,7 +1,8 @@ module API class Templates < Grape::API TEMPLATE_TYPES = { - gitignores: Gitlab::Template::Gitignore + gitignores: Gitlab::Template::Gitignore, + gitlab_ci_ymls: Gitlab::Template::GitlabCIYml }.freeze TEMPLATE_TYPES.each do |template, klass| diff --git a/lib/gitlab/template/base_template.rb b/lib/gitlab/template/base_template.rb index e1cdfc8f5f6..652a496b57b 100644 --- a/lib/gitlab/template/base_template.rb +++ b/lib/gitlab/template/base_template.rb @@ -13,40 +13,53 @@ module Gitlab File.read(@path) end + def categories + raise NotImplementedError + end + + def extension + raise NotImplementedError + end + + def base_dir + raise NotImplementedError + end + class << self def all - self.category_directories.flat_map do |dir| - templates_for_folder(dir) - end + self.categories.keys.flat_map { |cat| by_category(cat) } end def find(key) file_name = "#{key}#{self.extension}" directory = select_directory(file_name) - directory ? new(File.join(directory, file_name)) : nil + directory ? new(File.join(category_directory(directory), file_name)) : nil end def by_category(category) - templates_for_folder(categories[category]) + templates_for_directory(category_directory(category)) end - def category_directories - self.categories.values.map { |subdir| File.join(base_dir, subdir)} + def category_directory(category) + File.join(base_dir, categories[category]) end private def select_directory(file_name) - category_directories.find { |dir| File.exist?(File.join(dir, file_name)) } + categories.keys.find do |category| + File.exist?(File.join(category_directory(category), file_name)) + end end - def templates_for_folder(dir) - Dir.glob("#{dir.to_s}/*#{self.extension}").select { |f| f =~ filter_regex }.map { |f| new(f) } + def templates_for_directory(dir) + dir << '/' unless dir.end_with?('/') + Dir.glob(File.join(dir, "*#{self.extension}")).select { |f| f =~ filter_regex }.map { |f| new(f) } end def filter_regex - /#{Regexp.escape(extension)}\z/ + @filter_reges ||= /#{Regexp.escape(extension)}\z/ end end end diff --git a/lib/gitlab/template/gitignore.rb b/lib/gitlab/template/gitignore.rb index 73fb3b18c4d..964fbfd4de3 100644 --- a/lib/gitlab/template/gitignore.rb +++ b/lib/gitlab/template/gitignore.rb @@ -1,7 +1,6 @@ module Gitlab module Template class Gitignore < BaseTemplate - class << self def extension '.gitignore' @@ -9,8 +8,8 @@ module Gitlab def categories { - Languages: '', - Global: 'Global' + "Languages" => '', + "Global" => 'Global' } end diff --git a/lib/gitlab/template/gitlab_ci_yml.rb b/lib/gitlab/template/gitlab_ci_yml.rb new file mode 100644 index 00000000000..20377499ac9 --- /dev/null +++ b/lib/gitlab/template/gitlab_ci_yml.rb @@ -0,0 +1,22 @@ +module Gitlab + module Template + class GitlabCIYml < BaseTemplate + class << self + def extension + '.gitlab-ci.yml' + end + + def categories + { + "General" => '', + "Pages" =>'Pages' + } + end + + def base_dir + Rails.root.join('vendor/gitlab-ci-yml') + end + end + end + end +end diff --git a/lib/tasks/gitlab/update_templates.rake b/lib/tasks/gitlab/update_templates.rake index 36ffad8aae9..90b1a64ed5a 100644 --- a/lib/tasks/gitlab/update_templates.rake +++ b/lib/tasks/gitlab/update_templates.rake @@ -1,35 +1,34 @@ namespace :gitlab do desc "GitLab | Update templates" task :update_templates do - update("gitignore") - update("gitlab-ci-yml") + TEMPLATE_DATA.each { |template| update(template) } end - def update(directory) - unless clone_repository(directory) - puts "Cloning the #{directory} templates failed".red + def update(template) + sub_dir = template.repo_url.match(/([a-z-]+)\.git\z/)[1] + dir = File.join(vendor_directory, sub_dir) + + unless clone_repository(template.repo_url, dir) + puts "Cloning the #{sub_dir} templates failed".red return end - remove_unneeded_files(directory) + remove_unneeded_files(dir, template.cleanup_regex) puts "Done".green end - def clone_repository(directory) - dir = File.join(vendor_directory, directory) - FileUtils.rm_rf(dir) if Dir.exist?(dir) - FileUtils.cd vendor_directory + def clone_repository(url, directory) + FileUtils.rm_rf(directory) if Dir.exist?(directory) - system("git clone --depth=1 --branch=master #{TEMPLATE_DATA[directory]}") + system("git clone #{url} --depth=1 --branch=master #{directory}") end # Retain only certain files: # - The LICENSE, because we have to - # - The sub dir global - # - The gitignores themself + # - The sub dirs so we can organise the file by category + # - The templates themself # - Dir.entires returns also the entries '.' and '..' - def remove_unneeded_files(directory) - regex = CLEANUP_REGEX[directory] + def remove_unneeded_files(directory, regex) Dir.foreach(directory) do |file| FileUtils.rm_rf(File.join(directory, file)) unless file =~ regex end @@ -37,25 +36,17 @@ namespace :gitlab do private - TEMPLATE_DATA = { - "gitignore" => "https://github.com/github/gitignore.git", - "gitlab-ci-yml" => "https://gitlab.com/gitlab-org/gitlab-ci-yml.git" - }.freeze - - CLEANUP_REGEX = { - "gitignore" => /(\.{1,2}|LICENSE|Global|\.gitignore)\z/, - "gitlab-ci-yml" => /(\.{1,2}|LICENSE|Pages|\.gitignore)\z/ - }.freeze + Template = Struct.new(:repo_url, :cleanup_regex) + TEMPLATE_DATA = [Template.new( + "https://github.com/github/gitignore.git", + /(\.{1,2}|LICENSE|Global|\.gitignore)\z/ + ), + Template.new( + "https://gitlab.com/gitlab-org/gitlab-ci-yml.git", + /(\.{1,2}|LICENSE|Pages|\.gitignore)\z/ + )] def vendor_directory Rails.root.join('vendor') end - - def gitignore_directory - File.join(vendor_directory, 'gitignore') - end - - def gitlab_ci_directory - File.join(vendor_directory, 'gitlab-ci') - end end diff --git a/spec/requests/api/gitignores_spec.rb b/spec/requests/api/gitignores_spec.rb deleted file mode 100644 index 9130312c057..00000000000 --- a/spec/requests/api/gitignores_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper' - -describe API::Templates, api: true do - include ApiHelpers - - describe 'Entity Gitignore' do - before { get api('/gitignores/Ruby') } - - it { expect(json_response['name']).to eq('Ruby') } - it { expect(json_response['content']).to include('*.gem') } - end - - describe 'Entity GitignoresList' do - before { get api('/gitignores') } - - it { expect(json_response.first['name']).not_to be_nil } - it { expect(json_response.first['content']).to be_nil } - end - - describe 'GET /gitignores' do - it 'returns a list of available license templates' do - get api('/gitignores') - - expect(response.status).to eq(200) - expect(json_response).to be_an Array - expect(json_response.size).to be > 15 - end - end -end diff --git a/spec/requests/api/templates_spec.rb b/spec/requests/api/templates_spec.rb new file mode 100644 index 00000000000..0e9a28b1ff6 --- /dev/null +++ b/spec/requests/api/templates_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' + +describe API::Templates, api: true do + include ApiHelpers + + describe 'the Template Entity' do + before { get api('/gitignores/Ruby') } + + it { expect(json_response['name']).to eq('Ruby') } + it { expect(json_response['content']).to include('*.gem') } + end + + describe 'the TemplateList Entity' do + before { get api('/gitignores') } + + it { expect(json_response.first['name']).not_to be_nil } + it { expect(json_response.first['content']).to be_nil } + end + + context 'requesting gitignores' do + describe 'GET /gitignores' do + it 'returns a list of available gitignore templates' do + get api('/gitignores') + + expect(response.status).to eq(200) + expect(json_response).to be_an Array + expect(json_response.size).to be > 15 + end + end + end + + context 'requesting gitlab-ci-ymls' do + describe 'GET /gitlab_ci_ymls' do + it 'returns a list of available gitlab_ci_ymls' do + get api('/gitlab_ci_ymls') + + expect(response.status).to eq(200) + expect(json_response).to be_an Array + expect(json_response.first['name']).not_to be_nil + end + end + end +end -- cgit v1.2.1 From 5d12189296e173616ee980c60943680ed2d7d061 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Thu, 16 Jun 2016 02:06:30 -0500 Subject: Add GitLab CI Yml dropdown selector --- app/assets/javascripts/api.js.coffee | 7 +++++++ app/assets/javascripts/blob/blob_ci_yaml.js.coffee | 23 ++++++++++++++++++++++ app/assets/javascripts/blob/edit_blob.js.coffee | 1 + app/assets/stylesheets/pages/editor.scss | 11 +++++++++-- app/views/projects/blob/_editor.html.haml | 2 ++ 5 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/blob/blob_ci_yaml.js.coffee diff --git a/app/assets/javascripts/api.js.coffee b/app/assets/javascripts/api.js.coffee index 3f61ea1eaf4..d543e3b7a96 100644 --- a/app/assets/javascripts/api.js.coffee +++ b/app/assets/javascripts/api.js.coffee @@ -7,6 +7,7 @@ labelsPath: "/api/:version/projects/:id/labels" licensePath: "/api/:version/licenses/:key" gitignorePath: "/api/:version/gitignores/:key" + gitlabCIYmlPath: "/api/:version/gitlab_ci_ymls/:key" group: (group_id, callback) -> url = Api.buildUrl(Api.groupPath) @@ -110,6 +111,12 @@ $.get url, (gitignore) -> callback(gitignore) + gitlabCIYml: (key, callback) -> + url = Api.buildUrl(Api.gitlabCIYmlPath).replace(':key', key) + + $.get url, (file) -> + callback(file) + buildUrl: (url) -> url = gon.relative_url_root + url if gon.relative_url_root? return url.replace(':version', gon.api_version) diff --git a/app/assets/javascripts/blob/blob_ci_yaml.js.coffee b/app/assets/javascripts/blob/blob_ci_yaml.js.coffee new file mode 100644 index 00000000000..dc14700d305 --- /dev/null +++ b/app/assets/javascripts/blob/blob_ci_yaml.js.coffee @@ -0,0 +1,23 @@ +#= require blob/template_selector + +class @BlobCiYamlSelector extends TemplateSelector + requestFile: (query) -> + Api.gitlabCIYml query.name, @requestFileSuccess.bind(@) + +class @BlobCiYamlSelectors + constructor: (opts) -> + { + @$dropdowns = $('.js-gitlab-ci-yml-selector') + @editor + } = opts + + @$dropdowns.each (i, dropdown) => + $dropdown = $(dropdown) + + new BlobCiYamlSelector( + pattern: /(.gitlab-ci.yml)/, + data: $dropdown.data('data'), + wrapper: $dropdown.closest('.js-gitlab-ci-yml-selector-wrap'), + dropdown: $dropdown, + editor: @editor + ) diff --git a/app/assets/javascripts/blob/edit_blob.js.coffee b/app/assets/javascripts/blob/edit_blob.js.coffee index 636f909dbd0..19e584519d7 100644 --- a/app/assets/javascripts/blob/edit_blob.js.coffee +++ b/app/assets/javascripts/blob/edit_blob.js.coffee @@ -15,6 +15,7 @@ class @EditBlob new BlobLicenseSelectors { @editor } new BlobGitignoreSelectors { @editor } + new BlobCiYamlSelectors { @editor } initModePanesAndLinks: -> @$editModePanes = $(".js-edit-mode-pane") diff --git a/app/assets/stylesheets/pages/editor.scss b/app/assets/stylesheets/pages/editor.scss index a34b06f1054..1aa4e06d975 100644 --- a/app/assets/stylesheets/pages/editor.scss +++ b/app/assets/stylesheets/pages/editor.scss @@ -60,13 +60,14 @@ .encoding-selector, .license-selector, - .gitignore-selector { + .gitignore-selector, + .gitlab-ci-yml-selector { display: inline-block; vertical-align: top; font-family: $regular_font; } - .gitignore-selector, .license-selector { + .gitignore-selector, .license-selector, .gitlab-ci-yml-selector { .dropdown { line-height: 21px; } @@ -76,4 +77,10 @@ width: 220px; } } + + .gitlab-ci-yml-selector { + .dropdown-menu-toggle { + width: 250px; + } + } } diff --git a/app/views/projects/blob/_editor.html.haml b/app/views/projects/blob/_editor.html.haml index ae89637df60..29c7d45074a 100644 --- a/app/views/projects/blob/_editor.html.haml +++ b/app/views/projects/blob/_editor.html.haml @@ -17,6 +17,8 @@ = dropdown_tag("Choose a License template", options: { toggle_class: 'js-license-selector', title: "Choose a license", filter: true, placeholder: "Filter", data: { data: licenses_for_select, project: @project.name, fullname: @project.namespace.human_name } } ) .gitignore-selector.js-gitignore-selector-wrap.hidden = dropdown_tag("Choose a .gitignore template", options: { toggle_class: 'js-gitignore-selector', title: "Choose a template", filter: true, placeholder: "Filter", data: { data: gitignore_names } } ) + .gitlab-ci-yml-selector.js-gitlab-ci-yml-selector-wrap.hidden + = dropdown_tag("Choose a GitLab CI Yaml template", options: { toggle_class: 'js-gitlab-ci-yml-selector', title: "Choose a template", filter: true, placeholder: "Filter", data: { data: gitlab_ci_ymls } } ) .encoding-selector = select_tag :encoding, options_for_select([ "base64", "text" ], "text"), class: 'select2' -- cgit v1.2.1 From 8039856d80ce710f69af611f58857b29b74712b4 Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Thu, 16 Jun 2016 10:09:41 +0200 Subject: Add changelog item, fix rubocop issue --- CHANGELOG | 1 + lib/gitlab/template/gitlab_ci_yml.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 0e19ae06715..f26512c87ba 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -102,6 +102,7 @@ v 8.9.0 (unreleased) - An indicator is now displayed at the top of the comment field for confidential issues. - Show categorised search queries in the search autocomplete - RepositoryCheck::SingleRepositoryWorker public and private methods are now instrumented + - Dropdown for `.gitlab-ci.yml` templates - Improve issuables APIs performance when accessing notes !4471 - Add sorting dropdown to tags page !4423 - External links now open in a new tab diff --git a/lib/gitlab/template/gitlab_ci_yml.rb b/lib/gitlab/template/gitlab_ci_yml.rb index 20377499ac9..da7273b8d70 100644 --- a/lib/gitlab/template/gitlab_ci_yml.rb +++ b/lib/gitlab/template/gitlab_ci_yml.rb @@ -9,7 +9,7 @@ module Gitlab def categories { "General" => '', - "Pages" =>'Pages' + "Pages" => 'Pages' } end -- cgit v1.2.1 From 96ae6099dd5921ae32139a206d598043520fb506 Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Thu, 16 Jun 2016 10:39:17 +0200 Subject: Run rake gitlab:update_templates --- lib/tasks/gitlab/update_templates.rake | 2 +- vendor/gitignore/Android.gitignore | 3 ++- vendor/gitignore/C++.gitignore | 1 + vendor/gitignore/CMake.gitignore | 1 + vendor/gitignore/D.gitignore | 4 ++++ vendor/gitignore/Global/Bazaar.gitignore | 2 ++ vendor/gitignore/Global/OSX.gitignore | 3 ++- vendor/gitignore/Global/README.md | 10 +++++++++ vendor/gitignore/Global/SublimeText.gitignore | 13 ++++++++++++ vendor/gitignore/Haskell.gitignore | 1 + vendor/gitignore/Julia.gitignore | 4 ++++ vendor/gitignore/LICENSE | 19 +++++++++++++++++ vendor/gitignore/Laravel.gitignore | 1 - vendor/gitignore/Objective-C.gitignore | 9 ++++++++ vendor/gitignore/Qt.gitignore | 2 +- vendor/gitignore/README.md | 14 ------------- vendor/gitignore/Rails.gitignore | 4 ++++ vendor/gitignore/Swift.gitignore | 2 ++ vendor/gitignore/UnrealEngine.gitignore | 1 + vendor/gitignore/VisualStudio.gitignore | 1 + vendor/gitlab-ci-yml/Docker.gitlab-ci.yml | 7 +++++++ vendor/gitlab-ci-yml/Elixir.gitlab-ci.yml | 18 ++++++++++++++++ vendor/gitlab-ci-yml/Nodejs.gitlab-ci.yml | 27 ++++++++++++++++++++++++ vendor/gitlab-ci-yml/Ruby.gitlab-ci.yml | 30 +++++++++++++++++++++++++++ 24 files changed, 160 insertions(+), 19 deletions(-) create mode 100644 vendor/gitignore/Global/Bazaar.gitignore create mode 100644 vendor/gitignore/Global/README.md create mode 100644 vendor/gitignore/Julia.gitignore create mode 100644 vendor/gitignore/LICENSE delete mode 100644 vendor/gitignore/README.md create mode 100644 vendor/gitlab-ci-yml/Docker.gitlab-ci.yml create mode 100644 vendor/gitlab-ci-yml/Elixir.gitlab-ci.yml create mode 100644 vendor/gitlab-ci-yml/Nodejs.gitlab-ci.yml create mode 100644 vendor/gitlab-ci-yml/Ruby.gitlab-ci.yml diff --git a/lib/tasks/gitlab/update_templates.rake b/lib/tasks/gitlab/update_templates.rake index 90b1a64ed5a..14277fe4c4b 100644 --- a/lib/tasks/gitlab/update_templates.rake +++ b/lib/tasks/gitlab/update_templates.rake @@ -43,7 +43,7 @@ namespace :gitlab do ), Template.new( "https://gitlab.com/gitlab-org/gitlab-ci-yml.git", - /(\.{1,2}|LICENSE|Pages|\.gitignore)\z/ + /(\.{1,2}|LICENSE|Pages|\.gitlab-ci.yml)\z/ )] def vendor_directory diff --git a/vendor/gitignore/Android.gitignore b/vendor/gitignore/Android.gitignore index a8368751267..f6b286cea98 100644 --- a/vendor/gitignore/Android.gitignore +++ b/vendor/gitignore/Android.gitignore @@ -2,7 +2,7 @@ *.apk *.ap_ -# Files for the Dalvik VM +# Files for the ART/Dalvik VM *.dex # Java class files @@ -34,6 +34,7 @@ captures/ # Intellij *.iml +.idea/workspace.xml # Keystore files *.jks diff --git a/vendor/gitignore/C++.gitignore b/vendor/gitignore/C++.gitignore index b8bd0267bdf..4581ef2eeef 100644 --- a/vendor/gitignore/C++.gitignore +++ b/vendor/gitignore/C++.gitignore @@ -15,6 +15,7 @@ # Fortran module files *.mod +*.smod # Compiled Static libraries *.lai diff --git a/vendor/gitignore/CMake.gitignore b/vendor/gitignore/CMake.gitignore index b558e9afa6d..0cc7e4b5275 100644 --- a/vendor/gitignore/CMake.gitignore +++ b/vendor/gitignore/CMake.gitignore @@ -4,3 +4,4 @@ CMakeScripts Makefile cmake_install.cmake install_manifest.txt +CTestTestfile.cmake diff --git a/vendor/gitignore/D.gitignore b/vendor/gitignore/D.gitignore index b4433f8a512..74b926fc901 100644 --- a/vendor/gitignore/D.gitignore +++ b/vendor/gitignore/D.gitignore @@ -18,3 +18,7 @@ .dub docs.json __dummy.html +docs/ + +# Code coverage +*.lst diff --git a/vendor/gitignore/Global/Bazaar.gitignore b/vendor/gitignore/Global/Bazaar.gitignore new file mode 100644 index 00000000000..3cbbcbd11ec --- /dev/null +++ b/vendor/gitignore/Global/Bazaar.gitignore @@ -0,0 +1,2 @@ +.bzr/ +.bzrignore diff --git a/vendor/gitignore/Global/OSX.gitignore b/vendor/gitignore/Global/OSX.gitignore index 660b31353e8..5972fe50f66 100644 --- a/vendor/gitignore/Global/OSX.gitignore +++ b/vendor/gitignore/Global/OSX.gitignore @@ -1,4 +1,4 @@ -.DS_Store +*.DS_Store .AppleDouble .LSOverride @@ -15,6 +15,7 @@ Icon .TemporaryItems .Trashes .VolumeIcon.icns +.com.apple.timemachine.donotpresent # Directories potentially created on remote AFP share .AppleDB diff --git a/vendor/gitignore/Global/README.md b/vendor/gitignore/Global/README.md new file mode 100644 index 00000000000..06b6649bd9a --- /dev/null +++ b/vendor/gitignore/Global/README.md @@ -0,0 +1,10 @@ +## Globally Useful gitignores + +This directory contains globally useful gitignores, +e.g. OS-specific and editor specific. + +For more on global gitignores: + + +And a good blog post about 'em: + diff --git a/vendor/gitignore/Global/SublimeText.gitignore b/vendor/gitignore/Global/SublimeText.gitignore index 1d4e6137591..69c8c2b29ce 100644 --- a/vendor/gitignore/Global/SublimeText.gitignore +++ b/vendor/gitignore/Global/SublimeText.gitignore @@ -12,3 +12,16 @@ # sftp configuration file sftp-config.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +bh_unicode_properties.cache + +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings diff --git a/vendor/gitignore/Haskell.gitignore b/vendor/gitignore/Haskell.gitignore index 096abdd90b3..a4ee41ab62b 100644 --- a/vendor/gitignore/Haskell.gitignore +++ b/vendor/gitignore/Haskell.gitignore @@ -16,3 +16,4 @@ cabal.sandbox.config *.hp *.eventlog .stack-work/ +cabal.project.local diff --git a/vendor/gitignore/Julia.gitignore b/vendor/gitignore/Julia.gitignore new file mode 100644 index 00000000000..381e0b6d252 --- /dev/null +++ b/vendor/gitignore/Julia.gitignore @@ -0,0 +1,4 @@ +*.jl.cov +*.jl.*.cov +*.jl.mem +deps/deps.jl diff --git a/vendor/gitignore/LICENSE b/vendor/gitignore/LICENSE new file mode 100644 index 00000000000..b8a103ac9b1 --- /dev/null +++ b/vendor/gitignore/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2016 GitHub, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/vendor/gitignore/Laravel.gitignore b/vendor/gitignore/Laravel.gitignore index c491fa2bc6f..1cd717b6921 100644 --- a/vendor/gitignore/Laravel.gitignore +++ b/vendor/gitignore/Laravel.gitignore @@ -7,7 +7,6 @@ app/storage/ # Laravel 5 & Lumen specific bootstrap/cache/ -storage/ .env.*.php .env.php .env diff --git a/vendor/gitignore/Objective-C.gitignore b/vendor/gitignore/Objective-C.gitignore index 3020bc327a7..86f21d8e0ff 100644 --- a/vendor/gitignore/Objective-C.gitignore +++ b/vendor/gitignore/Objective-C.gitignore @@ -24,6 +24,8 @@ xcuserdata/ ## Obj-C/Swift specific *.hmap *.ipa +*.dSYM.zip +*.dSYM # CocoaPods # @@ -49,3 +51,10 @@ Carthage/Build fastlane/report.xml fastlane/screenshots + +#Code Injection +# +# After new code Injection tools there's a generated folder /iOSInjectionProject +# https://github.com/johnno1962/injectionforxcode + +iOSInjectionProject/ diff --git a/vendor/gitignore/Qt.gitignore b/vendor/gitignore/Qt.gitignore index fa24b2efee8..c7659c24f38 100644 --- a/vendor/gitignore/Qt.gitignore +++ b/vendor/gitignore/Qt.gitignore @@ -34,5 +34,5 @@ Makefile* *.qmlproject.user.* # QtCtreator CMake -CMakeLists.txt.user +CMakeLists.txt.user* diff --git a/vendor/gitignore/README.md b/vendor/gitignore/README.md deleted file mode 100644 index 43131e815cc..00000000000 --- a/vendor/gitignore/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# .gitignore templates - -This directory contains language-specific .gitignore templates that are used by GitLab. - -These files were automatically pulled from [this repository](https://github.com/github/gitignore). -Please submit pull requests to that repository. There is no need to edit the files in this directory. - -## Bulk Update - -To update this directory with the latest changes in the repository, run: - -```sh -bundle exec rake gitlab:update_gitignore -``` diff --git a/vendor/gitignore/Rails.gitignore b/vendor/gitignore/Rails.gitignore index 2121e0a8038..d8c256c1925 100644 --- a/vendor/gitignore/Rails.gitignore +++ b/vendor/gitignore/Rails.gitignore @@ -16,6 +16,10 @@ pickle-email-*.html config/initializers/secret_token.rb config/secrets.yml +# dotenv +# TODO Comment out this rule if environment variables can be committed +.env + ## Environment normalization: /.bundle /vendor/bundle diff --git a/vendor/gitignore/Swift.gitignore b/vendor/gitignore/Swift.gitignore index 8a29fa52af4..2c22487b5e3 100644 --- a/vendor/gitignore/Swift.gitignore +++ b/vendor/gitignore/Swift.gitignore @@ -24,6 +24,8 @@ xcuserdata/ ## Obj-C/Swift specific *.hmap *.ipa +*.dSYM.zip +*.dSYM ## Playgrounds timeline.xctimeline diff --git a/vendor/gitignore/UnrealEngine.gitignore b/vendor/gitignore/UnrealEngine.gitignore index 75b1186b0af..be0e4913c3a 100644 --- a/vendor/gitignore/UnrealEngine.gitignore +++ b/vendor/gitignore/UnrealEngine.gitignore @@ -37,6 +37,7 @@ *.suo *.opensdf *.sdf +*.VC.db *.VC.opendb # Precompiled Assets diff --git a/vendor/gitignore/VisualStudio.gitignore b/vendor/gitignore/VisualStudio.gitignore index f1e3d20e056..67acbf42f5e 100644 --- a/vendor/gitignore/VisualStudio.gitignore +++ b/vendor/gitignore/VisualStudio.gitignore @@ -42,6 +42,7 @@ dlldata.c # DNX project.lock.json +project.fragment.lock.json artifacts/ *_i.c diff --git a/vendor/gitlab-ci-yml/Docker.gitlab-ci.yml b/vendor/gitlab-ci-yml/Docker.gitlab-ci.yml new file mode 100644 index 00000000000..396d3f1b042 --- /dev/null +++ b/vendor/gitlab-ci-yml/Docker.gitlab-ci.yml @@ -0,0 +1,7 @@ +# Official docker image. +image: docker:latest + +build: + stage: build + script: + - docker build -t test . diff --git a/vendor/gitlab-ci-yml/Elixir.gitlab-ci.yml b/vendor/gitlab-ci-yml/Elixir.gitlab-ci.yml new file mode 100644 index 00000000000..0b329aaf1c4 --- /dev/null +++ b/vendor/gitlab-ci-yml/Elixir.gitlab-ci.yml @@ -0,0 +1,18 @@ +# This template uses the non default language docker image +# The image already has Hex installed. You might want to consider to use `elixir:latest` +image: trenpixster/elixir:latest + +# Pic zero or more services to be used on all builds. +# Only needed when using a docker container to run your tests in. +# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service +services: + - mysql:latest + - redis:latest + - postgres:latest + +before_script: + - mix deps.get + +mix: + script: + - mix test diff --git a/vendor/gitlab-ci-yml/Nodejs.gitlab-ci.yml b/vendor/gitlab-ci-yml/Nodejs.gitlab-ci.yml new file mode 100644 index 00000000000..e5bce3503f3 --- /dev/null +++ b/vendor/gitlab-ci-yml/Nodejs.gitlab-ci.yml @@ -0,0 +1,27 @@ +# Official framework image. Look for the different tagged releases at: +# https://hub.docker.com/r/library/node/tags/ +image: node:latest + +# Pick zero or more services to be used on all builds. +# Only needed when using a docker container to run your tests in. +# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service +services: + - mysql:latest + - redis:latest + - postgres:latest + +# This folder is cached between builds +# http://docs.gitlab.com/ce/ci/yaml/README.html#cache +cache: + paths: + - node_modules/ + +test_async: + script: + - npm install + - node ./specs/start.js ./specs/async.spec.js + +test_db: + script: + - npm install + - node ./specs/start.js ./specs/db-postgres.spec.js diff --git a/vendor/gitlab-ci-yml/Ruby.gitlab-ci.yml b/vendor/gitlab-ci-yml/Ruby.gitlab-ci.yml new file mode 100644 index 00000000000..78f3e39949f --- /dev/null +++ b/vendor/gitlab-ci-yml/Ruby.gitlab-ci.yml @@ -0,0 +1,30 @@ +# Official language image. Look for the different tagged releases at: +# https://hub.docker.com/r/library/ruby/tags/ +image: "ruby:2.3" + +# Pick zero or more services to be used on all builds. +# Only needed when using a docker container to run your tests in. +# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service +services: + - mysql:latest + - redis:latest + - postgres:latest + +# This is a basic example for a gem or script which doesn't use +# services such as redis or postgres +before_script: + - gem install bundler # Bundler is not installed with the image + - bundle install -j $(nproc) # Install dependencies + +rubocop: + script: + - rubocop + +rspec: + script: + - rspec spec + +rails: + script: + - rake db:migrate + - rspec spec -- cgit v1.2.1 From 483dc62eaac0e11717b5b103317c4441ec0ff23d Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Thu, 16 Jun 2016 15:33:11 +0200 Subject: Incorporate review --- app/assets/javascripts/api.js.coffee | 6 +++--- app/assets/javascripts/blob/blob_ci_yaml.js.coffee | 2 +- app/helpers/blob_helper.rb | 4 ++-- lib/api/templates.rb | 6 +++++- lib/gitlab/template/base_template.rb | 4 +++- lib/gitlab/template/gitlab_ci_yml.rb | 2 +- lib/tasks/gitlab/update_templates.rake | 18 ++++++++++-------- spec/requests/api/templates_spec.rb | 9 +++++++++ 8 files changed, 34 insertions(+), 17 deletions(-) diff --git a/app/assets/javascripts/api.js.coffee b/app/assets/javascripts/api.js.coffee index d543e3b7a96..cf46f15a156 100644 --- a/app/assets/javascripts/api.js.coffee +++ b/app/assets/javascripts/api.js.coffee @@ -7,7 +7,7 @@ labelsPath: "/api/:version/projects/:id/labels" licensePath: "/api/:version/licenses/:key" gitignorePath: "/api/:version/gitignores/:key" - gitlabCIYmlPath: "/api/:version/gitlab_ci_ymls/:key" + gitlabCiYmlPath: "/api/:version/gitlab_ci_ymls/:key" group: (group_id, callback) -> url = Api.buildUrl(Api.groupPath) @@ -111,8 +111,8 @@ $.get url, (gitignore) -> callback(gitignore) - gitlabCIYml: (key, callback) -> - url = Api.buildUrl(Api.gitlabCIYmlPath).replace(':key', key) + gitlabCiYml: (key, callback) -> + url = Api.buildUrl(Api.gitlabCiYmlPath).replace(':key', key) $.get url, (file) -> callback(file) diff --git a/app/assets/javascripts/blob/blob_ci_yaml.js.coffee b/app/assets/javascripts/blob/blob_ci_yaml.js.coffee index dc14700d305..d9a03d05529 100644 --- a/app/assets/javascripts/blob/blob_ci_yaml.js.coffee +++ b/app/assets/javascripts/blob/blob_ci_yaml.js.coffee @@ -2,7 +2,7 @@ class @BlobCiYamlSelector extends TemplateSelector requestFile: (query) -> - Api.gitlabCIYml query.name, @requestFileSuccess.bind(@) + Api.gitlabCiYml query.name, @requestFileSuccess.bind(@) class @BlobCiYamlSelectors constructor: (opts) -> diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index b30a01614be..16d9d7d2d5a 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -194,8 +194,8 @@ module BlobHelper def gitlab_ci_ymls @gitlab_ci_ymls ||= - Gitlab::Template::GitlabCIYml.categories.keys.map do |k| - [k, Gitlab::Template::GitlabCIYml.by_category(k).map { |t| { name: t.name } }] + Gitlab::Template::GitlabCiYml.categories.keys.map do |k| + [k, Gitlab::Template::GitlabCiYml.by_category(k).map { |t| { name: t.name } }] end.to_h end end diff --git a/lib/api/templates.rb b/lib/api/templates.rb index 9f5f10a5088..33cbb0c9e1b 100644 --- a/lib/api/templates.rb +++ b/lib/api/templates.rb @@ -2,7 +2,7 @@ module API class Templates < Grape::API TEMPLATE_TYPES = { gitignores: Gitlab::Template::Gitignore, - gitlab_ci_ymls: Gitlab::Template::GitlabCIYml + gitlab_ci_ymls: Gitlab::Template::GitlabCiYml }.freeze TEMPLATE_TYPES.each do |template, klass| @@ -29,6 +29,10 @@ module API new_template = klass.find(params[:name]) not_found!("#{template.to_s.singularize}") unless new_template + if new_template.class == Gitlab::Template::GitlabCiYml + new_template.content = "# This file is a template, and might need editing before it works on your project.\n" + new_template.content + end + present new_template, with: Entities::Template end end diff --git a/lib/gitlab/template/base_template.rb b/lib/gitlab/template/base_template.rb index 652a496b57b..4086d8701bf 100644 --- a/lib/gitlab/template/base_template.rb +++ b/lib/gitlab/template/base_template.rb @@ -1,6 +1,8 @@ module Gitlab module Template class BaseTemplate + attr_writer :content + def initialize(path) @path = path end @@ -10,7 +12,7 @@ module Gitlab end def content - File.read(@path) + @content ||= File.read(@path) end def categories diff --git a/lib/gitlab/template/gitlab_ci_yml.rb b/lib/gitlab/template/gitlab_ci_yml.rb index da7273b8d70..f1e96d22d64 100644 --- a/lib/gitlab/template/gitlab_ci_yml.rb +++ b/lib/gitlab/template/gitlab_ci_yml.rb @@ -1,6 +1,6 @@ module Gitlab module Template - class GitlabCIYml < BaseTemplate + class GitlabCiYml < BaseTemplate class << self def extension '.gitlab-ci.yml' diff --git a/lib/tasks/gitlab/update_templates.rake b/lib/tasks/gitlab/update_templates.rake index 14277fe4c4b..2d3c7993445 100644 --- a/lib/tasks/gitlab/update_templates.rake +++ b/lib/tasks/gitlab/update_templates.rake @@ -37,14 +37,16 @@ namespace :gitlab do private Template = Struct.new(:repo_url, :cleanup_regex) - TEMPLATE_DATA = [Template.new( - "https://github.com/github/gitignore.git", - /(\.{1,2}|LICENSE|Global|\.gitignore)\z/ - ), - Template.new( - "https://gitlab.com/gitlab-org/gitlab-ci-yml.git", - /(\.{1,2}|LICENSE|Pages|\.gitlab-ci.yml)\z/ - )] + TEMPLATE_DATA = [ + Template.new( + "https://github.com/github/gitignore.git", + /(\.{1,2}|LICENSE|Global|\.gitignore)\z/ + ), + Template.new( + "https://gitlab.com/gitlab-org/gitlab-ci-yml.git", + /(\.{1,2}|LICENSE|Pages|\.gitlab-ci.yml)\z/ + ) + ] def vendor_directory Rails.root.join('vendor') diff --git a/spec/requests/api/templates_spec.rb b/spec/requests/api/templates_spec.rb index 0e9a28b1ff6..a6d5ade3013 100644 --- a/spec/requests/api/templates_spec.rb +++ b/spec/requests/api/templates_spec.rb @@ -40,4 +40,13 @@ describe API::Templates, api: true do end end end + + describe 'GET /gitlab_ci_ymls/Ruby' do + it 'adds a disclaimer on the top' do + get api('/gitlab_ci_ymls/Ruby') + + expect(response.status).to eq(200) + expect(json_response['content']).to start_with("# This file is a template,") + end + end end -- cgit v1.2.1 From a18df1d15af68be4d129412ad2a6145277ca43d3 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Thu, 16 Jun 2016 18:53:41 -0500 Subject: Add feature test for gitab CI dropdown --- .../projects/files/gitlab_ci_yml_dropdown_spec.rb | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb diff --git a/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb b/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb new file mode 100644 index 00000000000..d516e8ce55a --- /dev/null +++ b/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +feature 'User wants to add a .gitlab-ci.yml file', feature: true do + include WaitForAjax + + before do + user = create(:user) + project = create(:project) + project.team << [user, :master] + login_as user + visit namespace_project_new_blob_path(project.namespace, project, 'master', file_name: '.gitlab-ci.yml') + end + + scenario 'user can see .gitlab-ci.yml dropdown' do + expect(page).to have_css('.gitlab-ci-yml-selector') + end + + scenario 'user can pick a template from the dropdown', js: true do + find('.js-gitlab-ci-yml-selector').click + wait_for_ajax + within '.gitlab-ci-yml-selector' do + find('.dropdown-input-field').set('jekyll') + find('.dropdown-content li', text: 'jekyll').click + end + wait_for_ajax + + expect(page).to have_content('This file is a template, and might need editing before it works on your project') + expect(page).to have_content('jekyll build -d test') + end +end -- cgit v1.2.1 From bbfd62bc34061089f753e4170912be64bae16f84 Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Fri, 17 Jun 2016 08:37:19 +0200 Subject: fixup! override content method --- lib/api/templates.rb | 6 +----- lib/gitlab/template/base_template.rb | 28 +++++++++++++--------------- lib/gitlab/template/gitlab_ci_yml.rb | 5 +++++ lib/tasks/gitlab/update_templates.rake | 2 +- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/lib/api/templates.rb b/lib/api/templates.rb index 33cbb0c9e1b..18408797756 100644 --- a/lib/api/templates.rb +++ b/lib/api/templates.rb @@ -27,11 +27,7 @@ module API required_attributes! [:name] new_template = klass.find(params[:name]) - not_found!("#{template.to_s.singularize}") unless new_template - - if new_template.class == Gitlab::Template::GitlabCiYml - new_template.content = "# This file is a template, and might need editing before it works on your project.\n" + new_template.content - end + not_found!(template.to_s.singularize) unless new_template present new_template, with: Entities::Template end diff --git a/lib/gitlab/template/base_template.rb b/lib/gitlab/template/base_template.rb index 4086d8701bf..760ff3e614a 100644 --- a/lib/gitlab/template/base_template.rb +++ b/lib/gitlab/template/base_template.rb @@ -1,8 +1,6 @@ module Gitlab module Template class BaseTemplate - attr_writer :content - def initialize(path) @path = path end @@ -12,19 +10,7 @@ module Gitlab end def content - @content ||= File.read(@path) - end - - def categories - raise NotImplementedError - end - - def extension - raise NotImplementedError - end - - def base_dir - raise NotImplementedError + File.read(@path) end class << self @@ -39,6 +25,18 @@ module Gitlab directory ? new(File.join(category_directory(directory), file_name)) : nil end + def categories + raise NotImplementedError + end + + def extension + raise NotImplementedError + end + + def base_dir + raise NotImplementedError + end + def by_category(category) templates_for_directory(category_directory(category)) end diff --git a/lib/gitlab/template/gitlab_ci_yml.rb b/lib/gitlab/template/gitlab_ci_yml.rb index f1e96d22d64..7f480fe33c0 100644 --- a/lib/gitlab/template/gitlab_ci_yml.rb +++ b/lib/gitlab/template/gitlab_ci_yml.rb @@ -1,6 +1,11 @@ module Gitlab module Template class GitlabCiYml < BaseTemplate + def content + explanation = "# This file is a template, and might need editing before it works on your project." + [explanation, super].join("\n") + end + class << self def extension '.gitlab-ci.yml' diff --git a/lib/tasks/gitlab/update_templates.rake b/lib/tasks/gitlab/update_templates.rake index 2d3c7993445..4f76dad7286 100644 --- a/lib/tasks/gitlab/update_templates.rake +++ b/lib/tasks/gitlab/update_templates.rake @@ -27,7 +27,7 @@ namespace :gitlab do # - The LICENSE, because we have to # - The sub dirs so we can organise the file by category # - The templates themself - # - Dir.entires returns also the entries '.' and '..' + # - Dir.entries returns also the entries '.' and '..' def remove_unneeded_files(directory, regex) Dir.foreach(directory) do |file| FileUtils.rm_rf(File.join(directory, file)) unless file =~ regex -- cgit v1.2.1 From 35383f33acaae6b286c203005b0410388a3bcca0 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Mon, 20 Jun 2016 15:06:36 -0500 Subject: Add button to add .gitlab-ci.yml file --- app/views/projects/show.html.haml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index e9ca46a74bf..5f041aedfc0 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -57,6 +57,10 @@ %li.missing = link_to add_special_file_path(@project, file_name: 'CONTRIBUTING.md', commit_message: 'Add contribution guide') do Add Contribution guide + - unless @repository.gitlab_ci_yml + %li.missing + = link_to add_special_file_path(@project, file_name: '.gitlab-ci.yml') do + Set up CI - if @repository.commit .content-block.second-block.white -- cgit v1.2.1