Class: BBItools::GitSets

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-bb-PodAssistant/tools/git_sets.rb

Class Method Summary collapse

Class Method Details

.commit_msg_init(args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cocoapods-bb-PodAssistant/tools/git_sets.rb', line 5

def self.commit_msg_init(args)
    # folder_path = args[0]
    # if folder_path.nil?
    #     puts "传入的参数不能为空".red
    #     return
    # end
    # if !File::directory?(folder_path)
    #     puts "参数不是文件夹".red
    #     return
    # end
    puts "开始配置CommitLint,用于校验commit message的工具...".yellow
    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/feat\\n#bug\u4FEE\u590D      bugfix/fixbug/fix\\n#\u6027\u80FD\u4F18\u5316     perf\\n#\u4EE3\u7801\u91CD\u6784     refactor/review\\n#\u7EBF\u4E0A\u4FEE\u590D     hotfix\\n#\u53D1\u5E03\u7248\u672C     release\\n#\u6587\u6863\u53D8\u66F4     docs\\n#\u66F4\u65B0     update\\n#\u65B0\u589E     add\\n#\u6807\u7B7E     tag\\n#\u4EE3\u7801\u56DE\u9000     revert\\n#\u66F4\u65B0lock     lock''' >> `pwd`/.git/commit_msg\n    EOF\n    File.open('.git/hooks/pre-commit', 'w') do |f|\n        f.puts a\n    end\n    puts \"\u5199\u5165CommitLint\u89C4\u5219\"\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    puts \"\u66F4\u65B0\u6743\u9650\"\n    system('chmod a+x .git/hooks/pre-commit')\n    system('chmod a+x .git/hooks/commit-msg')\n    puts \"\u914D\u7F6E\u6210\u529F\uFF0C\u540E\u7EED\u8BF7\u76F4\u63A5\u4F7F\u7528git commit ,\u4E0D\u8981\u52A0 -m\".green\nend\n"