git-duo 1.3.0 → 1.3.1

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
  SHA1:
3
- metadata.gz: 35b30a370fc3eed420ab7c87edde586defa46824
4
- data.tar.gz: f109937687adf8431fb2626e6eef823b5ab60987
3
+ metadata.gz: 40f8168f622c8da055f2eb8f42b38ddfbdaf03f8
4
+ data.tar.gz: 1cb5c9448e9cc10a4542402177e798299eb210b4
5
5
  SHA512:
6
- metadata.gz: d92c5d12b61c21dd034613de5878739e7d3cef29149de49055522d246e38528bd7afc1ad28a0a5924cf86df3ccce068ecbb459c674e48275dcd36f77ffb756c0
7
- data.tar.gz: e3189107ead1043efb8a1ccd96819275fab79395c47fc7a7e6d58501459eec38b9648d50992aa2432bf7730f98098c2a93fd55ddaed8c43ae642c0e3936ad25a
6
+ metadata.gz: cb2c80be744a702bdb89a366ad99033369a43eda5cfea75104eea2c22de48ee113a332caa2a10093da15cd76a64339045fcc9e2a639a3a18acb06bf291f7c6a0
7
+ data.tar.gz: ce390009f2dc542a8a387684af82e5000ff14d87b000ac1b34abf81a6ce27bbb00a82fea172627fb90c20da88b9fd855ac0773c7f75d4311d64b1decf58f4867
@@ -12,7 +12,9 @@ module Git
12
12
  result += opts.
13
13
  select {|k, _| authors.sample.respond_to? k }.
14
14
  map {|k, v|
15
- authors.select {|o| o.send(k) =~ /#{v}/i }
15
+ authors.
16
+ sort_by(&:key).
17
+ select {|o| o.send(k) =~ /#{v}/i }
16
18
  }.flatten
17
19
  rescue NoMethodError
18
20
  result
data/lib/git/duo/cli.rb CHANGED
@@ -8,19 +8,19 @@ module Git
8
8
  parser = OptionParser.new do |opts|
9
9
  puts current_repo.committer if ARGV.empty?
10
10
 
11
- opts.on '--add AUTHOR', 'Add an author. Format: "key Firstname Lastname <author@example.com>"' do |string|
11
+ opts.on '--add AUTHOR', '-a AUTHOR', 'Add an author. Format: "key Firstname Lastname <author@example.com>"' do |string|
12
12
  current_repo.authors = Author.import string
13
13
  end
14
14
 
15
- opts.on '--list', 'Lists the authors in the repository' do
15
+ opts.on '--list', '-l', 'Lists the authors in the repository' do
16
16
  puts current_repo.authors
17
17
  end
18
18
 
19
- opts.on '--email EMAIL', 'Set email format. Format: dev@example.com' do |email|
19
+ opts.on '--email EMAIL', '-e EMAIL', 'Set email format. Format: dev@example.com' do |email|
20
20
  current_repo.email = email
21
21
  end
22
22
 
23
- opts.on '--import=PATH/TO/REPO', 'Import pairs from another repo' do |path|
23
+ opts.on '--import=PATH/TO/REPO', '-i PATH/TO/REPO', 'Import pairs from another repo' do |path|
24
24
  import_repo = Repo.new path
25
25
  current_repo.email = import_repo.email
26
26
  current_repo.authors = import_repo.authors
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  module Duo
3
- VERSION = "1.3.0"
3
+ VERSION = "1.3.1"
4
4
  end
5
5
  end
@@ -21,6 +21,16 @@ module Git::Duo
21
21
  assert_equal "Alfred Pennyworth", result.name
22
22
  end
23
23
 
24
+ def test_where_partial_matches_closest
25
+ collection = AuthorCollection.new alexander_and_al
26
+
27
+ search = collection.where(key: 'al')
28
+ result = search.first
29
+
30
+ refute_predicate search, :empty?
31
+ assert_equal "Alfred Pennyworth", result.name
32
+ end
33
+
24
34
  def test_where_with_nonexisting_keys
25
35
  assert_empty collection.where(omg: 0)
26
36
  end
@@ -13,22 +13,17 @@ module Git::Duo
13
13
  returns(["board+%names@gotham.travel"]).at_least_once
14
14
 
15
15
  pair = Pair.new alfred_and_bruce_rachel, wrapper: wrapper
16
- expected_name = "Alfred Pennyworth + Bruce Wayne + Rachel Dawes"
17
- expected_email = "board+alfred+bruce+rachel@gotham.travel"
18
16
 
19
- assert_equal expected_name, pair.name
20
- assert_equal expected_email, pair.email
17
+ assert_equal "Alfred Pennyworth + Bruce Wayne + Rachel Dawes", pair.name
18
+ assert_equal "board+alfred+bruce+rachel@gotham.travel", pair.email
21
19
  end
22
20
 
23
21
  def test_pair_supports_one_single_author
24
22
  author = alfred_and_bruce.first
25
23
  pair = Pair.new [author], wrapper: wrapper
26
24
 
27
- expected_name = "Alfred Pennyworth"
28
- expected_email = "alfred@gotham.travel"
29
-
30
- assert_equal expected_name, pair.name
31
- assert_equal expected_email, pair.email
25
+ assert_equal "Alfred Pennyworth", pair.name
26
+ assert_equal "alfred@gotham.travel", pair.email
32
27
  end
33
28
 
34
29
  def test_name
@@ -40,16 +35,14 @@ module Git::Duo
40
35
  wrapper.expects(:config).with("git-duo.email").
41
36
  returns(["board+%names@gotham.travel"]).at_least_once
42
37
 
43
- expected = 'board+alfred+bruce@gotham.travel'
44
- assert_equal expected, pair.email
38
+ assert_equal "board+alfred+bruce@gotham.travel", pair.email
45
39
  end
46
40
 
47
41
  def test_email_guesses_the_email_domain_from_authors
48
42
  wrapper.expects(:config).with("git-duo.email").
49
43
  returns([]).at_least_once
50
44
 
51
- expected = "dev+alfred+bruce@gotham.travel"
52
- assert_equal expected, pair.email
45
+ assert_equal "dev+alfred+bruce@gotham.travel", pair.email
53
46
  end
54
47
 
55
48
  def test_email_raises_error_if_domain_could_not_be_guessed
@@ -65,8 +58,10 @@ module Git::Duo
65
58
  wrapper.expects(:config).with("git-duo.email").
66
59
  returns(["board+%names@gotham.travel"]).at_least_once
67
60
 
68
- expected = 'Alfred Pennyworth + Bruce Wayne <board+alfred+bruce@gotham.travel>'
69
- assert_equal expected, pair.to_s
61
+ name = "Alfred Pennyworth + Bruce Wayne"
62
+ email = "<board+alfred+bruce@gotham.travel>"
63
+
64
+ assert_equal "#{name} #{email}", pair.to_s
70
65
  end
71
66
 
72
67
  def test_inspect_is_to_s
data/test/test_helper.rb CHANGED
@@ -27,6 +27,13 @@ def jim_and_harvey
27
27
  ]
28
28
  end
29
29
 
30
+ def alexander_and_al
31
+ [
32
+ Git::Duo::Author.import('alexander Alexander Knox <alexander@gotham.travel>'),
33
+ Git::Duo::Author.import('al Alfred Pennyworth <alfred@gotham.travel>')
34
+ ]
35
+ end
36
+
30
37
  class DummyWrapper < Struct.new(:directory)
31
38
  def config(*)
32
39
  git_config
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Teo Ljungberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-07 00:00:00.000000000 Z
11
+ date: 2015-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  requirements: []
135
135
  rubyforge_project:
136
- rubygems_version: 2.4.1
136
+ rubygems_version: 2.4.8
137
137
  signing_key:
138
138
  specification_version: 4
139
139
  summary: Git pairing made easy