Sha256: cecf2878e39e6360aaaa6aa8e717ada1b96f011854dd2f3d7e7c4834a3939c88

Contents?: true

Size: 1.03 KB

Versions: 11

Compression:

Stored size: 1.03 KB

Contents

require 'thor'
require 'gitx'
require 'gitx/cli/base_command'

module Gitx
  module Cli
    class BuildtagCommand < BaseCommand
      desc 'buildtag', 'create a tag for the current build and push it back to origin (supports Travis CI and Codeship)'
      method_option :branch, type: :string, aliases: '-b', desc: 'branch name for build tag'
      method_option :message, type: :string, aliases: '-m', desc: 'message to attach to the buildtag'
      def buildtag
        fail "Branch must be one of the supported taggable branches: #{config.taggable_branches}" unless config.taggable_branch?(branch_name)
        run_cmd "git tag #{git_tag} -a -m '#{label}'"
        run_cmd "git push origin #{git_tag}"
      end

      private

      def branch_name
        options[:branch] || current_branch.name
      end

      def label
        options[:message] || "[gitx] buildtag for #{branch_name}"
      end

      def git_tag
        timestamp = Time.now.utc.strftime '%Y-%m-%d-%H-%M-%S'
        "build-#{branch_name}-#{timestamp}"
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
gitx-2.21.3.ci.135.1 lib/gitx/cli/buildtag_command.rb
gitx-2.21.3 lib/gitx/cli/buildtag_command.rb
gitx-2.21.2.ci.134.1 lib/gitx/cli/buildtag_command.rb
gitx-2.21.2.ci.130.1 lib/gitx/cli/buildtag_command.rb
gitx-2.21.2 lib/gitx/cli/buildtag_command.rb
gitx-2.21.1.ci.125.1 lib/gitx/cli/buildtag_command.rb
gitx-2.21.1 lib/gitx/cli/buildtag_command.rb
gitx-2.21.0.ci.121.1 lib/gitx/cli/buildtag_command.rb
gitx-2.21.0 lib/gitx/cli/buildtag_command.rb
gitx-2.20.0 lib/gitx/cli/buildtag_command.rb
gitx-2.20.0.ci.117.1 lib/gitx/cli/buildtag_command.rb