mailmap 0.1.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mailmap/map.rb +17 -13
- data/lib/mailmap/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d659e60a379065bd575a324d915c318d797f23aecfddf90e9c06486c737813fd
|
4
|
+
data.tar.gz: 6fc69c39af05df32d2f21239f4aee331b50dae610b6e71aacaefbe21db3ce6c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5f8d9ed92f6e40525ee41c6b54fe459ea427c3df589e978a80b7a8dcbafbf91707c590e001493c31a71c3f98c600db058aef7580e2107e2ba3452fe20d5414b
|
7
|
+
data.tar.gz: '08d9415b709f531e9532bd89698a7a3cac9fdee485061a9ebd42d4daee32f17c2b39c674cde06f5cc0b460518d71ab04a96f9bd056b5509b4785878a477ff22b'
|
data/lib/mailmap/map.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'forwardable'
|
4
3
|
require 'strscan'
|
5
4
|
|
6
5
|
module Mailmap
|
@@ -10,9 +9,7 @@ module Mailmap
|
|
10
9
|
|
11
10
|
# A Map represents a .mailmap file.
|
12
11
|
class Map
|
13
|
-
|
14
|
-
|
15
|
-
def_delegators :each, *Enumerable.instance_methods(false)
|
12
|
+
include Enumerable
|
16
13
|
|
17
14
|
class << self
|
18
15
|
# Load a mailmap file and return Map object.
|
@@ -28,18 +25,20 @@ module Mailmap
|
|
28
25
|
|
29
26
|
# @param string [String] the string in .mailmap format
|
30
27
|
def initialize(string)
|
28
|
+
# @type ivar @map: Hash[String, Hash[String?, String?]]
|
31
29
|
@map = Hash.new { |h, k| h[k] = {} }
|
32
30
|
parse(string)
|
33
31
|
end
|
34
32
|
|
35
33
|
def each
|
36
|
-
return enum_for
|
34
|
+
return enum_for unless block_given?
|
37
35
|
|
38
36
|
@map.each do |commit_email, entries_by_commit_name|
|
39
37
|
entries_by_commit_name.each do |commit_name, (proper_name, proper_email)|
|
40
|
-
yield
|
38
|
+
yield proper_name, proper_email, commit_name, commit_email
|
41
39
|
end
|
42
40
|
end
|
41
|
+
self
|
43
42
|
end
|
44
43
|
|
45
44
|
# Look up the person's canonical name and email address.
|
@@ -47,7 +46,9 @@ module Mailmap
|
|
47
46
|
#
|
48
47
|
# @param commit_name_or_nil [String, nil] the name in commit or nil
|
49
48
|
# @param commit_email [String] the name in commit
|
50
|
-
# @return [
|
49
|
+
# @return [(String, String)] if found, a pair of proper name and email
|
50
|
+
# @return [(String, nil)] if only proper name is found
|
51
|
+
# @return [(nil, String)] if only proper email is found
|
51
52
|
# @return [nil] if not found
|
52
53
|
def lookup(commit_name_or_nil, commit_email)
|
53
54
|
commit_name = commit_name_or_nil&.downcase
|
@@ -56,12 +57,13 @@ module Mailmap
|
|
56
57
|
hash[commit_name] || hash[nil]
|
57
58
|
end
|
58
59
|
|
59
|
-
# Like
|
60
|
+
# Like +git-check-mailmap+ command, look up the person's canonical name and email address.
|
60
61
|
# If found, return them; otherwise return the input as-is.
|
61
62
|
#
|
62
63
|
# @param commit_name_or_nil [String, nil] the name in commit or nil
|
63
64
|
# @param commit_email [String] the email in commit
|
64
|
-
# @return [
|
65
|
+
# @return [(String, String)] a pair of proper name and email
|
66
|
+
# @return [(nil, String)] if proper name is not found and +commit_name+ is not provided
|
65
67
|
def resolve(commit_name_or_nil, commit_email)
|
66
68
|
proper_name, proper_email = lookup(commit_name_or_nil, commit_email)
|
67
69
|
proper_name ||= commit_name_or_nil
|
@@ -76,7 +78,7 @@ module Mailmap
|
|
76
78
|
# @return [Boolean]
|
77
79
|
def include_name?(name)
|
78
80
|
name = name.downcase
|
79
|
-
any? do |
|
81
|
+
any? do |proper_name, _proper_email, commit_name, _commit_email|
|
80
82
|
proper_name&.downcase == name || commit_name == name
|
81
83
|
end
|
82
84
|
end
|
@@ -88,7 +90,7 @@ module Mailmap
|
|
88
90
|
# @return [Boolean]
|
89
91
|
def include_email?(email)
|
90
92
|
email = email.downcase
|
91
|
-
any? do |
|
93
|
+
any? do |_proper_name, proper_email, _commit_name, commit_email|
|
92
94
|
proper_email&.downcase == email || commit_email == email
|
93
95
|
end
|
94
96
|
end
|
@@ -104,7 +106,9 @@ module Mailmap
|
|
104
106
|
end
|
105
107
|
|
106
108
|
def parse_name_and_email(line, line_number) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
109
|
+
# @type var names: Array[String]
|
107
110
|
names = []
|
111
|
+
# @type var emails: Array[String]
|
108
112
|
emails = []
|
109
113
|
scanner = StringScanner.new(line)
|
110
114
|
2.times do
|
@@ -114,9 +118,9 @@ module Mailmap
|
|
114
118
|
scanner.scan(/[^>]+/).then { |s| emails << s if s }
|
115
119
|
scanner.skip(/>/)
|
116
120
|
end
|
117
|
-
raise ParserError, "Missing commit email at line #{line_number}" if emails.empty?
|
118
|
-
|
119
121
|
commit_email = emails.pop&.downcase
|
122
|
+
raise ParserError, "Missing commit email at line #{line_number}" unless commit_email
|
123
|
+
|
120
124
|
proper_email = emails.pop
|
121
125
|
proper_name = names.shift
|
122
126
|
commit_name = names.shift&.downcase
|
data/lib/mailmap/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryosuke Ito
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Parser for Git Mailmap (.mailmap)
|
14
14
|
email:
|
@@ -27,7 +27,7 @@ metadata:
|
|
27
27
|
rubygems_mfa_required: 'true'
|
28
28
|
homepage_uri: https://github.com/manicmaniac/mailmap
|
29
29
|
source_code_uri: https://github.com/manicmaniac/mailmap
|
30
|
-
post_install_message:
|
30
|
+
post_install_message:
|
31
31
|
rdoc_options: []
|
32
32
|
require_paths:
|
33
33
|
- lib
|
@@ -35,15 +35,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
35
35
|
requirements:
|
36
36
|
- - ">="
|
37
37
|
- !ruby/object:Gem::Version
|
38
|
-
version: 2.
|
38
|
+
version: 2.7.0
|
39
39
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '0'
|
44
44
|
requirements: []
|
45
|
-
rubygems_version: 3.
|
46
|
-
signing_key:
|
45
|
+
rubygems_version: 3.4.6
|
46
|
+
signing_key:
|
47
47
|
specification_version: 4
|
48
48
|
summary: Parser for Git Mailmap (.mailmap)
|
49
49
|
test_files: []
|