summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 18:25:58 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 18:25:58 +0000
commita5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch)
treefb69158581673816a8cd895f9d352dcb3c678b1e /bin
parentd16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff)
downloadgitlab-ce-a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4.tar.gz
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'bin')
-rwxr-xr-xbin/changelog282
-rwxr-xr-xbin/pkgr_before_precompile.sh20
-rwxr-xr-xbin/web61
-rwxr-xr-xbin/web_puma63
-rwxr-xr-xbin/web_unicorn59
5 files changed, 52 insertions, 433 deletions
diff --git a/bin/changelog b/bin/changelog
deleted file mode 100755
index e796b1df600..00000000000
--- a/bin/changelog
+++ /dev/null
@@ -1,282 +0,0 @@
-#!/usr/bin/env ruby
-#
-# Generate a changelog entry file in the correct location.
-#
-# Automatically stages the file and amends the previous commit if the `--amend`
-# argument is used.
-
-require 'optparse'
-require 'yaml'
-
-INVALID_TYPE = -1
-
-module ChangelogHelpers
- Abort = Class.new(StandardError)
- Done = Class.new(StandardError)
-
- MAX_FILENAME_LENGTH = 99 # GNU tar has a 99 character limit
-
- def capture_stdout(cmd)
- output = IO.popen(cmd, &:read)
- fail_with "command failed: #{cmd.join(' ')}" unless $?.success?
- output
- end
-
- def fail_with(message)
- raise Abort, "\e[31merror\e[0m #{message}"
- end
-end
-
-class ChangelogOptionParser
- extend ChangelogHelpers
-
- Options = Struct.new(
- :amend,
- :author,
- :dry_run,
- :force,
- :merge_request,
- :title,
- :type,
- :ee
- )
-
- Type = Struct.new(:name, :description)
- TYPES = [
- Type.new('added', 'New feature'),
- Type.new('fixed', 'Bug fix'),
- Type.new('changed', 'Feature change'),
- Type.new('deprecated', 'New deprecation'),
- Type.new('removed', 'Feature removal'),
- Type.new('security', 'Security fix'),
- Type.new('performance', 'Performance improvement'),
- Type.new('other', 'Other')
- ].freeze
- TYPES_OFFSET = 1
-
- class << self
- def parse(argv)
- options = Options.new
-
- parser = OptionParser.new do |opts|
- opts.banner = "Usage: #{__FILE__} [options] [title]\n\n"
-
- # Note: We do not provide a shorthand for this in order to match the `git
- # commit` interface
- opts.on('--amend', 'Amend the previous commit') do |value|
- options.amend = value
- end
-
- opts.on('-f', '--force', 'Overwrite an existing entry') do |value|
- options.force = value
- end
-
- opts.on('-m', '--merge-request [integer]', Integer, 'Merge request ID') do |value|
- options.merge_request = value
- end
-
- opts.on('-n', '--dry-run', "Don't actually write anything, just print") do |value|
- options.dry_run = value
- end
-
- opts.on('-u', '--git-username', 'Use Git user.name configuration as the author') do |value|
- options.author = git_user_name if value
- end
-
- opts.on('-t', '--type [string]', String, "The category of the change, valid options are: #{TYPES.map(&:name).join(', ')}") do |value|
- options.type = parse_type(value)
- end
-
- opts.on('-e', '--ee', 'Generate a changelog entry for GitLab EE') do |value|
- options.ee = value
- end
-
- opts.on('-h', '--help', 'Print help message') do
- $stdout.puts opts
- raise Done.new
- end
- end
-
- parser.parse!(argv)
-
- # Title is everything that remains, but let's clean it up a bit
- options.title = argv.join(' ').strip.squeeze(' ').tr("\r\n", '')
-
- options
- end
-
- def read_type
- read_type_message
-
- type = TYPES[$stdin.getc.to_i - TYPES_OFFSET]
- assert_valid_type!(type)
-
- type.name
- end
-
- private
-
- def parse_type(name)
- type_found = TYPES.find do |type|
- type.name == name
- end
- type_found ? type_found.name : INVALID_TYPE
- end
-
- def read_type_message
- $stdout.puts "\n>> Please specify the index for the category of your change:"
- TYPES.each_with_index do |type, index|
- $stdout.puts "#{index + TYPES_OFFSET}. #{type.description}"
- end
- $stdout.print "\n?> "
- end
-
- def assert_valid_type!(type)
- unless type
- raise Abort, "Invalid category index, please select an index between 1 and #{TYPES.length}"
- end
- end
-
- def git_user_name
- capture_stdout(%w[git config user.name]).strip
- end
- end
-end
-
-class ChangelogEntry
- include ChangelogHelpers
-
- attr_reader :options
-
- def initialize(options)
- @options = options
- end
-
- def execute
- assert_feature_branch!
- assert_title! unless editor
- assert_new_file!
-
- # Read type from $stdin unless is already set
- options.type ||= ChangelogOptionParser.read_type
- assert_valid_type!
-
- $stdout.puts "\e[32mcreate\e[0m #{file_path}"
- $stdout.puts contents
-
- unless options.dry_run
- write
- amend_commit if options.amend
- end
-
- if editor
- system("#{editor} '#{file_path}'")
- end
- end
-
- private
-
- def contents
- yaml_content = YAML.dump(
- 'title' => title,
- 'merge_request' => options.merge_request,
- 'author' => options.author,
- 'type' => options.type
- )
- remove_trailing_whitespace(yaml_content)
- end
-
- def write
- File.write(file_path, contents)
- end
-
- def editor
- ENV['EDITOR']
- end
-
- def amend_commit
- fail_with "git add failed" unless system(*%W[git add #{file_path}])
-
- Kernel.exec(*%w[git commit --amend])
- end
-
- def assert_feature_branch!
- return unless branch_name == 'master'
-
- fail_with "Create a branch first!"
- end
-
- def assert_new_file!
- return unless File.exist?(file_path)
- return if options.force
-
- fail_with "#{file_path} already exists! Use `--force` to overwrite."
- end
-
- def assert_title!
- return if options.title.length > 0 || options.amend
-
- fail_with "Provide a title for the changelog entry or use `--amend`" \
- " to use the title from the previous commit."
- end
-
- def assert_valid_type!
- return unless options.type && options.type == INVALID_TYPE
-
- fail_with 'Invalid category given!'
- end
-
- def title
- if options.title.empty?
- last_commit_subject
- else
- options.title
- end
- end
-
- def last_commit_subject
- capture_stdout(%w[git log --format=%s -1]).strip
- end
-
- def file_path
- base_path = File.join(
- unreleased_path,
- branch_name.gsub(/[^\w-]/, '-'))
-
- # Add padding for .yml extension
- base_path[0..MAX_FILENAME_LENGTH - 5] + '.yml'
- end
-
- def unreleased_path
- path = File.join('changelogs', 'unreleased')
- path = File.join('ee', path) if ee?
-
- path
- end
-
- def ee?
- options.ee
- end
-
- def branch_name
- @branch_name ||= capture_stdout(%w[git symbolic-ref --short HEAD]).strip
- end
-
- def remove_trailing_whitespace(yaml_content)
- yaml_content.gsub(/ +$/, '')
- end
-end
-
-if $0 == __FILE__
- begin
- options = ChangelogOptionParser.parse(ARGV)
- ChangelogEntry.new(options).execute
- rescue ChangelogHelpers::Abort => ex
- $stderr.puts ex.message
- exit 1
- rescue ChangelogHelpers::Done
- exit
- end
-end
-
-# vim: ft=ruby
diff --git a/bin/pkgr_before_precompile.sh b/bin/pkgr_before_precompile.sh
deleted file mode 100755
index 54ff32c711b..00000000000
--- a/bin/pkgr_before_precompile.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-
-set -e
-
-for file in config/*.yml.example; do
- cp ${file} config/$(basename ${file} .example)
-done
-
-# Allow to override the GitLab URL from an environment variable, as this will avoid having to change the configuration file for simple deployments.
-config=$(echo '<% gitlab_url = URI(ENV["GITLAB_URL"] || "http://localhost:80") %>' | cat - config/gitlab.yml)
-echo "$config" > config/gitlab.yml
-sed -i "s/host: localhost/host: <%= gitlab_url.host %>/" config/gitlab.yml
-sed -i "s/port: 80/port: <%= gitlab_url.port %>/" config/gitlab.yml
-sed -i "s/https: false/https: <%= gitlab_url.scheme == 'https' %>/" config/gitlab.yml
-
-# No need for config file. Will be taken care of by REDIS_URL env variable
-rm config/resque.yml
-
-# Set default unicorn.rb file
-echo "" > config/unicorn.rb
diff --git a/bin/web b/bin/web
index b714ad1e1bb..c1ab4718f0d 100755
--- a/bin/web
+++ b/bin/web
@@ -3,18 +3,61 @@
set -e
cd $(dirname $0)/..
+app_root=$(pwd)
-case "$USE_WEB_SERVER" in
- puma|"") # and the "" defines default
- exec bin/web_puma "$@"
- ;;
+puma_pidfile="$app_root/tmp/pids/puma.pid"
+puma_config="$app_root/config/puma.rb"
- unicorn)
- exec bin/web_unicorn "$@"
- ;;
+spawn_puma()
+{
+ exec bundle exec puma --config "${puma_config}" --environment "$RAILS_ENV" "$@"
+}
- *)
- echo "Unkown web server used by USE_WEB_SERVER: $USE_WEB_SERVER."
+get_puma_pid()
+{
+ pid=$(cat "${puma_pidfile}")
+ if [ -z "$pid" ] ; then
+ echo "Could not find a PID in $puma_pidfile"
exit 1
+ fi
+ echo "${pid}"
+}
+
+start()
+{
+ spawn_puma &
+}
+
+start_foreground()
+{
+ spawn_puma
+}
+
+stop()
+{
+ get_puma_pid
+ kill -INT "$(get_puma_pid)"
+}
+
+reload()
+{
+ kill -USR2 "$(get_puma_pid)"
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ start_foreground)
+ start_foreground
+ ;;
+ stop)
+ stop
+ ;;
+ reload)
+ reload
+ ;;
+ *)
+ echo "Usage: RAILS_ENV=your_env $0 {start|stop|reload}"
;;
esac
diff --git a/bin/web_puma b/bin/web_puma
deleted file mode 100755
index c1ab4718f0d..00000000000
--- a/bin/web_puma
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/bin/sh
-
-set -e
-
-cd $(dirname $0)/..
-app_root=$(pwd)
-
-puma_pidfile="$app_root/tmp/pids/puma.pid"
-puma_config="$app_root/config/puma.rb"
-
-spawn_puma()
-{
- exec bundle exec puma --config "${puma_config}" --environment "$RAILS_ENV" "$@"
-}
-
-get_puma_pid()
-{
- pid=$(cat "${puma_pidfile}")
- if [ -z "$pid" ] ; then
- echo "Could not find a PID in $puma_pidfile"
- exit 1
- fi
- echo "${pid}"
-}
-
-start()
-{
- spawn_puma &
-}
-
-start_foreground()
-{
- spawn_puma
-}
-
-stop()
-{
- get_puma_pid
- kill -INT "$(get_puma_pid)"
-}
-
-reload()
-{
- kill -USR2 "$(get_puma_pid)"
-}
-
-case "$1" in
- start)
- start
- ;;
- start_foreground)
- start_foreground
- ;;
- stop)
- stop
- ;;
- reload)
- reload
- ;;
- *)
- echo "Usage: RAILS_ENV=your_env $0 {start|stop|reload}"
- ;;
-esac
diff --git a/bin/web_unicorn b/bin/web_unicorn
deleted file mode 100755
index 5fa15a8324b..00000000000
--- a/bin/web_unicorn
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/sh
-
-cd $(dirname $0)/.. || exit 1
-app_root=$(pwd)
-
-unicorn_pidfile="$app_root/tmp/pids/unicorn.pid"
-unicorn_config="$app_root/config/unicorn.rb"
-unicorn_cmd="bundle exec unicorn_rails -c $unicorn_config -E $RAILS_ENV"
-
-get_unicorn_pid()
-{
- local pid
- pid=$(cat $unicorn_pidfile)
- if [ -z "$pid" ] ; then
- echo "Could not find a PID in $unicorn_pidfile"
- exit 1
- fi
- unicorn_pid=$pid
-}
-
-start()
-{
- exec $unicorn_cmd -D
-}
-
-start_foreground()
-{
- exec $unicorn_cmd
-}
-
-stop()
-{
- get_unicorn_pid
- kill -QUIT $unicorn_pid
-}
-
-reload()
-{
- get_unicorn_pid
- kill -USR2 $unicorn_pid
-}
-
-case "$1" in
- start)
- start
- ;;
- start_foreground)
- start_foreground
- ;;
- stop)
- stop
- ;;
- reload)
- reload
- ;;
- *)
- echo "Usage: RAILS_ENV=your_env $0 {start|stop|reload}"
- ;;
-esac