git_curate 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3c5185af90e371c5981ee81a5155ef9d2fedd1f65f461c6464fd35e579f5936
4
- data.tar.gz: baac5f23f47c40f59b91ce81fbe0de4c8a6dd5c956ac810f2e9e5c2b6d92e893
3
+ metadata.gz: 3210c7e8b48389447db001fa0b444b930a764a2c8c390a61827a2d6f01436d3b
4
+ data.tar.gz: 3b31eb0d7f14f5cc6cad363de5feb41aa9b38c2f3cea985b7ea309bfc0201f2d
5
5
  SHA512:
6
- metadata.gz: ef680b8d458bcd803f0d848c450dc9858041238861a66ed7ec40be86e10a294b233ed4c4387a483443bcb31a80e47108ea008d59011e60aff16d95ba38a6b33b
7
- data.tar.gz: 2de940644c00092336090309c49f499b91bf5cc903710dae67fc0c99ae9e726c7ed35195ad7ae684782a2b2002ba4087cbe7342c3659cbae6fe6c88b44589461
6
+ metadata.gz: 9c9d9b44f67a34b792045029656cf8c2e5f916d2325c45e6a2cf23989fd4d2c40431107b61405ad05dab21a0b8c80bf8e6ce3051689ca61a0429f0ca0c822ec3
7
+ data.tar.gz: 4178cf08ef5e4785cb42ec4d9437f1b0079e0adaa5ad8c56f87c25ba00ab6f678a0d1dde64ba57630b43f4376b149aeab7eeb332de28ef7c9cc4419f16137160
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### v0.6.3
4
+
5
+ * Fix formatting oof output on Windows.
6
+
3
7
  ### v0.6.2
4
8
 
5
9
  * Upgrade dependency versions.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_curate (0.6.2)
4
+ git_curate (0.6.3)
5
5
  highline (= 2.0.2)
6
6
  tabulo (= 1.5.1)
7
7
  tty-screen (= 0.7.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.2
1
+ 0.6.3
data/lib/git_curate.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "git_curate/branch"
1
2
  require "git_curate/cli_parser"
2
3
  require "git_curate/copyright"
3
4
  require "git_curate/runner"
@@ -0,0 +1,42 @@
1
+ module GitCurate
2
+
3
+ class Branch
4
+
5
+ attr_reader :raw_name
6
+
7
+ # raw_name should start in "* " if the current branch, but should otherwise have not whitespace.
8
+ def initialize(raw_name)
9
+ @raw_name = raw_name
10
+ end
11
+
12
+ def proper_name
13
+ @proper_name ||= @raw_name.lstrip.gsub(/^\*\s+/, '')
14
+ end
15
+
16
+ def current?
17
+ @current ||= /^\*\s+/.match?(@raw_name)
18
+ end
19
+
20
+ def displayable_name(pad:)
21
+ if pad && !current?
22
+ " #{@raw_name}"
23
+ else
24
+ @raw_name
25
+ end
26
+ end
27
+
28
+ def last_author
29
+ `git log -n1 --format=format:%an #{proper_name}`
30
+ end
31
+
32
+ def last_commit_date
33
+ `git log -n1 --date=short --format=format:%cd #{proper_name}`
34
+ end
35
+
36
+ def last_subject
37
+ `git log -n1 --format=format:%s #{proper_name}`
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -10,8 +10,6 @@ module GitCurate
10
10
  LEADING_STAR_REGEX = /^\* /
11
11
  REMOTE_INFO_REGEX = /^[^\s]+\s+[^\s]+\s+\[(.+?)\]/
12
12
 
13
- Branch = Struct.new("Branch", :raw, :proper, :displayable)
14
-
15
13
  class Runner
16
14
 
17
15
  def initialize(opts)
@@ -24,37 +22,20 @@ module GitCurate
24
22
  exit
25
23
  end
26
24
 
27
- branches = command_to_a("git branch").reject { |raw_branch| excluded_branch?(raw_branch) }.map do |raw_branch|
28
- Struct::Branch.new(raw_branch, proper_branch(raw_branch), displayable_branch(raw_branch))
29
- end
30
-
25
+ branches = command_to_a("git branch").map { |b| Branch.new(b) }
26
+ branches.reject!(&:current?) if interactive?
31
27
  merged_branches = command_to_a("git branch --merged").to_set
32
28
  upstream_branches = get_upstream_branches
33
29
 
34
30
  table = Tabulo::Table.new(branches, vertical_rule_character: " ", intersection_character: " ",
35
31
  horizontal_rule_character: "-", column_padding: 0, align_header: :left) do |t|
36
32
 
37
- t.add_column(:branch, header: "Branch") { |branch| branch.displayable }
38
-
39
- t.add_column("Last commit") do |branch|
40
- `git log -n1 --date=short --format='format:%cd' #{branch.proper}`
41
- end
42
-
43
- t.add_column("Last author") do |branch|
44
- `git log -n1 --format='format:%an' #{branch.proper}`
45
- end
46
-
47
- t.add_column("Last subject") do |branch|
48
- `git log -n1 --format='format:%s' #{branch.proper}`
49
- end
50
-
51
- t.add_column("Merged\ninto HEAD?") do |branch|
52
- merged_branches.include?(branch.proper) ? "Merged" : "Not merged"
53
- end
54
-
55
- t.add_column("Status vs\nupstream") do |branch|
56
- upstream_branches.fetch(branch.proper, "No upstream")
57
- end
33
+ t.add_column(:branch, header: "Branch") { |b| b.displayable_name(pad: !interactive?) }
34
+ t.add_column("Last commit", &:last_commit_date)
35
+ t.add_column("Last author", &:last_author)
36
+ t.add_column("Last subject", &:last_subject)
37
+ t.add_column("Merged#{$/}into HEAD?") { |b| merged_branches.include?(b.proper_name) ? "Merged" : "Not merged" }
38
+ t.add_column("Status vs#{$/}upstream") { |b| upstream_branches.fetch(b.proper_name, "No upstream") }
58
39
  end
59
40
 
60
41
  prompt = " Delete? [y/n/done/abort/help] "
@@ -73,7 +54,7 @@ module GitCurate
73
54
  if interactive?
74
55
  case HighLine.ask("#{row}#{prompt}")
75
56
  when "y"
76
- branches_to_delete << proper_branch(row.to_h[:branch])
57
+ branches_to_delete << row.source.proper_name
77
58
  when "n", ""
78
59
  ; # do nothing
79
60
  when "done"
@@ -82,7 +63,7 @@ module GitCurate
82
63
  exit
83
64
  when "abort"
84
65
  puts table.horizontal_rule
85
- puts "\nAborting. No branches deleted."
66
+ puts "#{$/}Aborting. No branches deleted."
86
67
  exit
87
68
  else
88
69
  puts table.horizontal_rule
@@ -105,24 +86,6 @@ module GitCurate
105
86
  !@opts[:list]
106
87
  end
107
88
 
108
- def proper_branch(raw_branch)
109
- raw_branch.lstrip.gsub(/^\*\s*/, '')
110
- end
111
-
112
- def displayable_branch(raw_branch)
113
- return raw_branch if interactive?
114
-
115
- current_branch?(raw_branch) ? raw_branch : " " + raw_branch
116
- end
117
-
118
- def excluded_branch?(raw_branch)
119
- interactive? && current_branch?(raw_branch)
120
- end
121
-
122
- def current_branch?(raw_branch)
123
- raw_branch =~ /^\s*\*/
124
- end
125
-
126
89
  # Returns a Hash containing, as keys, all local branches that have upstream branches,
127
90
  # and, as values, a brief description of each branch's status relative to its upstream
128
91
  # branch (up to date, or ahead/behind)
@@ -149,9 +112,9 @@ module GitCurate
149
112
  if branches_to_delete.size != 0
150
113
  puts
151
114
  system("git branch -D #{branches_to_delete.join(" ")}")
152
- puts "\nDone"
115
+ puts "#{$/}Done"
153
116
  else
154
- puts "\nNo branches deleted."
117
+ puts "#{$/}No branches deleted."
155
118
  end
156
119
  end
157
120
 
@@ -1,3 +1,3 @@
1
1
  module GitCurate
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_curate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Harvey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-23 00:00:00.000000000 Z
11
+ date: 2019-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -116,6 +116,7 @@ files:
116
116
  - exe/git-curate
117
117
  - git_curate.gemspec
118
118
  - lib/git_curate.rb
119
+ - lib/git_curate/branch.rb
119
120
  - lib/git_curate/cli_parser.rb
120
121
  - lib/git_curate/copyright.rb
121
122
  - lib/git_curate/runner.rb