git_curate 0.1.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efe99d35516a3694f9451935f2d33cb90b2f2534
4
- data.tar.gz: 23f63f3411b255eebe10039c6705f02d2ba89a01
3
+ metadata.gz: 62b82ad94f1a3524028e3e9f8b8dd60f1b4f2177
4
+ data.tar.gz: e01c3ba16c3828cdb511f69fea4f042451c851c3
5
5
  SHA512:
6
- metadata.gz: f87360f611fb9c29cddadfe0f18178fe541629124ab889ebb1e3d953ba856ee5f1d969a709a3475b36957a3b6a10ccc12d8ed2b169458fe4d20b12599f6dc761
7
- data.tar.gz: f98ce30aa2f67e1280b57863103c72558fe70e57c740c806cf970fefd29c275a400b7b6da5a976c88123aca9bcc015204159907c6fa1a5e82a4ae76945e09757
6
+ metadata.gz: 442a5541be149365e52164ade62f83fef05838baadfc3d34ab5c003963891d3bac2c4bed2c3499e30cdce1a2b8fcdb8f964172ae41228aa0d4af8d99ad153f8d
7
+ data.tar.gz: cb8dab16a57aadd7dfbdd009663a9fb1bc6eaa74ece51bd880656fa749814b3df01848a9437eddcd53221fdd423e393cbbfb82fb72942fb82ebe6f5c65eb661f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ### v0.2.0
4
+
5
+ * Make output more compact.
6
+ * Improve README.
7
+
3
8
  ### v0.1.1
4
9
 
5
10
  Fix runtime dependency specification.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_curate (0.1.1)
4
+ git_curate (0.2.0)
5
5
  highline (= 2.0.0)
6
6
  tabulo (= 1.2.0)
7
7
 
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # git curate
2
2
 
3
+ [![Gem Version][GV img]][Gem Version]
4
+
3
5
  ## Motivation
4
6
 
5
7
  After a while, my local repo becomes cluttered with branches, and `git branch` outputs an awkwardly
@@ -13,10 +15,14 @@ summary), and prompting you either to keep or to delete each branch as you go.
13
15
 
14
16
  ## Installation
15
17
 
18
+ You'll need Ruby v2.1.10 or higher. Run
19
+
16
20
  ```
17
21
  gem install git_curate
18
22
  ```
19
23
 
24
+ to install the executable.
25
+
20
26
  ## Usage
21
27
 
22
28
  From within a git repo, run:
@@ -27,7 +33,13 @@ git curate
27
33
 
28
34
  This will step you through your local branches one at a time, asking you whether to keep or
29
35
  delete each branch in what should be a fairly self-explanatory fashion. Note the branch
30
- you are currently on will not be included in the list.
36
+ you are currently on will not be included in the list, as `git` does not allow you to delete
37
+ the branch you're on.
38
+
39
+ (Note the space after `git`—we have effectively added a subcommand to `git` just by installing
40
+ a gem. When `git_curate` is installed, an executable is created called `git-curate`.
41
+ In general, for any executable of the form _git-xyz_ in your `PATH`, `git` will automatically
42
+ recognize _xyz_ as a subcommand, and will run that executable whenever that subcommand is invoked.)
31
43
 
32
44
  ## Development
33
45
 
@@ -41,3 +53,6 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/matt-h
41
53
 
42
54
  The gem is available as open source under the terms of the [MIT
43
55
  License](http://opensource.org/licenses/MIT).
56
+
57
+ [Gem Version]: https://rubygems.org/gems/git_curate
58
+ [GV img]: https://img.shields.io/gem/v/git_curate.svg?style=plastic
data/Rakefile CHANGED
@@ -3,5 +3,4 @@ require "rake-version"
3
3
 
4
4
  RakeVersion::Tasks.new do |v|
5
5
  v.copy "lib/git_curate/version.rb"
6
- v.copy "README.md", all: true
7
6
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
data/git_curate.gemspec CHANGED
@@ -14,6 +14,8 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = "https://github.com/matt-harvey/git_curate"
15
15
  spec.license = "MIT"
16
16
 
17
+ spec.required_ruby_version = ">= 2.1.10"
18
+
17
19
  spec.metadata = {
18
20
  "source_code_uri" => "https://github.com/matt-harvey/git_curate",
19
21
  "changelog_uri" => "https://raw.githubusercontent.com/matt-harvey/git_curate/master/CHANGELOG.md"
@@ -0,0 +1,90 @@
1
+ module GitCurate
2
+
3
+ class Runner
4
+
5
+ def run
6
+ if ARGV.length != 0
7
+ puts "This script does not accept any arguments."
8
+ exit
9
+ end
10
+
11
+ branches = `git branch`.split($/).reject { |b| current_branch?(b) }.map(&:strip)
12
+
13
+ table = Tabulo::Table.new(branches, vertical_rule_character: " ", intersection_character: " ",
14
+ horizontal_rule_character: "-", column_padding: 0) do |t|
15
+
16
+ t.add_column(:branch, header: "Branch", align_header: :left) { |branch| branch }
17
+
18
+ t.add_column("Last commit", align_header: :left) do |branch|
19
+ `git log -n1 --date=short --format='format:%cd' #{branch}`
20
+ end
21
+
22
+ t.add_column("Last author", align_header: :left) do |branch|
23
+ `git log -n1 --format='format:%an' #{branch}`
24
+ end
25
+
26
+ t.add_column("Last subject", align_header: :left) do |branch|
27
+ `git log -n1 --format='format:%s' #{branch}`
28
+ end
29
+ end
30
+
31
+ table.shrinkwrap!(max_table_width: 125)
32
+
33
+ branches_to_delete = []
34
+
35
+ table.each_with_index do |row, index|
36
+ case HighLine.ask("#{row} Mark for deletion? [y/n/done/abort/help] ")
37
+ when "y"
38
+ branches_to_delete << row.to_h[:branch]
39
+ when "n"
40
+ ; # do nothing
41
+ when "done"
42
+ puts table.horizontal_rule
43
+ finalize(branches_to_delete)
44
+ exit
45
+ when "abort"
46
+ puts table.horizontal_rule
47
+ puts "\nAborting. No branches deleted."
48
+ exit
49
+ else
50
+ puts table.horizontal_rule
51
+ print_help
52
+ puts table.horizontal_rule unless index == 0
53
+ redo
54
+ end
55
+ end
56
+ puts table.horizontal_rule
57
+
58
+ finalize(branches_to_delete)
59
+ end
60
+
61
+ private
62
+
63
+ def current_branch?(branch)
64
+ branch =~ /^\s*\*/
65
+ end
66
+
67
+ def finalize(branches_to_delete)
68
+ if branches_to_delete.size != 0
69
+ puts
70
+ system("git branch -D #{branches_to_delete.join(" ")}")
71
+ puts "\nDone"
72
+ else
73
+ puts "\nNo branches deleted."
74
+ end
75
+ end
76
+
77
+ def print_help
78
+ puts <<-EOL
79
+ Please enter one of:
80
+ y -- mark branch for deletion
81
+ n -- keep branch
82
+ done -- delete marked branches and exit session
83
+ abort -- abort without deleting any branches
84
+ help -- print this help message
85
+ EOL
86
+ end
87
+
88
+ end
89
+
90
+ end
@@ -1,3 +1,3 @@
1
1
  module GitCurate
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/git_curate.rb CHANGED
@@ -1,94 +1,4 @@
1
+ require "git_curate/runner"
1
2
  require "git_curate/version"
2
3
  require "highline/import"
3
4
  require "tabulo"
4
-
5
- module GitCurate
6
-
7
- class Runner
8
-
9
- def run
10
- if ARGV.length != 0
11
- puts "This script does not accept any arguments."
12
- exit
13
- end
14
-
15
- branches = `git branch`.split($/).reject { |b| current_branch?(b) }.map(&:strip)
16
-
17
- table = Tabulo::Table.new(branches, vertical_rule_character: " ", intersection_character: " ",
18
- horizontal_rule_character: "-", column_padding: 0) do |t|
19
-
20
- t.add_column(:branch, header: "Branch", align_header: :left) { |branch| branch }
21
-
22
- t.add_column("Last commit date", align_header: :left) do |branch|
23
- `git log -n1 --date=short --format='format:%cd' #{branch}`
24
- end
25
-
26
- t.add_column("Last commit author", align_header: :left) do |branch|
27
- `git log -n1 --format='format:%an' #{branch}`
28
- end
29
-
30
- t.add_column("Last commit subject", align_header: :left) do |branch|
31
- `git log -n1 --format='format:%s' #{branch}`
32
- end
33
- end
34
-
35
- table.shrinkwrap!(max_table_width: 200)
36
-
37
- branches_to_delete = []
38
-
39
- table.each_with_index do |row, index|
40
- case HighLine.ask("#{row} Mark for deletion? [y/n/done/abort/help] ")
41
- when "y"
42
- branches_to_delete << row.to_h[:branch]
43
- when "n"
44
- ; # do nothing
45
- when "done"
46
- puts table.horizontal_rule
47
- finalize(branches_to_delete)
48
- exit
49
- when "abort"
50
- puts table.horizontal_rule
51
- puts "\nAborting. No branches deleted."
52
- exit
53
- else
54
- puts table.horizontal_rule
55
- print_help
56
- puts table.horizontal_rule unless index == 0
57
- redo
58
- end
59
- end
60
- puts table.horizontal_rule
61
-
62
- finalize(branches_to_delete)
63
- end
64
-
65
- private
66
-
67
- def current_branch?(branch)
68
- branch =~ /^\s*\*/
69
- end
70
-
71
- def finalize(branches_to_delete)
72
- if branches_to_delete.size != 0
73
- puts
74
- system("git branch -D #{branches_to_delete.join(" ")}")
75
- puts "\nDone"
76
- else
77
- puts "\nNo branches deleted."
78
- end
79
- end
80
-
81
- def print_help
82
- puts <<-EOL
83
- Please enter one of:
84
- y -- mark branch for deletion
85
- n -- keep branch
86
- done -- delete marked branches and exit session
87
- abort -- abort without deleting any branches
88
- help -- print this help message
89
- EOL
90
- end
91
-
92
- end
93
-
94
- end
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.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Harvey
@@ -101,6 +101,7 @@ files:
101
101
  - exe/git-curate
102
102
  - git_curate.gemspec
103
103
  - lib/git_curate.rb
104
+ - lib/git_curate/runner.rb
104
105
  - lib/git_curate/version.rb
105
106
  homepage: https://github.com/matt-harvey/git_curate
106
107
  licenses:
@@ -116,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
117
  requirements:
117
118
  - - ">="
118
119
  - !ruby/object:Gem::Version
119
- version: '0'
120
+ version: 2.1.10
120
121
  required_rubygems_version: !ruby/object:Gem::Requirement
121
122
  requirements:
122
123
  - - ">="