grog 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -19,7 +19,6 @@ A wrapper script for git-log - shows subject, time and author of each commit plu
19
19
  * Create --no-color option
20
20
  * Improve performance by slashing some shell calls to git commands
21
21
  * Accept a commit range as a command line parameter
22
- * Fix tag/branch ambiguity issues
23
22
  * Show 'shadows' or remote branches (commit that is the latest in common with a remote branch)
24
23
  * Distinguish commits by user with different color
25
24
  * Read user default options from a .grog file
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -8,7 +8,7 @@ Feature: default output of grog
8
8
  When I run grog on the test git repo
9
9
  Then the output ignoring colour codes should be
10
10
  """
11
- 6165a67 Commit B (Tom ten Thij) B(branch_b master) T(foo v2)
11
+ 6165a67 Commit B (Tom ten Thij) B(branch_b master origin/master) T(foo v2)
12
12
  bf5b520 Commit A (Tom ten Thij) B(branch_a foo) T(v1)
13
13
 
14
14
  """
data/lib/grog/git_log.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'term/ansicolor'
2
+ require 'grog/list_hash'
2
3
 
3
4
  module Grog
4
5
  class GitLog
@@ -114,7 +115,7 @@ module Grog
114
115
  def get_all_branches
115
116
  local_branches = branch_names_from_branch_command(:local)
116
117
  remote_branches = branch_names_from_branch_command(:remote)
117
- @branches = local_branches.merge(remote_branches)
118
+ @branches = Grog::ListHash.merge_lists(local_branches, remote_branches)
118
119
  end
119
120
 
120
121
  def get_all_tags
@@ -0,0 +1,19 @@
1
+ module Grog
2
+ class ListHash
3
+ # Merges hashes that have lists as values: when merging identical
4
+ # keys the lists are added
5
+ #
6
+ # Hash.merge_lists({:a => [1, 2]}, {:a => [3]}) => {:a => [1, 2, 3] }
7
+ def self.merge_lists(h1, h2)
8
+ merged_hash = h1.dup
9
+ h2.keys.each do |key|
10
+ if merged_hash.has_key?(key)
11
+ merged_hash[key] += h2[key]
12
+ else
13
+ merged_hash[key] = h2[key]
14
+ end
15
+ end
16
+ merged_hash
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,39 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ require 'grog/list_hash'
3
+
4
+ describe Grog::ListHash do
5
+ it "should add lists that are the values of identical keys" do
6
+ hash1 = {:a => [1, 2], :b => [4]}
7
+ hash2 = {:a => [3], :c => [5]}
8
+ expected_hash = {:a => [1, 2, 3], :b => [4], :c => [5] }
9
+ Grog::ListHash.merge_lists(hash1, hash2).should == expected_hash
10
+ end
11
+
12
+ it "should be an empty hash if both arguments are empty" do
13
+ Grog::ListHash.merge_lists({}, {}).should == {}
14
+ end
15
+
16
+ it "should be the first hash if the second one is empty" do
17
+ hash = { :x => 3 }
18
+ Grog::ListHash.merge_lists(hash, {}).should == hash
19
+ end
20
+
21
+ it "should be the second hash if the first one is empty" do
22
+ hash = { :x => 3 }
23
+ Grog::ListHash.merge_lists({}, hash).should == hash
24
+ end
25
+
26
+ it "should not modify the first hash" do
27
+ hash1 = {:a => [1]}
28
+ hash2 = {:a => [2]}
29
+ Grog::ListHash.merge_lists(hash1, hash2)
30
+ hash1[:a].should == [1]
31
+ end
32
+
33
+ it "should not modify the second hash" do
34
+ hash1 = {:a => [1]}
35
+ hash2 = {:a => [2]}
36
+ Grog::ListHash.merge_lists(hash1, hash2)
37
+ hash2[:a].should == [2]
38
+ end
39
+ end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom ten Thij
@@ -76,8 +76,10 @@ files:
76
76
  - features/support/env.rb
77
77
  - lib/grog.rb
78
78
  - lib/grog/git_log.rb
79
+ - lib/grog/list_hash.rb
79
80
  - lib/grog/options.rb
80
81
  - spec/grog/git_log_spec.rb
82
+ - spec/grog/list_hash.rb
81
83
  - spec/grog/options_spec.rb
82
84
  - spec/grog_spec.rb
83
85
  - spec/spec.opts
@@ -113,6 +115,7 @@ specification_version: 3
113
115
  summary: A wrapper script for git-log - shows subject, time and author of each commit plus branches and tags
114
116
  test_files:
115
117
  - spec/grog/git_log_spec.rb
118
+ - spec/grog/list_hash.rb
116
119
  - spec/grog/options_spec.rb
117
120
  - spec/grog_spec.rb
118
121
  - spec/spec_helper.rb