git-sprint 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +20 -42
- data/.rubocop.yml +39 -0
- data/README.md +5 -3
- data/bin/console +0 -2
- data/bin/lint +3 -0
- data/bin/setup +0 -2
- data/bin/test +0 -1
- data/exe/git-sprint +0 -2
- data/gems.locked +1 -16
- data/gems.rb +0 -2
- data/git-sprint.gemspec +17 -3
- data/lib/git-sprint.rb +7 -2
- data/lib/git-sprint/cli.rb +61 -147
- data/lib/git-sprint/cli/delete.rb +27 -0
- data/lib/git-sprint/cli/help.rb +48 -0
- data/lib/git-sprint/cli/list.rb +25 -0
- data/lib/git-sprint/cli/start.rb +25 -0
- data/lib/git-sprint/cli/version.rb +18 -0
- data/lib/git-sprint/logger.rb +1 -11
- data/lib/git-sprint/version.rb +1 -3
- data/rakefile.rb +2 -4
- metadata +11 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c0faf2c2b2854f0034e876fbcf8189ad0897a70996393befaa996be29d13d70
|
4
|
+
data.tar.gz: ffe1b781bceb797b547036ee3f653f8c9961b42160f41d98aa791cb7c3e5fe19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8037516cc7fc0d2ab598f4c461521745f53f50ee9083ac4d37a37ad208f74fe550ea29a87229da7f328d5c4a7021acb218371429eb637c8b889c686c048979e8
|
7
|
+
data.tar.gz: 49947b6edfddb026eeec5a75c0ea7abd221f73913d207415ff85bb515b3ce6efcd312f92798a682eae8ed2ce4bb75886a5c0fe8e2a5b1331a617231112bcea95
|
data/.github/workflows/build.yml
CHANGED
@@ -3,55 +3,33 @@ name: build
|
|
3
3
|
on: [push]
|
4
4
|
|
5
5
|
jobs:
|
6
|
-
|
7
|
-
name:
|
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:
|
16
|
+
- name: set up ruby
|
13
17
|
uses: actions/setup-ruby@v1
|
14
18
|
with:
|
15
|
-
ruby-version:
|
19
|
+
ruby-version: ${{ matrix.ruby }}
|
16
20
|
|
17
|
-
- name:
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
data/.rubocop.yml
ADDED
@@ -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
|
-
|
32
|
-
|
33
|
-
|
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
|
|
data/bin/console
CHANGED
data/bin/lint
ADDED
data/bin/setup
CHANGED
data/bin/test
CHANGED
data/exe/git-sprint
CHANGED
data/gems.locked
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
git-sprint (0.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
data/git-sprint.gemspec
CHANGED
@@ -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|
|
data/lib/git-sprint.rb
CHANGED
@@ -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'
|
data/lib/git-sprint/cli.rb
CHANGED
@@ -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
|
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
|
32
|
+
# Set debug level
|
42
33
|
class_option :debug,
|
43
34
|
type: :string,
|
44
|
-
banner: '
|
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,
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
-
|
52
|
+
info.debug { 'dying ...' }
|
53
|
+
|
54
|
+
if color?
|
172
55
|
say msg, :red
|
173
56
|
else
|
174
57
|
say msg
|
175
58
|
end
|
176
|
-
|
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 !
|
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
|
-
|
96
|
+
# Prompts for project and sprint info, returns a hash
|
97
|
+
def prompt_for_sprint_vars!
|
202
98
|
ask = -> question do
|
203
|
-
question =
|
204
|
-
ask question
|
99
|
+
question = color? ? question.light_magenta : question
|
100
|
+
ask "#{question.ljust 14, ' '}:"
|
205
101
|
end
|
206
102
|
|
207
|
-
|
208
|
-
|
209
|
-
|
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
|
-
[
|
108
|
+
[project, project_number, sprint_number].each do |var|
|
213
109
|
die "#{var} is invalid!" if var.nil?
|
214
110
|
end
|
215
111
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
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
|
data/lib/git-sprint/logger.rb
CHANGED
@@ -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(
|
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
|
data/lib/git-sprint/version.rb
CHANGED
data/rakefile.rb
CHANGED
@@ -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 :
|
31
|
-
task :
|
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.
|
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-
|
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: '
|
255
|
+
version: '2.4'
|
263
256
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
264
257
|
requirements:
|
265
258
|
- - ">="
|