git-sprint 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: 2dd2230df6b74b0d1f31033e4df5d9726e712f183b53b779eedbc1a79da163a3
4
- data.tar.gz: 264255bac7c49b58c0c780186f310b85b53dc44f5e604ffda8d9fe9de1341e92
3
+ metadata.gz: 6c0faf2c2b2854f0034e876fbcf8189ad0897a70996393befaa996be29d13d70
4
+ data.tar.gz: ffe1b781bceb797b547036ee3f653f8c9961b42160f41d98aa791cb7c3e5fe19
5
5
  SHA512:
6
- metadata.gz: 67e6da305269a31f368320017cfc2012e1873a8d8b12edcafd510e2ee8441e22e84f5c8461f4321d41efe82fba225f5266ce578324dd10082509037ed0af0476
7
- data.tar.gz: 6c7fa6eb6cb6e92a25b9c9246aaef2e55556a50c87d1194d21d500a6e2ca74b67da6f99419b6d953fdf59116175bcf10629772210cbd6215baf6343bec7b9284
6
+ metadata.gz: 8037516cc7fc0d2ab598f4c461521745f53f50ee9083ac4d37a37ad208f74fe550ea29a87229da7f328d5c4a7021acb218371429eb637c8b889c686c048979e8
7
+ data.tar.gz: 49947b6edfddb026eeec5a75c0ea7abd221f73913d207415ff85bb515b3ce6efcd312f92798a682eae8ed2ce4bb75886a5c0fe8e2a5b1331a617231112bcea95
@@ -3,55 +3,33 @@ name: build
3
3
  on: [push]
4
4
 
5
5
  jobs:
6
- Ubuntu:
7
- name: Ubuntu
6
+ ci:
7
+ name: build
8
8
  runs-on: ubuntu-latest
9
+ strategy:
10
+ matrix:
11
+ ruby: [ '2.4.x', '2.5.x', '2.6.x']
12
+
9
13
  steps:
10
14
  - uses: actions/checkout@v1
11
15
 
12
- - name: Set up Ruby 2.6
16
+ - name: set up ruby
13
17
  uses: actions/setup-ruby@v1
14
18
  with:
15
- ruby-version: 2.6.x
19
+ ruby-version: ${{ matrix.ruby }}
16
20
 
17
- - name: Build and test with Rake
21
+ - name: setup bundler
18
22
  run: |
19
23
  gem install bundler
24
+
25
+ - name: bundle install
26
+ run: |
20
27
  bundle install --jobs 4 --retry 3
21
- bundle exec rake
22
-
23
- # macOS:
24
- # name: macOS
25
- # runs-on: macos-latest
26
- # steps:
27
- # - uses: actions/checkout@v1
28
-
29
- # - name: Set up Ruby 2.6
30
- # uses: actions/setup-ruby@v1
31
- # with:
32
- # ruby-version: 2.6.x
33
-
34
- # - name: Build and test with Rake
35
- # run: |
36
- # gem uninstall bundler
37
- # sudo rm -f /Users/runner/hostedtoolcache/Ruby/2.6.3/x64/bin/bundle
38
- # gem install bundler -v '2.0.2'
39
- # bundle install --jobs 4 --retry 3
40
- # bundle exec rake
41
-
42
- # Windows:
43
- # name: windows
44
- # runs-on: windows-latest
45
- # steps:
46
- # - uses: actions/checkout@v1
47
-
48
- # - name: Set up Ruby 2.6
49
- # uses: actions/setup-ruby@v1
50
- # with:
51
- # ruby-version: 2.6.x
52
-
53
- # - name: Build and test with Rake
54
- # run: |
55
- # gem install bundler
56
- # bundle install --jobs 4 --retry 3
57
- # bundle exec rake test
28
+
29
+ - name: test
30
+ run: |
31
+ bundle exec ./bin/test
32
+
33
+ - name: lint
34
+ run: |
35
+ bundle exec ./bin/lint
@@ -0,0 +1,39 @@
1
+ ---
2
+ # rubocop config
3
+ #
4
+ # ```
5
+ # gem install rubocop
6
+ # ```
7
+
8
+ AllCops:
9
+ TargetRubyVersion: 2.4
10
+
11
+ inherit_from:
12
+ - https://raw.githubusercontent.com/jethrodaniel/dotfiles/master/home/.config/rubocop/config.yml
13
+
14
+ # The executable has to be named `git-xxx` in order to be a git plugin.
15
+ #
16
+ # Error: The name of this source file (git-sprint.rb) should use snake_case.
17
+ Naming/FileName:
18
+ Exclude:
19
+ - 'lib/git-sprint.rb'
20
+
21
+ # Specs, man
22
+ Metrics/BlockLength:
23
+ Exclude:
24
+ - 'spec/git-sprint/cli_spec.rb'
25
+ - 'lib/git-sprint/cli.rb' # no_commands { }
26
+ - 'git-sprint.gemspec'
27
+
28
+ # Logging, etc
29
+ Metrics/AbcSize:
30
+ Max: 30
31
+
32
+ # Logging, options, etc. The default of 7 is a bit low
33
+ Metrics/PerceivedComplexity:
34
+ Max: 10
35
+
36
+ # lolcat modifies strings
37
+ # @todo make a pr to fix this
38
+ Style/FrozenStringLiteralComment:
39
+ EnforcedStyle: never
data/README.md CHANGED
@@ -21,6 +21,8 @@ git sprint help
21
21
 
22
22
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
23
23
 
24
+ To run the linter, run `bin/lint`.
25
+
24
26
  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).
25
27
 
26
28
 
@@ -28,9 +30,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
28
30
 
29
31
  Bug reports and pull requests are welcome on GitHub at https://github.com/jethrodaniel/git-sprint.
30
32
 
31
- ### Todo
32
-
33
- See the github project.
33
+ - issues - https://github.com/jethrodaniel/git-sprint/issues
34
+ - pull requests - https://github.com/jethrodaniel/git-sprint/pulls
35
+ - kanban - https://github.com/jethrodaniel/git-sprint/projects/1
34
36
 
35
37
  ## License
36
38
 
@@ -1,6 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
2
  require 'bundler/setup'
5
3
  require 'git-sprint'
6
4
 
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ puts '== running rubocop =='
3
+ system 'bundle exec rubocop'
data/bin/setup CHANGED
@@ -1,6 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
2
  APP_ROOT = File.expand_path '..', __dir__
5
3
 
6
4
  def system! *args
data/bin/test CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
2
  puts '== Installing gem locally =='
4
3
  system 'bundle exec rake install'
5
4
 
@@ -1,6 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
2
  require 'pathname'
5
3
  lib = Pathname.new(__dir__) + '..' + 'lib'
6
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git-sprint (0.1.1)
4
+ git-sprint (0.1.2)
5
5
  colorize (~> 0.8.1)
6
6
  git (~> 1.5)
7
7
  lolcat (~> 100.0)
@@ -16,7 +16,6 @@ GEM
16
16
  byebug (11.0.1)
17
17
  coderay (1.1.2)
18
18
  colorize (0.8.1)
19
- diff-lcs (1.3)
20
19
  git (1.5.0)
21
20
  jaro_winkler (1.5.3)
22
21
  lolcat (100.0.0)
@@ -50,19 +49,6 @@ GEM
50
49
  psych (3.1.0)
51
50
  rainbow (3.0.0)
52
51
  rake (12.3.3)
53
- rspec (3.8.0)
54
- rspec-core (~> 3.8.0)
55
- rspec-expectations (~> 3.8.0)
56
- rspec-mocks (~> 3.8.0)
57
- rspec-core (3.8.2)
58
- rspec-support (~> 3.8.0)
59
- rspec-expectations (3.8.4)
60
- diff-lcs (>= 1.2.0, < 2.0)
61
- rspec-support (~> 3.8.0)
62
- rspec-mocks (3.8.1)
63
- diff-lcs (>= 1.2.0, < 2.0)
64
- rspec-support (~> 3.8.0)
65
- rspec-support (3.8.2)
66
52
  rubocop (0.65.0)
67
53
  jaro_winkler (~> 1.5.1)
68
54
  parallel (~> 1.10)
@@ -90,7 +76,6 @@ DEPENDENCIES
90
76
  pry (~> 0.12.2)
91
77
  pry-byebug (~> 3.7)
92
78
  rake (~> 12.3.2)
93
- rspec (~> 3.8)
94
79
  rubocop (~> 0.65.0)
95
80
  yard (~> 0.9.18)
96
81
 
data/gems.rb CHANGED
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  source 'https://rubygems.org'
4
2
 
5
3
  gemspec
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  lib = File.expand_path 'lib', __dir__
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
  require 'git-sprint/version'
@@ -14,6 +12,8 @@ Gem::Specification.new do |spec|
14
12
  spec.homepage = 'https://github.com/jethrodaniel/git-sprint'
15
13
  spec.license = 'MIT'
16
14
 
15
+ spec.required_ruby_version = '~> 2.4'
16
+
17
17
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the
18
18
  # 'allowed_push_host' to allow pushing to a single host or delete this
19
19
  # section to allow pushing to any host.
@@ -38,25 +38,39 @@ Gem::Specification.new do |spec|
38
38
  spec.bindir = 'exe'
39
39
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename f }
40
40
  spec.require_paths = ['lib']
41
+
41
42
  {
43
+ # debugger
42
44
  'pry' => '~> 0.12.2',
43
45
  'pry-byebug' => '~> 3.7',
46
+
47
+ # build tasks
44
48
  'bundler' => '~> 2.0',
45
49
  'rake' => '~> 12.3.2',
50
+
51
+ # tests
46
52
  'minitest' => '~> 5.11',
47
53
  'minitest-spec-context' => '~> 0.0.4',
48
54
  'minitest-reporters' => '~> 1.3',
49
- 'rspec' => '~> 3.8',
50
55
  'm' => '~> 1.5',
56
+
57
+ # docs
51
58
  'yard' => '~> 0.9.18',
59
+
60
+ # linting
52
61
  'rubocop' => '~> 0.65.0'
53
62
  }.each do |gem, version|
54
63
  spec.add_development_dependency gem, version
55
64
  end
56
65
 
57
66
  {
67
+ # cli
58
68
  'thor' => '~> 0.20.3',
69
+
70
+ # git operations, instead of `git ...`
59
71
  'git' => '~> 1.5',
72
+
73
+ # colored output
60
74
  'colorize' => '~> 0.8.1',
61
75
  'lolcat' => '~> 100.0'
62
76
  }.each do |gem, version|
@@ -1,8 +1,13 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'git-sprint/version'
4
2
  require 'git-sprint/logger'
5
3
 
4
+ require 'stringio'
5
+ require 'tempfile'
6
+
7
+ require 'git'
8
+ require 'thor'
9
+ require 'lolcat'
10
+
6
11
  module GitSprint
7
12
  def self.testing?
8
13
  ENV['GIT_SPRINT_TESTING'] == 'true'
@@ -1,19 +1,9 @@
1
- # frozen_string_literal: false
2
-
3
- # ffrozen_string_literal: true
4
-
5
1
  # The actual CLI part of this app.
6
2
  #
7
3
  # It's a standard thor CLI, and is called in the executable.
8
4
 
9
5
  require 'git-sprint'
10
6
 
11
- require 'stringio'
12
-
13
- require 'git'
14
- require 'thor'
15
- require 'lolcat'
16
-
17
7
  class String
18
8
  include GitSprint::CaptureOutput
19
9
 
@@ -31,155 +21,60 @@ module GitSprint
31
21
  #
32
22
  # @todo: use config for colors. `git.config.has_key? 'sprint.colors.branch'`
33
23
  class CLI < Thor
24
+ include GitSprintLogger
34
25
  include GitSprint::CaptureOutput
35
26
 
36
- # Exit non-zero when no command is found of something was required, etc.
27
+ # Exit non-zero when a command is missing a required argument, etc.
37
28
  def self.exit_on_failure?
38
29
  true
39
30
  end
40
31
 
41
- # Set debug level, --debug=N
32
+ # Set debug level
42
33
  class_option :debug,
43
34
  type: :string,
44
- banner: 'INFO (or WARN, DEBUG, ERROR, etc)',
35
+ banner: 'WARN (or DEBUG, INFO, ERROR, FATAL, UNKNOWN)',
45
36
  aliases: %w[-d]
46
37
 
47
38
  # Enable or disable color output
48
- class_option :color, type: :boolean, aliases: %w[-c --color]
49
-
50
- map %w[-v -V] => :version
51
- desc :version, 'show the version'
52
- def version
53
- version = GitSprint::VERSION
54
- if options[:color]
55
- say "git sprint version #{version.light_green}"
56
- else
57
- say "git sprint version #{version}"
58
- end
59
- end
60
-
61
- # Get help for a command.
62
- #
63
- # This command is generated by thor, so we just add a message to the start
64
- # when `git sprint` or `git sprint help` is called.
65
- #
66
- # @param cmd [String] The command to get help on
67
- # @param args [Array<String>] Additional command arguments
68
- def help cmd = nil, *args
69
- handle_debug_option!
70
- log.debug { 'Running `help` command...' }
71
-
72
- banner = <<~MSG
73
- Name:
74
- git sprint
75
-
76
- Summary:
77
- a git plugin for sprint related commands
78
-
79
- Install and start using like so
80
-
81
- gem install git-sprint && git sprint help
82
-
83
- See https://github.com/jethrodaniel/git-sprint
84
- MSG
39
+ class_option :color,
40
+ type: :boolean,
41
+ aliases: %w[-c --color],
42
+ banner: 'false (default, respects NO_COLOR)'
85
43
 
86
- usage = capture_std_out { super }
87
-
88
- if cmd.nil? # print banner
89
- if options[:color]
90
- say "#{banner}\n#{usage}".rainbow
91
- else
92
- say "#{banner}\n#{usage}"
93
- end
94
- else
95
- say usage unless options[:color]
96
- end
97
-
98
- log.debug { 'Finished `help` command.' }
99
- end
100
-
101
- desc :list, 'list all sprint branches'
102
- def list
103
- handle_debug_option!
104
- log.debug { 'Running `list` command...' }
105
-
106
- sprint_branches = git.branches
107
- .local
108
- .map(&:name)
109
- .select { |b| b.include? 'sprint' }
110
-
111
- die 'no sprint branches!' if sprint_branches.empty?
112
-
113
- msg = 'sprint branches:'
114
- say options[:color] ? msg.light_magenta : msg
115
-
116
- sprint_branches.each do |branch|
117
- say format_branch(branch: branch, color: :green)
118
- end
119
-
120
- log.debug { 'Finished `list` command...' }
121
- end
122
-
123
- desc :start, 'start a new sprint'
124
- def start
125
- handle_debug_option!
126
- set_sprint_vars!
127
-
128
- log.debug { 'Running `start` command...' }
129
-
130
- git.branch(@dev_branch).create
131
- git.branch(@branch).create
132
-
133
- msg = 'created new branches'
134
- say <<~MSG
135
- #{options[:color] ? msg.light_magenta : msg}
136
- #{format_branch branch: @branch, color: :green}
137
- #{format_branch branch: @dev_branch, color: :green}
138
- MSG
139
-
140
- log.debug { 'Finished `start` command...' }
141
- rescue Git::GitExecuteError => e
142
- die "[Error] #{e.class}\n#{e.message}"
143
- end
144
-
145
- desc :delete, 'delete a sprint'
146
- def delete
147
- handle_debug_option!
148
- set_sprint_vars!
149
-
150
- log.debug { 'Running `delete` command...' }
151
-
152
- del_msg = 'deleted sprint branches:'
153
- msg = <<~MSG
154
- #{options[:color] ? del_msg.light_magenta : del_msg}
155
- #{format_branch branch: @branch, color: :red}
156
- #{format_branch branch: @dev_branch, color: :red}
157
- MSG
158
-
159
- git.branch(@dev_branch).delete
160
- git.branch(@branch).delete
161
-
162
- say msg
163
-
164
- log.debug { 'Finished `delete` command...' }
165
- rescue Git::GitExecuteError => e
166
- die "[Error] #{e.class}\n#{e.message}"
167
- end
44
+ # Page if output is more than a page
45
+ class_option :pager,
46
+ type: :boolean,
47
+ aliases: %w[-p --pager],
48
+ banner: 'true (default, uses PAGER)'
168
49
 
169
50
  no_commands do
170
51
  def die msg
171
- if options[:color]
52
+ info.debug { 'dying ...' }
53
+
54
+ if color?
172
55
  say msg, :red
173
56
  else
174
57
  say msg
175
58
  end
176
- exit 1
59
+
60
+ info.debug { 'dead!' }
61
+
62
+ # @todo test this in a better way
63
+ #
64
+ # In tests, we don't want to exit from the test
65
+ exit 1 unless GitSprint.testing?
177
66
  end
178
67
 
179
68
  def handle_debug_option!
180
69
  ENV['GIT_SPRINT_LOG_LEVEL'] = 'DEBUG' if options[:debug]
181
70
  end
182
71
 
72
+ def color?
73
+ return false if ENV['NO_COLOR']
74
+
75
+ options[:color]
76
+ end
77
+
183
78
  def git
184
79
  # @todo refactor logger and use here
185
80
  @git ||= Git.open Dir.pwd # , :log => Logger.new(STDERR)
@@ -189,7 +84,7 @@ module GitSprint
189
84
 
190
85
  def format_branch branch:, color:
191
86
  sha = git.branch(branch).gcommit.sha[0..7]
192
- if !options[:color] || !color
87
+ if !color? || !color
193
88
  " #{branch.ljust 32, ' '} #{sha}"
194
89
  elsif color == :red
195
90
  " #{branch.ljust(32, ' ').light_red} #{sha.cyan}"
@@ -198,27 +93,46 @@ module GitSprint
198
93
  end
199
94
  end
200
95
 
201
- def set_sprint_vars!
96
+ # Prompts for project and sprint info, returns a hash
97
+ def prompt_for_sprint_vars!
202
98
  ask = -> question do
203
- question = options[:color] ? question.light_magenta : question
204
- ask question
99
+ question = color? ? question.light_magenta : question
100
+ ask "#{question.ljust 14, ' '}:"
205
101
  end
206
102
 
207
- @project = ask.call 'project name :'
208
- @project_number = ask.call 'project number:'
209
- @sprint_number = ask.call 'sprint number :'
103
+ project = ask.call 'project name'
104
+ project_number = ask.call 'project number'
105
+ sprint_number = ask.call 'sprint number'
210
106
  say
211
107
 
212
- [@project, @project_number, @sprint_number].each do |var|
108
+ [project, project_number, sprint_number].each do |var|
213
109
  die "#{var} is invalid!" if var.nil?
214
110
  end
215
111
 
216
- @branch = "project-#{@project_number}/" \
217
- "sprint-#{@sprint_number}/" \
218
- "#{@project}"
219
-
220
- @dev_branch = "#{@branch}-dev"
112
+ branch = "project-#{project_number}/" \
113
+ "sprint-#{sprint_number}/" \
114
+ "#{project}"
115
+
116
+ dev_branch = "#{branch}-dev"
117
+
118
+ {
119
+ project: {
120
+ name: project,
121
+ number: project_number
122
+ },
123
+ sprint: {
124
+ number: sprint_number
125
+ },
126
+ branch: branch,
127
+ dev_branch: dev_branch
128
+ }
221
129
  end
222
130
  end
223
131
  end
224
132
  end
133
+
134
+ require 'git-sprint/cli/version'
135
+ require 'git-sprint/cli/help'
136
+ require 'git-sprint/cli/list'
137
+ require 'git-sprint/cli/start'
138
+ require 'git-sprint/cli/delete'
@@ -0,0 +1,27 @@
1
+ module GitSprint
2
+ class CLI < Thor
3
+ desc :delete, 'Delete a sprint'
4
+ def delete
5
+ handle_debug_option!
6
+ sprint_data = prompt_for_sprint_vars!
7
+
8
+ log.debug { 'Running `delete` command...' }
9
+
10
+ del_msg = 'deleted sprint branches:'
11
+ msg = <<~MSG
12
+ #{color? ? del_msg.light_magenta : del_msg}
13
+ #{format_branch branch: sprint_data[:branch], color: :red}
14
+ #{format_branch branch: sprint_data[:dev_branch], color: :red}
15
+ MSG
16
+
17
+ git.branch(sprint_data[:dev_branch]).delete
18
+ git.branch(sprint_data[:branch]).delete
19
+
20
+ say msg
21
+
22
+ log.debug { 'Finished `delete` command...' }
23
+ rescue Git::GitExecuteError => e
24
+ die "[Error] #{e.class}\n#{e.message}"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,48 @@
1
+ module GitSprint
2
+ class CLI < Thor
3
+ # Get help for a command.
4
+ #
5
+ # This command is generated by thor, so we just add a message to the start
6
+ # when `git sprint` or `git sprint help` is called.
7
+ #
8
+ # @param cmd [String] The command to get help on
9
+ # @param args [Array<String>] Additional command arguments
10
+ def help cmd = nil, *args
11
+ handle_debug_option!
12
+ log.debug { 'Running `help` command...' }
13
+
14
+ banner = <<~MSG
15
+ Name:
16
+ git sprint
17
+
18
+ Summary:
19
+ a git plugin for sprint related commands
20
+ MSG
21
+
22
+ usage = capture_std_out { super }
23
+
24
+ output = if cmd.nil? # print banner
25
+ if color?
26
+ "#{banner}\n#{usage}".rainbow
27
+ else
28
+ "#{banner}\n#{usage}"
29
+ end
30
+ else
31
+ color? ? usage.rainbow : usage
32
+ end
33
+
34
+ if options[:pager] && output&.split("\n")&.size.send(:>, 30)
35
+ pager = ENV['PAGER'] || 'less'
36
+ temp_file = Tempfile.new
37
+ temp_file.puts output
38
+ temp_file.close
39
+
40
+ system "#{pager} #{temp_file.path}"
41
+ else
42
+ say output
43
+ end
44
+
45
+ log.debug { 'Finished `help` command.' }
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,25 @@
1
+ module GitSprint
2
+ class CLI < Thor
3
+ desc :list, 'List all sprint branches'
4
+ def list
5
+ handle_debug_option!
6
+ log.debug { 'Running `list` command...' }
7
+
8
+ sprint_branches = git.branches
9
+ .local
10
+ .map(&:name)
11
+ .select { |b| b.include? 'sprint' }
12
+
13
+ die 'no sprint branches!' if sprint_branches.empty?
14
+
15
+ msg = 'sprint branches:'
16
+ say color? ? msg.light_magenta : msg
17
+
18
+ sprint_branches.each do |branch|
19
+ say format_branch(branch: branch, color: :green)
20
+ end
21
+
22
+ log.debug { 'Finished `list` command...' }
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ module GitSprint
2
+ class CLI < Thor
3
+ desc :start, 'Start a new sprint'
4
+ def start
5
+ handle_debug_option!
6
+ sprint_data = prompt_for_sprint_vars!
7
+
8
+ log.debug { 'Running `start` command...' }
9
+
10
+ git.branch(sprint_data[:dev_branch]).create
11
+ git.branch(sprint_data[:branch]).create
12
+
13
+ msg = 'created new branches'
14
+ say <<~MSG
15
+ #{color? ? msg.light_magenta : msg}
16
+ #{format_branch branch: sprint_data[:branch], color: :green}
17
+ #{format_branch branch: sprint_data[:dev_branch], color: :green}
18
+ MSG
19
+
20
+ log.debug { 'Finished `start` command...' }
21
+ rescue Git::GitExecuteError => e
22
+ die "[Error] #{e.class}\n#{e.message}"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ module GitSprint
2
+ class CLI < Thor
3
+ map %w[-v -V] => :version
4
+ desc :version, 'Show the version'
5
+ def version
6
+ log.debug { 'Running `version` command...' }
7
+
8
+ version = GitSprint::VERSION
9
+ if color?
10
+ say "git sprint version #{version.light_green}"
11
+ else
12
+ say "git sprint version #{version}"
13
+ end
14
+
15
+ log.debug { 'Finished `version` command.' }
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'logger'
4
2
  require 'colorize'
5
3
 
@@ -25,7 +23,7 @@ module GitSprintLogger
25
23
  # Uses logging level ENV['GIT_SPRINT_LOG_LEVEL'], which can be WARN, INFO,
26
24
  # etc, or even a number (since those just map to integers anyway).
27
25
  def log
28
- Logger.new(STDOUT).tap do |logger|
26
+ Logger.new($stdout).tap do |logger|
29
27
  if Logger.constants.map(&:to_s).include? ENV['GIT_SPRINT_LOG_LEVEL']
30
28
  logger.level = Logger.const_get ENV['GIT_SPRINT_LOG_LEVEL']
31
29
  else
@@ -35,11 +33,3 @@ module GitSprintLogger
35
33
  end
36
34
  end
37
35
  end
38
-
39
- class Thor
40
- include GitSprintLogger
41
- end
42
-
43
- module GitSprint
44
- include GitSprintLogger
45
- end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module GitSprint
4
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'.freeze
5
3
  end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  begin
4
2
  require 'bundler/setup'
5
3
  rescue LoadError
@@ -27,5 +25,5 @@ Rake::TestTask.new :test do |t|
27
25
  t.warning = false
28
26
  end
29
27
 
30
- task :spec => :test
31
- task :default => :test
28
+ task spec: :test
29
+ task default: :test
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-sprint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Delk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-02 00:00:00.000000000 Z
11
+ date: 2019-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -108,20 +108,6 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.3'
111
- - !ruby/object:Gem::Dependency
112
- name: rspec
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '3.8'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '3.8'
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: m
127
113
  requirement: !ruby/object:Gem::Requirement
@@ -230,9 +216,11 @@ extra_rdoc_files: []
230
216
  files:
231
217
  - ".github/workflows/build.yml"
232
218
  - ".gitignore"
219
+ - ".rubocop.yml"
233
220
  - LICENSE.txt
234
221
  - README.md
235
222
  - bin/console
223
+ - bin/lint
236
224
  - bin/setup
237
225
  - bin/test
238
226
  - exe/git-sprint
@@ -241,6 +229,11 @@ files:
241
229
  - git-sprint.gemspec
242
230
  - lib/git-sprint.rb
243
231
  - lib/git-sprint/cli.rb
232
+ - lib/git-sprint/cli/delete.rb
233
+ - lib/git-sprint/cli/help.rb
234
+ - lib/git-sprint/cli/list.rb
235
+ - lib/git-sprint/cli/start.rb
236
+ - lib/git-sprint/cli/version.rb
244
237
  - lib/git-sprint/logger.rb
245
238
  - lib/git-sprint/version.rb
246
239
  - rakefile.rb
@@ -257,9 +250,9 @@ require_paths:
257
250
  - lib
258
251
  required_ruby_version: !ruby/object:Gem::Requirement
259
252
  requirements:
260
- - - ">="
253
+ - - "~>"
261
254
  - !ruby/object:Gem::Version
262
- version: '0'
255
+ version: '2.4'
263
256
  required_rubygems_version: !ruby/object:Gem::Requirement
264
257
  requirements:
265
258
  - - ">="