#!/usr/bin/env ruby require 'rubygems' require 'gitscape' require "optparse" OVERVIEW = <<-EOS gitscape perform git-related promotions in a consistent manner. The following actions are supported. hotfix_start Creates a branch off live called hotfix/ hotfix_finish [] Merges the branch hotfix/ into live, the current release branch and master. If is omitted and you are already on a hotfix branch, it is used. release_start Branches master, incrementing the release number to create a new release branch, release/i. The release branch is forced to the qa branch. ** These actions update the origin server. ** release_finish After performing several validations, it merges the latest release branch into live and master. Tags are created that facilitate a rollback. ** These actions update the origin server. ** EOS # Parse option overrides. options = {} op = OptionParser.new do |op| op.banner = 'Usage: gitscape [action] [options]' op.separator('Options:') op.on '--[no-]trace', 'Verbose output for debugging' do |bool| options[:trace] = bool end op.on '-h', '--help', 'Show a list of actions' do puts OVERVIEW exit end op.on '-p', '--[no-]push', 'Whether or not to push changes to origin' do |bool| options[:push] = bool end op.on '-u', '--[no-]update-env', 'Whether to update environment branches when their development branch is updated' do |bool| options[:update_env] = bool end op.on '-e', '--env-depth=ENV', [:staging, :qa, :live], 'The level of environments to push changes to' do |depth| options[:env_depth] = depth end end op.parse!(ARGV) if ARGV.size < 1 puts OVERVIEW exit else command_name = ARGV[0] case command_name when "hotfix_start" hotfix_branch = ARGV[1] Gitscape::Base.new.hotfix_start hotfix_branch, options when "hotfix_finish" hotfix_branch = ARGV[1] Gitscape::Base.new.hotfix_finish hotfix_branch, options when "release_start" Gitscape::Base.new.release_start options when "release_finish" Gitscape::Base.new.release_finish options when "tag_cleanup" Gitscape::Base.new.tag_cleanup options else puts "Unknown command: #{command_name}" end end