gitsu 2.0.1 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -4
- data/README.md +2 -1
- data/Rakefile +2 -1
- data/features/switch_to_multiple_users.feature +1 -1
- data/gitsu.gemspec +6 -5
- data/lib/gitsu/array.rb +5 -1
- data/lib/gitsu/switcher.rb +1 -1
- data/lib/gitsu/user.rb +4 -0
- data/lib/gitsu/user_list.rb +18 -23
- data/lib/gitsu/version.rb +6 -2
- data/spec/gitsu/array_spec.rb +14 -0
- data/spec/gitsu/switcher_spec.rb +1 -1
- data/spec/gitsu/user_list_spec.rb +1 -1
- data/spec/gitsu/version_spec.rb +12 -2
- metadata +23 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6052b324417250518afe887bcb191d981627958
|
4
|
+
data.tar.gz: 23ede1aa4fd3875f1dba10b1ee388d2f2fc50e00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70dc9713701d5e8ea3170df85c5faddf5460729b3a6326b082e2ed442d0ff99fb4e6502011b431646c65b720c21dfb69f8ca4875e303c9cba4b01d0d82af21a2
|
7
|
+
data.tar.gz: 33553abab3b5f6e8a4a49e50505e2c4fc549ba78f9029dd98cc746fd8bbb09f75d11a40e07e3bae87b41dc4e74aad71faa06e0b1b1bcb3ba63aa102392dd2290
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,8 @@
|
|
4
4
|
[![Coverage Status](https://coveralls.io/repos/drrb/gitsu/badge.png?branch=master)](https://coveralls.io/r/drrb/gitsu)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/drrb/gitsu.png)](https://codeclimate.com/github/drrb/gitsu)
|
6
6
|
|
7
|
-
[![Gem Version](https://badge.fury.io/rb/gitsu.png)](
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/gitsu.png)](https://badge.fury.io/rb/gitsu)
|
8
|
+
[![Dependency Status](https://gemnasium.com/drrb/gitsu.png)](https://gemnasium.com/drrb/gitsu)
|
8
9
|
|
9
10
|
Gitsu helps to manage your Git users, by making it easy to switch
|
10
11
|
between users. Gitsu also supports pair programming by allowing you
|
data/Rakefile
CHANGED
@@ -40,7 +40,7 @@ task 'push-release' => ['check-license', :verify] do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
version = GitSu::Version.prompt($stdin, $stdout, "Enter the version to release", GitSu::Version.current)
|
43
|
-
next_version = GitSu::Version.prompt($stdin, $stdout, "Enter the next development version", version.
|
43
|
+
next_version = GitSu::Version.prompt($stdin, $stdout, "Enter the next development version", version.next_patch)
|
44
44
|
|
45
45
|
puts "Releasing #{version} and preparing for #{next_version}"
|
46
46
|
|
@@ -64,4 +64,5 @@ end
|
|
64
64
|
|
65
65
|
def update_version(new_version)
|
66
66
|
system(%q[sed -i '' -E 's/VERSION = ".*"/VERSION = "] + new_version.to_s + %q["/' lib/gitsu/version.rb])
|
67
|
+
GitSu::VERSION.replace new_version.to_s
|
67
68
|
end
|
@@ -53,7 +53,7 @@ Feature: Switch to multiple users
|
|
53
53
|
b@example.com: Johnny B
|
54
54
|
"""
|
55
55
|
When I type "git su ja jb ja"
|
56
|
-
Then I should see "Couldn't find a combination of
|
56
|
+
Then I should see "Couldn't find a combination of users matching 'ja', 'jb' and 'ja'"
|
57
57
|
|
58
58
|
Scenario: No group email configured
|
59
59
|
Given the Git configuration has "gitsu.groupEmailAddress" set to ""
|
data/gitsu.gemspec
CHANGED
@@ -38,9 +38,10 @@ Gem::Specification.new do |gem|
|
|
38
38
|
gem.require_paths = ["lib"]
|
39
39
|
|
40
40
|
# Dependencies
|
41
|
-
gem.add_development_dependency
|
42
|
-
gem.add_development_dependency
|
43
|
-
gem.add_development_dependency
|
44
|
-
gem.add_development_dependency
|
45
|
-
gem.add_development_dependency
|
41
|
+
gem.add_development_dependency 'bundler', '~> 1.3'
|
42
|
+
gem.add_development_dependency 'rake'
|
43
|
+
gem.add_development_dependency 'coveralls', '>= 0.6.3'
|
44
|
+
gem.add_development_dependency 'json' # Coveralls needs it
|
45
|
+
gem.add_development_dependency 'rspec'
|
46
|
+
gem.add_development_dependency 'cucumber'
|
46
47
|
end
|
data/lib/gitsu/array.rb
CHANGED
@@ -21,11 +21,15 @@ class Array
|
|
21
21
|
elsif size == 1
|
22
22
|
last.to_s
|
23
23
|
else
|
24
|
-
"#{self[0
|
24
|
+
"#{self[0...-1].map{|e| e.to_s}.join(", ")} and #{last.to_s}"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
def pluralize(word)
|
29
29
|
size > 1 ? word + "s" : word
|
30
30
|
end
|
31
|
+
|
32
|
+
def quote
|
33
|
+
map { |element| "'#{element}'" }
|
34
|
+
end
|
31
35
|
end
|
data/lib/gitsu/switcher.rb
CHANGED
@@ -99,7 +99,7 @@ module GitSu
|
|
99
99
|
|
100
100
|
def add_parsed_user(user)
|
101
101
|
if @user_list.list.include? user
|
102
|
-
@output.puts "User '#{user}' already in user list"
|
102
|
+
@output.puts "User '#{user}' already in user list (try switching to them with 'git su #{user.initials}')"
|
103
103
|
else
|
104
104
|
@user_list.add user
|
105
105
|
@output.puts "User '#{user}' added to users"
|
data/lib/gitsu/user.rb
CHANGED
data/lib/gitsu/user_list.rb
CHANGED
@@ -16,6 +16,22 @@
|
|
16
16
|
|
17
17
|
module GitSu
|
18
18
|
class UserList
|
19
|
+
MATCH_STRATEGIES = [
|
20
|
+
# Whole word of name
|
21
|
+
lambda { |search_term, user| user.name =~ /\b#{search_term}\b/i },
|
22
|
+
|
23
|
+
# Beginning of word in name
|
24
|
+
lambda { |search_term, user| user.name =~ /\b#{search_term}/i },
|
25
|
+
|
26
|
+
# Initials
|
27
|
+
lambda { |search_term, user| user.initials =~ /#{search_term}/i },
|
28
|
+
|
29
|
+
# Segment anywhere in name or email
|
30
|
+
lambda do |search_term, user|
|
31
|
+
"#{user.name} #{user.email}" =~ /#{search_term}/i
|
32
|
+
end
|
33
|
+
]
|
34
|
+
|
19
35
|
def initialize(user_file)
|
20
36
|
@user_file = user_file
|
21
37
|
end
|
@@ -37,7 +53,7 @@ module GitSu
|
|
37
53
|
end
|
38
54
|
end
|
39
55
|
|
40
|
-
find_unique_combination(searches) or raise "Couldn't find a combination of
|
56
|
+
find_unique_combination(searches) or raise "Couldn't find a combination of users matching #{search_terms.quote.to_sentence}"
|
41
57
|
end
|
42
58
|
|
43
59
|
private
|
@@ -51,7 +67,7 @@ module GitSu
|
|
51
67
|
def all_matching_users(all_users, search_terms)
|
52
68
|
searches = search_terms.map {|search_term| Search.new(search_term)}
|
53
69
|
searches.each do |search|
|
54
|
-
|
70
|
+
MATCH_STRATEGIES.each do |strategy|
|
55
71
|
search.matches += all_users.select { |user| strategy.call(search.term, user) }
|
56
72
|
end
|
57
73
|
search.matches.uniq!
|
@@ -77,27 +93,6 @@ module GitSu
|
|
77
93
|
combo.uniq.size == combo.size
|
78
94
|
end
|
79
95
|
end
|
80
|
-
|
81
|
-
def match_strategies
|
82
|
-
[
|
83
|
-
# Whole word of name
|
84
|
-
lambda { |search_term, user| user.name =~ /\b#{search_term}\b/i },
|
85
|
-
|
86
|
-
# Beginning of word in name
|
87
|
-
lambda { |search_term, user| user.name =~ /\b#{search_term}/i },
|
88
|
-
|
89
|
-
# Initials
|
90
|
-
lambda do |search_term, user|
|
91
|
-
initials = user.name.split(" ").map { |word| word.chars.first }.join
|
92
|
-
initials =~ /#{search_term}/i
|
93
|
-
end,
|
94
|
-
|
95
|
-
# Segment anywhere in name or email
|
96
|
-
lambda do |search_term, user|
|
97
|
-
"#{user.name} #{user.email}" =~ /#{search_term}/i
|
98
|
-
end
|
99
|
-
]
|
100
|
-
end
|
101
96
|
end
|
102
97
|
end
|
103
98
|
|
data/lib/gitsu/version.rb
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
16
|
|
17
17
|
module GitSu
|
18
|
-
VERSION = "2.0.
|
18
|
+
VERSION = "2.0.3"
|
19
19
|
|
20
20
|
class Version
|
21
21
|
class ParseError < StandardError
|
@@ -48,7 +48,11 @@ module GitSu
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def next_minor
|
51
|
-
Version.new(@major, @minor + 1,
|
51
|
+
Version.new(@major, @minor + 1, 0)
|
52
|
+
end
|
53
|
+
|
54
|
+
def next_patch
|
55
|
+
Version.new(@major, @minor, @patch + 1)
|
52
56
|
end
|
53
57
|
|
54
58
|
def ==(other)
|
data/spec/gitsu/array_spec.rb
CHANGED
@@ -68,4 +68,18 @@ describe Array do
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
71
|
+
|
72
|
+
describe "#quote" do
|
73
|
+
let(:array) { [:apple, :orange] }
|
74
|
+
|
75
|
+
it "quotes all elements in the array" do
|
76
|
+
array.quote.should == ["'apple'", "'orange'"]
|
77
|
+
end
|
78
|
+
|
79
|
+
context "when the array is empty" do
|
80
|
+
it "returns an empty array" do
|
81
|
+
[].quote.should == []
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
71
85
|
end
|
data/spec/gitsu/switcher_spec.rb
CHANGED
@@ -173,7 +173,7 @@ module GitSu
|
|
173
173
|
context "when the user already exists in the user list" do
|
174
174
|
it "doesn't add the user to the user list" do
|
175
175
|
user_list.should_receive(:list).and_return [User.new('John Galt', 'jgalt@example.com')]
|
176
|
-
output.should_receive(:puts).with("User 'John Galt <jgalt@example.com>' already in user list")
|
176
|
+
output.should_receive(:puts).with("User 'John Galt <jgalt@example.com>' already in user list (try switching to them with 'git su jg')")
|
177
177
|
switcher.add("John Galt <jgalt@example.com>")
|
178
178
|
end
|
179
179
|
end
|
@@ -110,7 +110,7 @@ module GitSu
|
|
110
110
|
user_file.add("Johnny A", "ja@example.com")
|
111
111
|
user_file.add("Johnny B", "jb@example.com")
|
112
112
|
|
113
|
-
expect {user_list.find("ja", "jb", "j")}.to raise_error "Couldn't find a combination of
|
113
|
+
expect {user_list.find("ja", "jb", "j")}.to raise_error "Couldn't find a combination of users matching 'ja', 'jb' and 'j'"
|
114
114
|
end
|
115
115
|
end
|
116
116
|
context "when a search term only matches a user that was already matched, but the matching search term matched multiple users" do
|
data/spec/gitsu/version_spec.rb
CHANGED
@@ -60,12 +60,22 @@ module GitSu
|
|
60
60
|
end
|
61
61
|
|
62
62
|
describe "#next_minor" do
|
63
|
-
it "increments the minor version by 1" do
|
63
|
+
it "increments the minor version by 1 and resets the patch version to 0" do
|
64
64
|
version = Version.parse("1.2.3")
|
65
65
|
next_version = version.next_minor
|
66
66
|
next_version.major.should be 1
|
67
67
|
next_version.minor.should be 3
|
68
|
-
next_version.patch.should be
|
68
|
+
next_version.patch.should be 0
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#next_patch" do
|
73
|
+
it "increments the patch number by 1" do
|
74
|
+
version = Version.parse("1.2.3")
|
75
|
+
next_version = version.next_patch
|
76
|
+
next_version.major.should be 1
|
77
|
+
next_version.minor.should be 2
|
78
|
+
next_version.patch.should be 4
|
69
79
|
end
|
70
80
|
end
|
71
81
|
end
|
metadata
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitsu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- drrb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04
|
11
|
+
date: 2013-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '>='
|
@@ -39,7 +39,21 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: coveralls
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.6.3
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.6.3
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - '>='
|