git_curate 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/VERSION +1 -1
- data/exe/git-curate +1 -15
- data/lib/git_curate.rb +1 -0
- data/lib/git_curate/app.rb +22 -0
- data/lib/git_curate/branch.rb +7 -3
- data/lib/git_curate/runner.rb +16 -12
- data/lib/git_curate/util.rb +9 -2
- data/lib/git_curate/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6996bc4363bed00c0ed66d7ac49427a681f633e199e3b8f7b0e504bed64af52
|
4
|
+
data.tar.gz: 5a1766c37e6460a3b6081ba876443359b8fe01c44a898e234a4a96527ac13306
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed0bee6ea221fb9d3a50b8432151409604d0fee5ee63c7c423daf19fade386bc43a1c5d2645a178bdf9bc873d4318ec82d9f2468506f9b0643a59b9f48308f59
|
7
|
+
data.tar.gz: 909f9f0e1bc401c5e110a830b910192fd7fc959fc457ab8b1d19e5d7db0b1b0e6b1aa7a2d558f4d253b70a0ceb6dd8633d2152f7eaaf670c10355bee3255f321
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### v0.7.1
|
4
|
+
|
5
|
+
* Fix errors on -h, -v and --version options due to incorrect exit code handling
|
6
|
+
* Fix error when branch name is the same as the name of a filepath
|
7
|
+
* Get test coverage to 100%
|
8
|
+
|
3
9
|
### v0.7.0
|
4
10
|
|
5
11
|
* Show "no" option as capital "N", to hint that it's the default
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.1
|
data/exe/git-curate
CHANGED
@@ -1,19 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "git_curate"
|
4
|
-
require "optparse"
|
5
4
|
|
6
|
-
|
7
|
-
parser = GitCurate::CLIParser.new
|
8
|
-
continue = parser.parse(ARGV)
|
9
|
-
return unless continue
|
10
|
-
|
11
|
-
runner = GitCurate::Runner.new(parser.parsed_options)
|
12
|
-
runner.run
|
13
|
-
rescue OptionParser::InvalidOption
|
14
|
-
puts "Unrecognized option"
|
15
|
-
puts 'For help, enter `git curate -h`'
|
16
|
-
exit(1)
|
17
|
-
end
|
18
|
-
|
19
|
-
main
|
5
|
+
exit(GitCurate::App.main)
|
data/lib/git_curate.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "optparse"
|
2
|
+
|
3
|
+
module GitCurate
|
4
|
+
|
5
|
+
module App
|
6
|
+
|
7
|
+
def self.main
|
8
|
+
parser = GitCurate::CLIParser.new
|
9
|
+
continue = parser.parse(ARGV) # will throw on error
|
10
|
+
return 0 unless continue
|
11
|
+
|
12
|
+
runner = GitCurate::Runner.new(parser.parsed_options)
|
13
|
+
runner.run(ARGV)
|
14
|
+
rescue OptionParser::InvalidOption
|
15
|
+
puts "Unrecognized option"
|
16
|
+
puts "For help, enter `git curate -h`"
|
17
|
+
1
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/lib/git_curate/branch.rb
CHANGED
@@ -34,15 +34,15 @@ module GitCurate
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def last_author
|
37
|
-
Util.command_output("git log -n1 --format=format:%an #{proper_name}")
|
37
|
+
Util.command_output("git log -n1 --format=format:%an #{proper_name} --")
|
38
38
|
end
|
39
39
|
|
40
40
|
def last_commit_date
|
41
|
-
Util.command_output("git log -n1 --date=short --format=format:%cd #{proper_name}")
|
41
|
+
Util.command_output("git log -n1 --date=short --format=format:%cd #{proper_name} --")
|
42
42
|
end
|
43
43
|
|
44
44
|
def last_subject
|
45
|
-
Util.command_output("git log -n1 --format=format:%s #{proper_name}")
|
45
|
+
Util.command_output("git log -n1 --format=format:%s #{proper_name} --")
|
46
46
|
end
|
47
47
|
|
48
48
|
# Returns the local branches
|
@@ -77,6 +77,10 @@ module GitCurate
|
|
77
77
|
end.compact.to_h
|
78
78
|
end
|
79
79
|
|
80
|
+
def self.delete_multi(*branches)
|
81
|
+
Util.command_output("git branch -D #{branches.map(&:proper_name).join(" ")} --")
|
82
|
+
end
|
83
|
+
|
80
84
|
private
|
81
85
|
|
82
86
|
def self.command_to_branches(command)
|
data/lib/git_curate/runner.rb
CHANGED
@@ -5,16 +5,19 @@ require "tty-screen"
|
|
5
5
|
|
6
6
|
module GitCurate
|
7
7
|
|
8
|
+
EXIT_SUCCESS = 0
|
9
|
+
EXIT_FAILURE = 1
|
10
|
+
|
8
11
|
class Runner
|
9
12
|
|
10
13
|
def initialize(opts)
|
11
14
|
@opts = opts
|
12
15
|
end
|
13
16
|
|
14
|
-
def run
|
15
|
-
if
|
16
|
-
puts "This script does not accept any arguments."
|
17
|
-
|
17
|
+
def run(args)
|
18
|
+
if args.length != 0
|
19
|
+
$stderr.puts "This script does not accept any arguments."
|
20
|
+
return EXIT_FAILURE
|
18
21
|
end
|
19
22
|
|
20
23
|
branches = Branch.local
|
@@ -36,30 +39,30 @@ module GitCurate
|
|
36
39
|
prompt = " Delete? [y/N/done/abort/help] "
|
37
40
|
longest_response = "abort"
|
38
41
|
prompt_and_response_width = (interactive? ? (prompt.length + longest_response.length + 1) : 0)
|
39
|
-
|
42
|
+
max_table_width = TTY::Screen.width - prompt_and_response_width
|
43
|
+
table.pack(max_table_width: max_table_width)
|
40
44
|
|
41
45
|
branches_to_delete = []
|
42
46
|
|
43
47
|
if !interactive?
|
44
|
-
puts table
|
45
|
-
|
46
|
-
return
|
48
|
+
puts "#{table}#{$/}#{table.horizontal_rule}"
|
49
|
+
return EXIT_SUCCESS
|
47
50
|
end
|
48
51
|
|
49
52
|
table.each_with_index do |row, index|
|
50
53
|
case HighLine.ask("#{row}#{prompt}").downcase
|
51
54
|
when "y"
|
52
|
-
branches_to_delete << row.source
|
55
|
+
branches_to_delete << row.source
|
53
56
|
when "n", ""
|
54
57
|
; # do nothing
|
55
58
|
when "done"
|
56
59
|
puts table.horizontal_rule
|
57
60
|
finalize(branches_to_delete)
|
58
|
-
|
61
|
+
return EXIT_SUCCESS
|
59
62
|
when "abort"
|
60
63
|
puts table.horizontal_rule
|
61
64
|
puts "#{$/}Aborting. No branches deleted."
|
62
|
-
|
65
|
+
return EXIT_SUCCESS
|
63
66
|
else
|
64
67
|
puts table.horizontal_rule
|
65
68
|
print_help
|
@@ -70,6 +73,7 @@ module GitCurate
|
|
70
73
|
puts table.horizontal_rule
|
71
74
|
|
72
75
|
finalize(branches_to_delete)
|
76
|
+
return EXIT_SUCCESS
|
73
77
|
end
|
74
78
|
|
75
79
|
private
|
@@ -81,7 +85,7 @@ module GitCurate
|
|
81
85
|
def finalize(branches_to_delete)
|
82
86
|
if branches_to_delete.size != 0
|
83
87
|
puts
|
84
|
-
|
88
|
+
puts Branch.delete_multi(*branches_to_delete)
|
85
89
|
puts "#{$/}Done"
|
86
90
|
else
|
87
91
|
puts "#{$/}No branches deleted."
|
data/lib/git_curate/util.rb
CHANGED
@@ -11,10 +11,17 @@ module GitCurate
|
|
11
11
|
end
|
12
12
|
|
13
13
|
# Runs the passed string as a system command and returns its output.
|
14
|
+
# If the command doesn't exit with 0 (success), then an error will be thrown, with the error
|
15
|
+
# output as its message.
|
14
16
|
def self.command_output(command)
|
15
|
-
Open3.
|
16
|
-
|
17
|
+
stdout_str, stderr_str, status = Open3.capture3(command)
|
18
|
+
|
19
|
+
if status.exitstatus != 0
|
20
|
+
raise RuntimeError.new(stderr_str)
|
21
|
+
end
|
17
22
|
|
23
|
+
stdout_str
|
24
|
+
end
|
18
25
|
end
|
19
26
|
|
20
27
|
end
|
data/lib/git_curate/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_curate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Harvey
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- exe/git-curate
|
160
160
|
- git_curate.gemspec
|
161
161
|
- lib/git_curate.rb
|
162
|
+
- lib/git_curate/app.rb
|
162
163
|
- lib/git_curate/branch.rb
|
163
164
|
- lib/git_curate/cli_parser.rb
|
164
165
|
- lib/git_curate/copyright.rb
|