Commit 5db03926 authored by John Skarbek's avatar John Skarbek Committed by John Skarbek

this is a start...

* grabs all branches with `auto-deploy` in the name
* Finds the version associated with it
* next up is to figure out what needs to be cherry picked
  * i think i need to learn how to write tests to do this without
  breaking real things though
parent 0026c655
# frozen_string_literal: true
require 'pry'
require_relative 'lib/release_tools'
require_relative 'lib/release_tools/support/tasks_helper'
......@@ -12,6 +13,43 @@ namespace :auto_deploy do
.new(ReleaseTools::AutoDeploy::Naming.branch)
.create_branches!
end
desc 'Pick commits into the auto deploy branches'
task :pick do
versions = {}
count = 0
ReleaseTools::GitlabClient.branches(ReleaseTools::Project::GitlabEe.path).auto_paginate.each do |branch|
if branch.name =~ /^(\d+-\d+)-auto-deploy.*$/
#binding.pry
# convert the version to version used for picking
branch_name = branch.name
version = branch.name.match(/^(\d+-\d+)-auto-deploy.*$/)[1].gsub('-', '.')
versions.merge!(branch_name => version)
count += 1
end
end
puts count
puts versions.count
versions.each do |branch_name, version|
icon = ->(result) { result.success? ? "✓" : "✗" }
version = ReleaseTools::Version.new(version).to_ee
puts "--> Picking for #{version}..."
results = ReleaseTools::CherryPick::Service
.new(ReleaseTools::Project::GitlabEe, version, branch_name)
.dry_run
binding.pry
results.each do |result|
$stdout.puts " #{icon.call(result)} #{result.url}"
end
end
# check for valid pick tag that contains version
#versions.each do |version|
#end
# perform pick
end
end
desc "Sync master branch in remotes"
......
......@@ -12,5 +12,9 @@ module ReleaseTools
def create(ref:)
GitlabClient.create_branch(name, ref, project)
end
def get
GitLabClient.branches(@project, {})
end
end
end
......@@ -20,20 +20,31 @@ module ReleaseTools
attr_reader :project
attr_reader :version
def initialize(project, version)
def initialize(project, version, pick_branch = nil)
@project = project
@version = version
assert_version!
@prep_mr = PreparationMergeRequest.new(version: version)
if pick_branch.nil?
@prep_mr = PreparationMergeRequest.new(version: version)
assert_prep_mr!
assert_prep_mr!
@prep_branch = @prep_mr.preparation_branch_name
else
@prep_branch = pick_branch
end
@prep_branch = @prep_mr.preparation_branch_name
@results = []
end
def dry_run
return [] unless pickable_mrs.any?
pickable_mrs.auto_paginate
end
def execute
return [] unless pickable_mrs.any?
......
......@@ -9,7 +9,11 @@ module ReleaseTools
class << self
extend Forwardable
def_delegator :client, :branches
def_delegator :client, :commits
def_delegator :client, :labels
def_delegator :client, :pipelines
def_delegator :client, :pipeline_jobs
def_delegator :client, :file_contents
def_delegator :client, :job_play
......
Markdown is supported
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