git-message 0.2 → 0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 106c6947963bf80a07c5f9777080d3e903c1af07
4
- data.tar.gz: f244a986b4752a2429d6bf4d28693cedf3f2a247
3
+ metadata.gz: d1d6b3272857a159c64d8d434b5ac04f0e624a2e
4
+ data.tar.gz: 3f1c17418e370a3ee3ee3af5423b1a37f49a55db
5
5
  SHA512:
6
- metadata.gz: 530e23dd711d78377ba718e558e44070494e14631c864e18d9b6a82f8a7fd42f911d8c4e5a10c76c13388c79081b6ba36eb1ee57e65dd5a16603fdf27b5eb600
7
- data.tar.gz: 8fd2a4bdef29ead8a8f548c47898e8e6c16df8c6ac32d59b69763cd0a21e59db62bb002705144e281f7dcfe8d016f775931e333fe6a06a90414efb0e7dbd8ac1
6
+ metadata.gz: 3347d41a4202769224b55fd84879c161d7d436033ac2afed42aee931a90b4e8b957896f5f3fa8c7b04e0c59db177d6d489fbe57b8182cb68a6412334467726a3
7
+ data.tar.gz: a664e6699c584057aa09e06646df778031d47b9036145d0842a38ae4b18d840b76271b2c5dfb0b4f02d224cbae40bd00e4e7b90d545b2c6935221de444b63e15
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Git::Message
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/git/message`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ git-message is A plugin of Git for creating a Angular style commit message.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,17 +20,38 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ ###Angular style commit message
24
+
25
+ type[scope]:subject
26
+
27
+ ###Type
28
+
29
+ 1. feat
30
+ 2. fix
31
+ 3. docs
32
+ 4. style
33
+ 5. refactor
34
+ 6. test
35
+ 7. chore
36
+ 8. debug
37
+
38
+ ###Command
26
39
 
27
- ## Development
40
+ ```
41
+ git message --type 1 --scope hello.rb --message world
42
+ ```
43
+
44
+ or just use
28
45
 
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
46
+ ```
47
+ git message
48
+ ```
30
49
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
50
+ and then follow the note to enter the type,scope and subject
32
51
 
33
52
  ## Contributing
34
53
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/git-message. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
54
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Wingzki/git-message. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
55
 
37
56
 
38
57
  ## License
@@ -2,13 +2,14 @@
2
2
 
3
3
  require 'optparse'
4
4
  require 'colorize'
5
+ require 'commander/import'
5
6
 
6
7
  require 'git/message/version'
7
8
  require 'git/message'
8
9
 
9
- def getType (num)
10
+ def getType (type)
10
11
 
11
- case num
12
+ case type
12
13
  when '1'
13
14
  "feat"
14
15
  when '2'
@@ -26,107 +27,62 @@ def getType (num)
26
27
  when '8'
27
28
  "debug"
28
29
  else
29
- ''
30
+ type
30
31
  end
31
32
 
32
33
  end
33
34
 
34
- def runCommend (options)
35
+ never_trace!
36
+ default_command :commit
35
37
 
36
- commitMessage = "#{options[:type]}[#{options[:scope]}]:#{options[:subject]}".strip
38
+ program :name, 'git-message'
39
+ program :version, Git::Message::VERSION
40
+ program :description, 'A plugin of Git for creating a Angular style commit message.'
37
41
 
38
- puts ""
39
- puts "Commiting with message:#{commitMessage}".green
40
- puts ""
42
+ command :commit do |c|
41
43
 
42
- command = 'git commit -m ' + commitMessage
44
+ c.description = "Commit with Angular style commit message"
43
45
 
44
- system command
45
-
46
- end
47
-
48
- options = {}
49
- option_parser = OptionParser.new do |opts|
50
- # 这里是这个命令行工具的帮助信息
51
- opts.banner = 'here is help messages of git-message.'
52
-
53
- # 下面第一项是 Short option(没有可以直接在引号间留空),第二项是 Long option,第三项是对 Option 的描述
54
- opts.on('-v', '--version', 'version of git-message') do
55
- puts Git::Message::VERSION
56
- exit
57
- end
58
-
59
- opts.on('-t TYPE', '--type TYPE', 'Type of commit message') do |value|
60
- options[:type] = value
61
- end
62
-
63
- opts.on('-s SCOPE', '--scope SCOPE', 'Scope of commit message') do |value|
64
- options[:scope] = value
65
- end
66
-
67
- opts.on('-m MESSAGE', '--message MESSAGE', 'Subject of commit message') do |value|
68
- options[:subject] = value
69
- end
46
+ c.example "git message --type 1 --scope hello.rb --message world", ""
70
47
 
71
- # # Option 作为 flag,带argument,用于将argument作为数值解析,比如"name"信息
72
- # #下面的“value”就是用户使用时输入的argument
73
- # opts.on('-n NAME', '--name Name', 'Pass-in single name') do |value|
74
- # options[:name] = value
75
- # end
48
+ c.option '-t', '--type STRING', String, 'Type of commit message'
49
+ c.option '-s', '--scope STRING', String, 'Scope of commit message'
50
+ c.option '-m', '--message STRING', String, 'Subject of commit message'
76
51
 
77
- # # Option 作为 flag,带一组用逗号分割的arguments,用于将arguments作为数组解析
78
- # opts.on('-a A,B', '--array A,B', Array, 'List of arguments') do |value|
79
- # options[:array] = value
80
- # end
81
- end.parse!
52
+ c.action do |args, options|
82
53
 
83
- tempType = String.new("#{options[:type]}")
84
- tempScope = String.new("#{options[:scope]}")
85
- tempSubject = String.new("#{options[:subject]}")
54
+ tempType = getType options.type
55
+ tempScope = options.scope
56
+ tempSubject = options.message
86
57
 
87
- if tempType.length == 0
58
+ if !tempType
88
59
 
89
- Git::Message::showTypeOption
60
+ tempType = choose("Type of your commit?", :feat, :fix, :docs, :style, :refactor, :test, :chore, :debug)
90
61
 
91
- while (1)
62
+ end
92
63
 
93
- num = gets.chomp
94
- options[:type] = getType num
64
+ if !tempScope
95
65
 
96
- break
66
+ tempScope = ask("Scope of your commit: ")
97
67
 
98
- end
68
+ end
99
69
 
100
- end
101
-
102
- if tempScope.length == 0
103
-
104
- Git::Message::showScopeNote
105
-
106
- while (1)
107
-
108
- scope = gets.chomp
109
- options[:scope] = scope
70
+ if !tempSubject
110
71
 
111
- break
72
+ tempSubject = ask("Subject of your commit: ")
112
73
 
113
- end
74
+ end
114
75
 
115
- end
116
-
117
- if tempSubject.length == 0
118
-
119
- Git::Message::showMessage
76
+ commitMessage = "\"#{tempType}[#{tempScope}]:#{tempSubject}\""
120
77
 
121
- while (1)
78
+ puts ""
79
+ puts "Commiting with message:#{commitMessage}".green
80
+ puts ""
122
81
 
123
- subject = gets.chomp
124
- options[:subject] = subject
82
+ command = 'git commit -m ' + commitMessage
125
83
 
126
- break
84
+ system command
127
85
 
128
- end
86
+ end
129
87
 
130
88
  end
131
-
132
- runCommend options
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Wingzki"]
10
10
  spec.email = ["thewingofthesky@gmail.com"]
11
11
 
12
- spec.summary = %q{A plugin for git to creat a commit message}
13
- spec.description = %q{A plugin for git to creat a commit message}
12
+ spec.summary = %q{A plugin of Git for creating a Angular style commit message}
13
+ spec.description = %q{A plugin of Git for creating a Angular style commit message}
14
14
  spec.homepage = "https://github.com/Wingzki"
15
15
  spec.license = "MIT"
16
16
 
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.11"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_dependency "colorize", "~> 0.7.7"
25
+ spec.add_dependency "commander", "4.4.0"
25
26
  end
@@ -3,36 +3,5 @@ require "git/message/version"
3
3
  module Git
4
4
  module Message
5
5
 
6
- def Message.showTypeOption
7
-
8
- puts <<EOF
9
-
10
- 1 feat: 新功能(feature)
11
- 2 fix: 修补bug
12
- 3 docs: 文档(documentation)
13
- 4 style: 格式(不影响代码运行的变动)
14
- 5 refactor:重构(即不是新增功能,也不是修改bug的代码变动)
15
- 6 test: 增加测试
16
- 7 chore: 构建过程或辅助工具的变动
17
- 8 debug: 调试的变更(仅作调试使用)
18
-
19
- EOF
20
-
21
- print 'Enter the type number of your commit:'
22
-
23
- end
24
-
25
- def Message.showScopeNote
26
-
27
- print 'Enter the scope of your commit:'
28
-
29
- end
30
-
31
- def Message.showMessage
32
-
33
- print 'Enter the subject of your commit:'
34
-
35
- end
36
-
37
6
  end
38
7
  end
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  module Message
3
- VERSION = "0.2"
3
+ VERSION = "0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-message
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wingzki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-05 00:00:00.000000000 Z
11
+ date: 2016-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,21 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.7.7
55
- description: A plugin for git to creat a commit message
55
+ - !ruby/object:Gem::Dependency
56
+ name: commander
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 4.4.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 4.4.0
69
+ description: A plugin of Git for creating a Angular style commit message
56
70
  email:
57
71
  - thewingofthesky@gmail.com
58
72
  executables:
@@ -95,5 +109,5 @@ rubyforge_project:
95
109
  rubygems_version: 2.4.7
96
110
  signing_key:
97
111
  specification_version: 4
98
- summary: A plugin for git to creat a commit message
112
+ summary: A plugin of Git for creating a Angular style commit message
99
113
  test_files: []