Class: Itools::GitSets

Inherits:
Object
  • Object
show all
Defined in:
lib/itools/git_sets.rb

Class Method Summary collapse

Class Method Details

.commit_msg_init(args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/itools/git_sets.rb', line 3

def self.commit_msg_init(args)
    puts "\033[32m开始配置...\033[0m"
    system('touch ./.git/commit_msg')
    system('git config commit.template "`pwd`/.git/commit_msg"')
    a = "#!/bin/sh\necho \"$(git symbolic-ref --short HEAD) subject\" > `pwd`/.git/commit_msg\necho \"\" >> `pwd`/.git/commit_msg\necho \"Cause:\" >> `pwd`/.git/commit_msg\necho \"Solution:\" >> `pwd`/.git/commit_msg\necho \"Releated Doc Address:\" >> `pwd`/.git/commit_msg\necho  '''\\n#TYPE\u7C7B\u578B\\n#\u65B0\u529F\u80FD       feature\\n#bug\u4FEE\u590D      bugfix\\n#\u6027\u80FD\u4F18\u5316     perf\\n#\u4EE3\u7801\u91CD\u6784     refactor\\n#\u7EBF\u4E0A\u4FEE\u590D     hotfix\\n#\u53D1\u5E03\u7248\u672C     release\\n#\u6587\u6863\u53D8\u66F4     docs''' >> `pwd`/.git/commit_msg\n    EOF\n    File.open('.git/hooks/pre-commit', 'w') do |f|\n        f.puts a\n    end\n    logo_path = File.join( File.dirname(__FILE__), 'temple-commit-msg.dat' )\n    content = File.read( logo_path )\n    File.open('.git/hooks/commit-msg', 'w') do |f|\n        f.puts content\n    end\n    system('chmod a+x .git/hooks/pre-commit')\n    system('chmod a+x .git/hooks/commit-msg')\n    puts \"\\033[32m\u914D\u7F6E\u6210\u529F\uFF0C\u540E\u7EED\u8BF7\u76F4\u63A5\u4F7F\u7528git commit ,\u4E0D\u8981\u52A0 -m\\033[0m\"\nend\n"