tukune 0.0.3 → 0.1.0
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 +4 -4
- data/.rubocop_todo.yml +1 -0
- data/bin/tukune +3 -24
- data/lib/tukune.rb +1 -0
- data/lib/tukune/cli.rb +1 -6
- data/lib/tukune/git/diff.rb +17 -6
- data/lib/tukune/option_parser.rb +39 -0
- data/lib/tukune/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d4e98ddb41caa3e00a497df06da16bfc8fb57dd
|
4
|
+
data.tar.gz: c32e2e3aa97c537629c86ae00df2f34b5ba7c989
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bb90b2a43b70565ffc2bfa8f925f520449d2e6831bf954eb05c352a1046f9ed8c8f6ded35294e0f9c87a9a3f6f040af5cf3e6954be66401ea7f52050077e547
|
7
|
+
data.tar.gz: 8ba4b8c96f108d04814bce5f4b91ab2e2c36b3895f4b5b263f341e0cb8cdcab03222c195863b723aaa84d22c9293b4198096ea27daa44c0b13caa25393bafa75
|
data/.rubocop_todo.yml
CHANGED
data/bin/tukune
CHANGED
@@ -4,28 +4,7 @@ require 'bundler/setup'
|
|
4
4
|
require 'tukune'
|
5
5
|
require 'optparse'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
opt.banner = 'Usage: tukune [OPTIONS]'
|
10
|
-
opt.separator ''
|
11
|
-
opt.separator 'Options'
|
7
|
+
parser = Tukune::OptionParser.new
|
8
|
+
parser.parse!(ARGV)
|
12
9
|
|
13
|
-
|
14
|
-
options[:title] = title
|
15
|
-
end
|
16
|
-
|
17
|
-
opt.on('-b', '--body BODY', 'Pull request body') do |body|
|
18
|
-
options[:body] = body
|
19
|
-
end
|
20
|
-
|
21
|
-
opt.on('--enable-all') do |enable_all|
|
22
|
-
options[:enable_all] = enable_all
|
23
|
-
end
|
24
|
-
|
25
|
-
opt.on('-h', '--help', 'help') do
|
26
|
-
puts opt_parser
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
opt_parser.parse!
|
31
|
-
Tukune::CLI.start(options)
|
10
|
+
Tukune::CLI.start(parser.options)
|
data/lib/tukune.rb
CHANGED
data/lib/tukune/cli.rb
CHANGED
@@ -3,16 +3,11 @@ module Tukune
|
|
3
3
|
class << self
|
4
4
|
def start(options)
|
5
5
|
config = Tukune.configuration
|
6
|
-
diff = Tukune::Git::Diff.name_status
|
6
|
+
diff = Tukune::Git::Diff.name_status(options[:target_paths])
|
7
7
|
if config.tukune_branch?
|
8
8
|
puts 'this branch is tukune'
|
9
9
|
return
|
10
10
|
end
|
11
|
-
unless options[:enable_all] || config.pull_request?
|
12
|
-
puts 'This build is not part of pull request.'
|
13
|
-
puts 'If you want to exec tukune, try to use `--enable-all` option.'
|
14
|
-
return
|
15
|
-
end
|
16
11
|
if diff.nothing_to_commit?
|
17
12
|
puts 'nothing to commit, working directory clean'
|
18
13
|
return
|
data/lib/tukune/git/diff.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
+
require 'mem'
|
2
|
+
|
1
3
|
module Tukune
|
2
4
|
module Git
|
3
5
|
class Diff
|
6
|
+
include Mem
|
7
|
+
|
4
8
|
attr_reader :changed_files
|
5
9
|
|
6
|
-
def initialize(
|
7
|
-
@
|
10
|
+
def initialize(target_paths)
|
11
|
+
@target_paths = target_paths.join(' ')
|
8
12
|
end
|
9
13
|
|
10
14
|
def nothing_to_commit?
|
@@ -12,21 +16,28 @@ module Tukune
|
|
12
16
|
end
|
13
17
|
|
14
18
|
def added_files
|
15
|
-
`git ls-files --others --exclude-standard`.strip.split("\n")
|
19
|
+
`git ls-files --others --exclude-standard #{@target_paths}`.strip.split("\n")
|
16
20
|
end
|
21
|
+
memoize :added_files
|
17
22
|
|
18
23
|
def modified_files
|
19
24
|
changed_files.select { |type, _| type == 'M' }.map { |_, name| name }
|
20
25
|
end
|
26
|
+
memoize :modified_files
|
21
27
|
|
22
28
|
def deleted_files
|
23
29
|
changed_files.select { |type, _| type == 'D' }.map { |_, name| name }
|
24
30
|
end
|
31
|
+
memoize :deleted_files
|
32
|
+
|
33
|
+
def changed_files
|
34
|
+
@changed_files ||= `git diff --name-status #{@target_paths}`.strip.split("\n").map { |e| e.split("\t") }
|
35
|
+
end
|
36
|
+
memoize :changed_files
|
25
37
|
|
26
38
|
class << self
|
27
|
-
def name_status
|
28
|
-
|
29
|
-
Diff.new(changed_files)
|
39
|
+
def name_status(target_paths = [])
|
40
|
+
Diff.new(target_paths)
|
30
41
|
end
|
31
42
|
end
|
32
43
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Tukune
|
2
|
+
class OptionParser
|
3
|
+
def initialize
|
4
|
+
@opt_parser = ::OptionParser.new do |opt|
|
5
|
+
opt.banner = 'Usage: tukune [OPTIONS]'
|
6
|
+
opt.separator ''
|
7
|
+
opt.separator 'Options'
|
8
|
+
|
9
|
+
opt.on('-t', '--title TITLE', 'Pull request title') do |title|
|
10
|
+
@title = title
|
11
|
+
end
|
12
|
+
|
13
|
+
opt.on('-b', '--body BODY', 'Pull request body') do |body|
|
14
|
+
@body = body
|
15
|
+
end
|
16
|
+
|
17
|
+
opt.on('--target-path V,V...', Array) do |path|
|
18
|
+
@target_paths = path
|
19
|
+
end
|
20
|
+
|
21
|
+
opt.on('-h', '--help', 'help') do
|
22
|
+
puts @opt_parser
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def parse!(argv = @opt_parser.default_argv)
|
28
|
+
@opt_parser.parse!(argv)
|
29
|
+
end
|
30
|
+
|
31
|
+
def options
|
32
|
+
{
|
33
|
+
title: @title,
|
34
|
+
body: @body,
|
35
|
+
target_paths: @target_paths || []
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/tukune/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tukune
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gin0606
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- lib/tukune/configuration/default.rb
|
139
139
|
- lib/tukune/configuration/travis_ci.rb
|
140
140
|
- lib/tukune/git/diff.rb
|
141
|
+
- lib/tukune/option_parser.rb
|
141
142
|
- lib/tukune/version.rb
|
142
143
|
- tukune.gemspec
|
143
144
|
homepage: https://github.com/gin0606/tukune
|