text 要点不要强迫推进掌握

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text 要点不要强迫推进掌握相关的知识,希望对你有一定的参考价值。

#!/usr/bin/env ruby

# Read this blog to know more about this script.
#
# http://blog.bigbinary.com/2013/09/19/do-not-allow-force-pusht-to-master.html

class PrePushHandler

  def handle
    reject if pushing_to_master? && forced_push?
  end

  private

  def pushing_to_master?
    current_branch == 'master'
  end

  def current_branch
    result = %x{git branch}.split("\n")
    if result.empty?
      feedback "It seems your app is not a git repository."
    else
      result.select { |b| b =~ /^\*/ }.first.split(" ").last.strip
    end
  end

  def reject
    messages = ["Your attempt to FORCE PUSH to MASTER has been rejected."]
    messages << "If you still want to FORCE PUSH then you need to ignore the pre_push git hook by executing following command."
    messages << "git push master --force --no-verify"
    feedback messages
  end

  def forced_push?
    ppid = Process.ppid
    cmd = "ps -ocommand= -p #{ppid}"
    output = `#{cmd}`
    output.match(/--force|-f/)
  end

  def feedback messages
    puts "*"*40
    [messages].flatten.each do |message|
      puts message
    end
    puts "*"*40

    exit 1
  end
end

PrePushHandler.new.handle

以上是关于text 要点不要强迫推进掌握的主要内容,如果未能解决你的问题,请参考以下文章

怎么样学习熟练win32 api?需要掌握哪些知识点、要点?

工程实践规模化推进要点分析

工程实践规模化推进要点分析

JVM 掌握要点

前端程序员面试套路,两大要点需掌握

linux 常用 掌握要点