summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 18:42:06 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 18:42:06 +0000
commit6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch)
tree78be5963ec075d80116a932011d695dd33910b4e /bin
parent1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff)
downloadgitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'bin')
-rwxr-xr-xbin/feature-flag46
1 files changed, 33 insertions, 13 deletions
diff --git a/bin/feature-flag b/bin/feature-flag
index 46d93a11ebd..ba86df9c06c 100755
--- a/bin/feature-flag
+++ b/bin/feature-flag
@@ -8,7 +8,7 @@
require 'optparse'
require 'yaml'
require 'fileutils'
-require 'cgi'
+require 'uri'
require_relative '../lib/feature/shared' unless defined?(Feature::Shared)
@@ -105,10 +105,11 @@ class FeatureFlagOptionParser
end
def read_group
+ $stdout.puts
$stdout.puts ">> Please specify the group introducing feature flag, like `group::apm`:"
loop do
- $stdout.print "\n?> "
+ $stdout.print "?> "
group = $stdin.gets.strip
group = nil if group.empty?
return group if group.nil? || group.start_with?('group::')
@@ -118,6 +119,10 @@ class FeatureFlagOptionParser
end
def read_type
+ # if there's only one type, do not ask, return
+ return TYPES.first.first if TYPES.one?
+
+ $stdout.puts
$stdout.puts ">> Please specify the type of your feature flag:"
$stdout.puts
TYPES.each do |type, data|
@@ -125,7 +130,7 @@ class FeatureFlagOptionParser
end
loop do
- $stdout.print "\n?> "
+ $stdout.print "?> "
type = $stdin.gets.strip.to_sym
return type if TYPES[type]
@@ -134,27 +139,41 @@ class FeatureFlagOptionParser
end
end
- def read_issue_url(options)
+ def read_introduced_by_url
+ $stdout.puts
+ $stdout.puts ">> If you have MR open, can you paste the URL here? (or enter to skip)"
+
+ loop do
+ $stdout.print "?> "
+ introduced_by_url = $stdin.gets.strip
+ introduced_by_url = nil if introduced_by_url.empty?
+ return introduced_by_url if introduced_by_url.nil? || introduced_by_url.start_with?('https://')
+
+ $stderr.puts "URL needs to start with https://"
+ end
+ end
+
+ def read_rollout_issue_url(options)
return unless TYPES.dig(options.type, :rollout_issue)
url = "https://gitlab.com/gitlab-org/gitlab/-/issues/new"
title = "[Feature flag] Rollout of `#{options.name}`"
- description = File.read('.gitlab/issue_templates/Feature Flag Roll Out.md')
- description.sub!(':feature_name', options.name)
- issue_new_url = url + "?" +
- "issue[title]=" + CGI.escape(title) + "&"
- # TODO: We should be able to pick `issueable_template`
- # + "issue[description]=" + CGI.escape(description)
+ params = {
+ 'issue[title]' => "[Feature flag] Rollout of `#{options.name}`",
+ 'issuable_template' => 'Feature Flag Roll Out',
+ }
+ issue_new_url = url + "?" + URI.encode_www_form(params)
+ $stdout.puts
$stdout.puts ">> Open this URL and fill the rest of details:"
$stdout.puts issue_new_url
$stdout.puts
- $stdout.puts ">> Paste URL here, or enter to skip:"
+ $stdout.puts ">> Paste URL of `rollout issue` here, or enter to skip:"
loop do
- $stdout.print "\n?> "
+ $stdout.print "?> "
created_url = $stdin.gets.strip
created_url = nil if created_url.empty?
return created_url if created_url.nil? || created_url.start_with?('https://')
@@ -182,7 +201,8 @@ class FeatureFlagCreator
# Read type from $stdin unless is already set
options.type ||= FeatureFlagOptionParser.read_type
options.group ||= FeatureFlagOptionParser.read_group
- options.rollout_issue_url ||= FeatureFlagOptionParser.read_issue_url(options)
+ options.introduced_by_url ||= FeatureFlagOptionParser.read_introduced_by_url
+ options.rollout_issue_url ||= FeatureFlagOptionParser.read_rollout_issue_url(options)
$stdout.puts "\e[32mcreate\e[0m #{file_path}"
$stdout.puts contents