Sha256: 2f57746226c9a3d63f64ed53ad9a51066341c6644c7ab9643ab41d007abc407f

Contents?: true

Size: 1.91 KB

Versions: 1

Compression:

Stored size: 1.91 KB

Contents

#!/usr/bin/ruby

require 'falkorlib/common'
require 'git'

module FalkorLib

    class GitFlow < Git::Base

        @@config = {
            :master     => 'production',
            :develop    => 'master',
            :feature    => 'feature/',
            :release    => 'release/',
            :hotfix     => 'hotfix/',
            :support    => 'support/',
            :versiontag => "v",
        }


        def initialize(base = nil, options = {})
            # @logger = options[:logger] || Logger.new(STDOUT)
            options.each do |k,v|
                self.config_set(k, v) if @@config.has_key?(k.to_sym)
            end
            #puts @@config.inspect
        end

        # def self.method_missing(sym, *args, &block)
        #     @@config[sym.to_s]
        # end

        def self.global_config(opt)
            @@config[opt.to_sym]
        end

        def self.config_set(opt, value)
            @@config[opt.to_sym] = value
        end

        # initializes a git flow repository
        # options:
        #  :repository
        #  :index_file
        #
        def self.init(working_dir, opts = {})
	        super
	        g = Git.open(working_dir)

	        config = @@config
	        @@config.keys.each do |k| 
		        config[k.to_sym] = opts[k.to_sym] if opts.has_key?(k.to_sym)
	        end

            # Now update the local config for gitflow
            g.config('gitflow.branch.master',     config[:master])
            g.config('gitflow.branch.develop',    config[:develop])
            g.config('gitflow.prefix.feature',    config[:feature])
            g.config('gitflow.prefix.release',    config[:release])
            g.config('gitflow.prefix.hotfix',     config[:hotfix])
            g.config('gitflow.prefix.support',    config[:support])
            g.config('gitflow.prefix.versiontag', config[:versiontag])

	        g.lib.send('command', 'flow init -d')
        end




    end # End Falkorlib::GitFlow
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
falkorlib-0.1.0 lib/falkorlib/gitflow.rb