Commit 81f2c482 authored by James Lopez's avatar James Lopez
Browse files

Merge branch 'rs-secpick' into 'master'

Add `--security-remote` flag to bin/secpick

See merge request gitlab-org/gitlab!21274
parents a8e3bb2d 9cf3e973
...@@ -11,8 +11,12 @@ using Rainbow ...@@ -11,8 +11,12 @@ using Rainbow
module Secpick module Secpick
BRANCH_PREFIX = 'security'.freeze BRANCH_PREFIX = 'security'.freeze
STABLE_SUFFIX = 'stable'.freeze STABLE_SUFFIX = 'stable'.freeze
DEFAULT_REMOTE = 'dev'.freeze DEFAULT_REMOTE = 'dev'.freeze
SECURITY_REMOTE = 'security'.freeze
NEW_MR_URL = 'https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/new'.freeze NEW_MR_URL = 'https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/new'.freeze
SECURITY_MR_URL = 'https://gitlab.com/gitlab-org/security/gitlab/merge_requests/new'.freeze
   
class SecurityFix class SecurityFix
def initialize def initialize
...@@ -20,7 +24,7 @@ module Secpick ...@@ -20,7 +24,7 @@ module Secpick
end end
   
def ee? def ee?
File.exist?('./ee/app/models/license.rb') File.exist?(File.expand_path('../ee/app/models/license.rb', __dir__))
end end
   
def dry_run? def dry_run?
...@@ -62,17 +66,30 @@ module Secpick ...@@ -62,17 +66,30 @@ module Secpick
end end
   
def new_mr_url def new_mr_url
if ee? if @options[:security_remote]
NEW_MR_URL.sub('gitlabhq', 'gitlab-ee') if ee?
SECURITY_MR_URL
else
SECURITY_MR_URL.sub('/gitlab/', '/gitlab-foss/')
end
else else
NEW_MR_URL if ee?
NEW_MR_URL.sub('gitlabhq', 'gitlab-ee')
else
NEW_MR_URL
end
end end
end end
   
def create! def create!
if dry_run? if dry_run?
puts git_commands.join("\n").green puts "\nGit commands:".blue
puts "\nMerge request params: ".blue puts git_commands.join("\n")
puts "\nMerge request URL:".blue
puts new_mr_url
puts "\nMerge request params:".blue
pp gitlab_params pp gitlab_params
else else
cmd = git_commands.join(' && ') cmd = git_commands.join(' && ')
...@@ -111,13 +128,27 @@ module Secpick ...@@ -111,13 +128,27 @@ module Secpick
options[:remote] = remote options[:remote] = remote
end end
   
opts.on('-d', '--dry-run', 'Only show Git commands, without calling them') do |remote| opts.on('--security-remote', 'Use the new Security group-based workflow on gitlab.com (note: mutually exclusive to --remote)') do
unless options[:remote].nil?
abort('Cannot use --security-remote with --remote')
end
options[:security_remote] = true
options[:remote] = SECURITY_REMOTE
end
opts.on('-d', '--dry-run', 'Only show Git commands, without calling them') do
options[:try] = true options[:try] = true
end end
   
opts.on('-h', '--help', 'Displays Help') do opts.on('-h', '--help', 'Displays Help') do
puts opts puts opts
   
puts
puts 'NOTE: If `--security-remote` is used, commands will default ' \
'to using a `security` remote, and merge requests will be created ' \
'on gitlab.com/gitlab-org/security/ rather than dev.gitlab.org.'
exit exit
end end
end end
...@@ -127,7 +158,7 @@ module Secpick ...@@ -127,7 +158,7 @@ module Secpick
options[:branch] ||= `git rev-parse --abbrev-ref HEAD` options[:branch] ||= `git rev-parse --abbrev-ref HEAD`
options[:remote] ||= DEFAULT_REMOTE options[:remote] ||= DEFAULT_REMOTE
   
abort("Missing options. Use #{$0} --help to see the list of options available".red) if options.values.include?(nil) abort("Missing options. Use #{$0} --help to see the list of options available".red) if options.value?(nil)
abort("Wrong version format #{options[:version].bold}".red) unless options[:version] =~ /\A\d*\-\d*\Z/ abort("Wrong version format #{options[:version].bold}".red) unless options[:version] =~ /\A\d*\-\d*\Z/
end end
end end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment