ruby [git] - 发布结账钩子

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby [git] - 发布结账钩子相关的知识,希望对你有一定的参考价值。

https://github.com/wayneeseguin/rvm/issues/2347#issuecomment-28716030
#!/usr/bin/env ruby-rvm-env 1.9.3

require 'yaml'

# Get the "type" of checkout from the arguments Git passes to us.
# Possible values for this are "0" for a file-only checkout (which we dont' care about)
# or "1" for a full branch checkout (which we do).
checkout_type = ARGV[2]

if checkout_type == "1"
  # Get the name of the current branch and the absolute path to our git root. Trim whitespace.
  current_branch_name = `git rev-parse --abbrev-ref HEAD`.gsub(/\s+/, "")
  root_directory = `git rev-parse --show-toplevel`.gsub(/\s+/, "")

  # Convert the branch name to a symbol for hash lookups.
  branch = current_branch_name.to_sym

  # Find and update any config.yml files.
  Dir.glob("#{root_directory}/**/config.yml").each do |config_file|
    config = YAML.load_file(config_file)

    # Check to see if we've specified a known theme ID for this branch.
    if config.has_key?(branch)
      config[:theme_id] = config.fetch(branch)

      File.open(config_file, 'w') do |f|
        f.write config.to_yaml
      end
    end
  end
end

以上是关于ruby [git] - 发布结账钩子的主要内容,如果未能解决你的问题,请参考以下文章

GIT & Ruby:如何从 ruby​​ 脚本中取消设置 GIT_DIR 变量?

Ruby on Rails Paypal REST API 来宾结账

Elastic Beanstalk Ruby/Rails 需要安装 git,所以 bundle install 可以工作.. 但不是

Git可以使用独占结账吗?

Ruby 模块中的“基础”是啥?

成功结帐钩子后获取订单数据