gitswitch 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -4
- data/.travis.yml +9 -0
- data/README.rdoc +7 -3
- data/lib/gitswitch.rb +1 -3
- data/lib/gitswitch/cli.rb +30 -26
- data/lib/gitswitch/commands.rb +54 -70
- data/lib/gitswitch/git.rb +34 -0
- data/lib/gitswitch/version.rb +1 -1
- data/spec/git_spec.rb +13 -0
- data/spec/gitswitch_spec.rb +24 -29
- data/spec/spec_helper.rb +9 -0
- data/spec/tmp/.gitkeep +0 -0
- metadata +69 -75
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/README.rdoc
CHANGED
@@ -58,10 +58,14 @@ Update your global .git user instead of your current repository
|
|
58
58
|
Show your current git user info. If you are in a git repo directory, it will show you the info associated with the current repository. Outside a repo (or if you use the --global option), it will show you the info from your global .git config.
|
59
59
|
# gitswitch info
|
60
60
|
|
61
|
-
== What's with all the aliases?
|
61
|
+
== What's with all the aliases for each task?
|
62
62
|
|
63
63
|
I initially wrote the gem using optparse and used the '-r' style params to keep the commands as short as possible. Now, I've decided to lean toward a rake-style descriptive method of passing commands -- which meshes well with the way Thor likes to do things. But the old command line options still work fine in case you got used to it.
|
64
64
|
|
65
|
-
==
|
65
|
+
== Recent changes (2012 edition)
|
66
66
|
|
67
|
-
|
67
|
+
I've learned a few things, taken some inspiration from David Copeland's "Build Awesome Command-Line Applications in Ruby" book, and stolen the idea of making everything a class method from Hashrocket's hitch gem.
|
68
|
+
|
69
|
+
In Ruby 1.9, command line argument strings get frozen, which makes gsub! unhappy. I wasn't on 1.9 two years ago, and my tests are far too incomplete for Travis CI to catch this bug. But alas, it is now fixed.
|
70
|
+
|
71
|
+
I've made the first steps toward returning reasonable exit status codes. A failed git command will not yet throw a proper exit code.
|
data/lib/gitswitch.rb
CHANGED
data/lib/gitswitch/cli.rb
CHANGED
@@ -3,34 +3,36 @@ require 'thor'
|
|
3
3
|
|
4
4
|
class Gitswitch
|
5
5
|
class CLI < Thor
|
6
|
-
|
6
|
+
EXIT_OK = 0
|
7
|
+
EXIT_MISSING_INFO = 1
|
7
8
|
|
8
9
|
######################################################################
|
9
10
|
desc "init", "Initialize your .gitswitch file"
|
10
11
|
def init
|
11
12
|
if !Gitswitch::gitswitch_file_exists
|
12
13
|
if yes?("Gitswitch users file ~/.gitswitch not found. Would you like to create one? (y/n): ")
|
13
|
-
Gitswitch
|
14
|
+
Gitswitch.create_fresh_gitswitch_file
|
14
15
|
else
|
15
16
|
puts "Ok, that's fine. Exiting."
|
16
|
-
exit
|
17
|
+
exit EXIT_OK
|
17
18
|
end
|
18
19
|
else
|
19
20
|
if yes?("Gitswitch users file ~/.gitswitch already exists. Would you like to wipe it out and create a fresh one? (y/n): ")
|
20
|
-
Gitswitch
|
21
|
+
Gitswitch.create_fresh_gitswitch_file
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
25
|
# Grab the current global info to drop into the default slot -- if available
|
25
|
-
user = Gitswitch
|
26
|
+
user = Gitswitch.get_git_user_info({:global => true})
|
26
27
|
if user[:name].empty? && user[:email].empty?
|
27
28
|
puts "No global git user.name and user.email configurations were found. Set up a default now."
|
28
29
|
add('default')
|
29
30
|
else
|
30
31
|
puts "Adding your global .gitconfig user info to the \"default\" tag..."
|
31
|
-
Gitswitch
|
32
|
+
Gitswitch.set_gitswitch_entry('default', user[:email], user[:name])
|
32
33
|
end
|
33
34
|
|
35
|
+
exit EXIT_OK
|
34
36
|
end
|
35
37
|
|
36
38
|
|
@@ -39,6 +41,7 @@ class Gitswitch
|
|
39
41
|
map ["-v","--version"] => :version
|
40
42
|
def version
|
41
43
|
puts Gitswitch::VERSION
|
44
|
+
exit EXIT_OK
|
42
45
|
end
|
43
46
|
|
44
47
|
|
@@ -48,6 +51,7 @@ class Gitswitch
|
|
48
51
|
method_option :global, :type => :boolean
|
49
52
|
def info
|
50
53
|
puts Gitswitch.current_user_info(options)
|
54
|
+
exit EXIT_OK
|
51
55
|
end
|
52
56
|
|
53
57
|
|
@@ -55,7 +59,8 @@ class Gitswitch
|
|
55
59
|
desc "list", "Show all the git user tags you have configured"
|
56
60
|
map ["-l","--list"] => :list
|
57
61
|
def list
|
58
|
-
puts Gitswitch.
|
62
|
+
puts Gitswitch.list_users
|
63
|
+
exit EXIT_OK
|
59
64
|
end
|
60
65
|
|
61
66
|
|
@@ -65,8 +70,9 @@ class Gitswitch
|
|
65
70
|
method_option :global, :type => :boolean, :aliases => ["-s","--global"] ## To support the deprecated behavior
|
66
71
|
method_option :repository, :type => :boolean, :aliases => "-r"
|
67
72
|
def switch(tag = 'default')
|
68
|
-
options[:global] ? global(tag) : Gitswitch.
|
73
|
+
options[:global] ? global(tag) : Gitswitch.switch_repo_user(tag)
|
69
74
|
puts Gitswitch.current_user_info(options)
|
75
|
+
exit EXIT_OK
|
70
76
|
end
|
71
77
|
|
72
78
|
|
@@ -74,7 +80,8 @@ class Gitswitch
|
|
74
80
|
desc "global [TAG]", "Switch global git user (your ~/.gitconfig file)"
|
75
81
|
map "-s" => :global
|
76
82
|
def global(tag = 'default')
|
77
|
-
Gitswitch.
|
83
|
+
Gitswitch.switch_global_user(tag)
|
84
|
+
exit EXIT_OK
|
78
85
|
end
|
79
86
|
|
80
87
|
|
@@ -82,19 +89,19 @@ class Gitswitch
|
|
82
89
|
desc "add [TAG]", "Add a new tagged user entry"
|
83
90
|
map ["-a","--add"] => :add
|
84
91
|
def add(tag = '')
|
85
|
-
|
86
|
-
|
87
|
-
tag.gsub!(/\W+/,'')
|
92
|
+
# tag.gsub!(/\W+/,'') ## ARGV gets frozen, so gsub! will throw an error.
|
93
|
+
tag = tag.gsub(/\W+/,'')
|
88
94
|
tag = ask("Enter a tag to describe this git user entry: ").gsub(/\W+/,'') if (tag.nil? || tag.empty?)
|
89
95
|
|
90
96
|
if tag.empty?
|
91
97
|
puts "You must enter a short tag to describe the git user entry you would like to save."
|
92
|
-
exit
|
98
|
+
exit EXIT_MISSING_INFO
|
93
99
|
end
|
94
100
|
|
95
101
|
puts "Adding a new gitswitch user entry for tag '#{tag}'"
|
96
102
|
(email, name) = prompt_for_email_and_name
|
97
|
-
|
103
|
+
Gitswitch.set_gitswitch_entry(tag, email, name)
|
104
|
+
exit EXIT_OK
|
98
105
|
end
|
99
106
|
|
100
107
|
|
@@ -102,33 +109,32 @@ class Gitswitch
|
|
102
109
|
desc "update [TAG]", "Update a tagged user entry"
|
103
110
|
map ["-o","--overwrite"] => :add
|
104
111
|
def update(tag = '')
|
105
|
-
|
106
|
-
tag_table = gs.get_tag_display
|
112
|
+
tag_table = Gitswitch.get_tag_display
|
107
113
|
|
108
|
-
tag.gsub
|
114
|
+
tag = tag.gsub(/\W+/,'')
|
109
115
|
if (tag.nil? || tag.empty?)
|
110
116
|
tag = ask("Which tag would you like to update: \n#{tag_table}").gsub(/\W+/,'')
|
111
117
|
end
|
112
118
|
|
113
119
|
puts "Updating #{tag} entry..."
|
114
120
|
(email, name) = prompt_for_email_and_name
|
115
|
-
Gitswitch.
|
121
|
+
Gitswitch.set_gitswitch_entry(tag, email, name)
|
122
|
+
exit EXIT_OK
|
116
123
|
end
|
117
124
|
|
118
125
|
|
119
126
|
######################################################################
|
120
127
|
desc "delete [TAG]", "Delete a tagged user entry"
|
121
128
|
def delete(tag = '')
|
122
|
-
|
123
|
-
|
124
|
-
tag_table = gs.get_tag_display
|
129
|
+
tag_table = Gitswitch.get_tag_display
|
125
130
|
|
126
|
-
tag.gsub
|
131
|
+
tag = tag.gsub(/\W+/,'')
|
127
132
|
if (tag.nil? || tag.empty?)
|
128
133
|
tag = ask("Which tag would you like to delete: \n#{tag_table}").gsub(/\W+/,'')
|
129
134
|
end
|
130
135
|
|
131
|
-
Gitswitch.
|
136
|
+
Gitswitch.delete_gitswitch_entry(tag)
|
137
|
+
exit EXIT_OK
|
132
138
|
end
|
133
139
|
|
134
140
|
|
@@ -140,8 +146,7 @@ class Gitswitch
|
|
140
146
|
email = ask(" E-mail address: ").chomp
|
141
147
|
## TODO: Validate e-mail
|
142
148
|
if email.nil?
|
143
|
-
puts "No
|
144
|
-
exit
|
149
|
+
puts "No e-mail address provided"
|
145
150
|
end
|
146
151
|
|
147
152
|
name = ask(" Name: (ENTER to use \"" + Gitswitch::get_git_user_info({:global => true})[:name] + "\") ").chomp
|
@@ -149,7 +154,6 @@ class Gitswitch
|
|
149
154
|
|
150
155
|
if name.nil?
|
151
156
|
puts "No name provided"
|
152
|
-
exit
|
153
157
|
end
|
154
158
|
|
155
159
|
return [email, name]
|
data/lib/gitswitch/commands.rb
CHANGED
@@ -1,45 +1,42 @@
|
|
1
1
|
require 'yaml'
|
2
|
-
require 'shellwords' if !String.new.methods.include?('shellescape')
|
3
|
-
|
4
2
|
|
5
3
|
class Gitswitch
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
attr_reader :users
|
10
|
-
|
4
|
+
def self.gitswitch_config_file
|
5
|
+
ENV['GITSWITCH_CONFIG_FILE'] || File.join(ENV["HOME"], ".gitswitch")
|
6
|
+
end
|
11
7
|
|
12
8
|
##############################################################
|
13
|
-
def
|
14
|
-
@users
|
9
|
+
def self.users
|
10
|
+
@users ||= load_users
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.load_users
|
14
|
+
user_hash = {}
|
15
15
|
if Gitswitch::gitswitch_file_exists
|
16
|
-
|
17
|
-
if @users.nil?
|
18
|
-
puts "Error loading .gitswitch file. Delete the file and start fresh."
|
19
|
-
exit
|
20
|
-
end
|
16
|
+
user_hash = YAML::load_file gitswitch_config_file
|
21
17
|
end
|
18
|
+
user_hash
|
22
19
|
end
|
23
|
-
|
24
20
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
@users = {}
|
29
|
-
save_gitswitch_file
|
21
|
+
## Create a .gitswitch file with the current user defaults
|
22
|
+
def self.create_fresh_gitswitch_file
|
23
|
+
save_gitswitch_file({})
|
30
24
|
end
|
31
25
|
|
32
26
|
def self.gitswitch_file_exists
|
33
|
-
File.exists?
|
27
|
+
File.exists? gitswitch_config_file
|
34
28
|
end
|
35
29
|
|
36
|
-
def save_gitswitch_file
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
30
|
+
def self.save_gitswitch_file(users_hash)
|
31
|
+
begin
|
32
|
+
File.open(gitswitch_config_file, 'w') do |fh|
|
33
|
+
fh.write(users_hash.to_yaml)
|
34
|
+
end
|
35
|
+
rescue
|
36
|
+
warn "ERROR: Could not open/write the gitswitch config file: #{gitswitch_config_file}: #{$!}"
|
37
|
+
exit
|
42
38
|
end
|
39
|
+
@users = nil
|
43
40
|
end
|
44
41
|
|
45
42
|
|
@@ -49,39 +46,40 @@ class Gitswitch
|
|
49
46
|
# * +tag+ - Required. The tag you want to add to your .gitswitch file
|
50
47
|
# * +email+ - Required
|
51
48
|
# * +name+ - Required
|
52
|
-
def set_gitswitch_entry(tag, email, name)
|
53
|
-
|
54
|
-
save_gitswitch_file
|
49
|
+
def self.set_gitswitch_entry(tag, email, name)
|
50
|
+
users[tag] = {:name => name, :email => email}
|
51
|
+
save_gitswitch_file(users)
|
55
52
|
end
|
56
53
|
|
57
|
-
def delete_gitswitch_entry(tag)
|
54
|
+
def self.delete_gitswitch_entry(tag)
|
58
55
|
if tag == 'default'
|
59
56
|
puts "Cannot delete the default tag. Use the update command instead"
|
60
57
|
exit
|
61
58
|
end
|
62
|
-
|
63
|
-
save_gitswitch_file
|
59
|
+
users.delete(tag)
|
60
|
+
save_gitswitch_file(users)
|
64
61
|
end
|
65
62
|
|
66
|
-
def get_user(tag)
|
67
|
-
|
68
|
-
|
63
|
+
def self.get_user(tag)
|
64
|
+
## TODO: Stop coding so defensively.
|
65
|
+
if !users.empty? && users[tag] && !users[tag].empty?
|
66
|
+
users[tag]
|
69
67
|
end
|
70
68
|
end
|
71
69
|
|
72
|
-
def get_tags
|
73
|
-
|
70
|
+
def self.get_tags
|
71
|
+
users.keys
|
74
72
|
end
|
75
73
|
|
76
|
-
def get_tag_display
|
77
|
-
max_length =
|
78
|
-
|
74
|
+
def self.get_tag_display
|
75
|
+
max_length = users.keys.sort{|x,y| y.length <=> x.length }.first.length
|
76
|
+
users.each_pair.map {|key,value| sprintf(" %#{max_length}s %s\n", key, value[:email]) }
|
79
77
|
end
|
80
78
|
|
81
|
-
def list_users
|
79
|
+
def self.list_users
|
82
80
|
response = ''
|
83
81
|
response << "\nCurrent git user options --\n"
|
84
|
-
|
82
|
+
users.each do |key, user|
|
85
83
|
response << "#{key}:\n"
|
86
84
|
response << " Name: #{user[:name]}\n" if !user[:name].to_s.empty?
|
87
85
|
response << " E-mail: #{user[:email]}\n\n"
|
@@ -99,26 +97,12 @@ class Gitswitch
|
|
99
97
|
response
|
100
98
|
end
|
101
99
|
|
102
|
-
def self.in_a_git_repo
|
103
|
-
%x(#{GIT_BIN} status 2>&1 | head -n 1).to_s =~ /^fatal/i ? false : true
|
104
|
-
end
|
105
|
-
|
106
|
-
|
107
|
-
##############################################################
|
108
|
-
def git_config(user, options = {})
|
109
|
-
git_args = 'config --replace-all'
|
110
|
-
git_args += ' --global' if options[:global]
|
111
|
-
|
112
|
-
%x(#{GIT_BIN} #{git_args} user.email #{user[:email].to_s.shellescape})
|
113
|
-
%x(#{GIT_BIN} #{git_args} user.name #{user[:name].to_s.shellescape}) if !user[:name].to_s.empty?
|
114
|
-
end
|
115
|
-
|
116
100
|
|
117
101
|
##############################################################
|
118
102
|
# Switch git user in your global .gitconfig file
|
119
103
|
# ==== Parameters
|
120
104
|
# * +tag+ - The tag associated with your desired git info in .gitswitch. Defaults to "default".
|
121
|
-
def switch_global_user
|
105
|
+
def self.switch_global_user(tag = "default")
|
122
106
|
if user = get_user(tag)
|
123
107
|
puts "Switching your .gitconfig user info to \"#{tag}\" tag (#{user[:name]} <#{user[:email]}>)."
|
124
108
|
git_config(user, {:global => true})
|
@@ -128,11 +112,11 @@ class Gitswitch
|
|
128
112
|
end
|
129
113
|
|
130
114
|
|
115
|
+
##############################################################
|
131
116
|
# Set the git user information for current repository
|
132
117
|
# ==== Parameters
|
133
118
|
# * +tag+ - The tag associated with your desired git info in .gitswitch. Defaults to "default".
|
134
|
-
def switch_repo_user(tag = "default")
|
135
|
-
## TODO: See if we're actually in a git repo
|
119
|
+
def self.switch_repo_user(tag = "default")
|
136
120
|
if !Gitswitch::in_a_git_repo
|
137
121
|
puts "You do not appear to currently be in a git repository directory"
|
138
122
|
false
|
@@ -147,18 +131,18 @@ class Gitswitch
|
|
147
131
|
end
|
148
132
|
|
149
133
|
|
150
|
-
|
151
|
-
|
134
|
+
##############################################################
|
135
|
+
# TODO: Straight delegation through to Gitswitch::Git
|
136
|
+
def self.in_a_git_repo
|
137
|
+
Gitswitch::Git.in_a_git_repo
|
138
|
+
end
|
139
|
+
|
140
|
+
def self.git_config(user, options = {})
|
141
|
+
Gitswitch::Git.git_config(user, options)
|
142
|
+
end
|
152
143
|
|
153
|
-
# Show the current git user info
|
154
144
|
def self.get_git_user_info(options = {})
|
155
|
-
|
156
|
-
git_args += ' --global' if options[:global]
|
157
|
-
|
158
|
-
{
|
159
|
-
:name => %x(#{GIT_BIN} #{git_args} user.name).to_s.chomp,
|
160
|
-
:email => %x(#{GIT_BIN} #{git_args} user.email).to_s.chomp
|
161
|
-
}
|
145
|
+
Gitswitch::Git.get_git_user_info(options)
|
162
146
|
end
|
163
147
|
|
164
148
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'shellwords' if !String.new.methods.include?('shellescape')
|
2
|
+
|
3
|
+
class Gitswitch
|
4
|
+
class Git
|
5
|
+
GIT_BIN = '/usr/bin/env git'
|
6
|
+
|
7
|
+
def self.version
|
8
|
+
%x(#{GIT_BIN} --version).to_s.gsub(/^git version\s*/, '')
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.in_a_git_repo
|
12
|
+
%x(#{GIT_BIN} status 2>&1 | head -n 1).to_s =~ /^fatal/i ? false : true
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.git_config(user, options = {})
|
16
|
+
git_args = 'config --replace-all'
|
17
|
+
git_args += ' --global' if options[:global]
|
18
|
+
|
19
|
+
%x(#{GIT_BIN} #{git_args} user.email #{user[:email].to_s.shellescape})
|
20
|
+
%x(#{GIT_BIN} #{git_args} user.name #{user[:name].to_s.shellescape}) if !user[:name].to_s.empty?
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.get_git_user_info(options = {})
|
24
|
+
git_args = 'config --get'
|
25
|
+
git_args += ' --global' if options[:global]
|
26
|
+
|
27
|
+
{
|
28
|
+
:name => %x(#{GIT_BIN} #{git_args} user.name).to_s.chomp,
|
29
|
+
:email => %x(#{GIT_BIN} #{git_args} user.email).to_s.chomp
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
data/lib/gitswitch/version.rb
CHANGED
data/spec/git_spec.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Gitswitch::Git do
|
4
|
+
it "should find the git executable" do
|
5
|
+
result = %x[#{Gitswitch::Git::GIT_BIN} --version]
|
6
|
+
$?.exitstatus.should == 0
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should grab the local git version" do
|
10
|
+
Gitswitch::Git.version.should =~ /^\d+\.+\d+/ # Should start off looking like a version number
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/spec/gitswitch_spec.rb
CHANGED
@@ -6,63 +6,58 @@ describe Gitswitch do
|
|
6
6
|
it "should have a VERSION" do
|
7
7
|
Gitswitch::VERSION.should_not == ''
|
8
8
|
end
|
9
|
-
|
10
|
-
it "should find the git executable" do
|
11
|
-
result = %x[#{Gitswitch::GIT_BIN} --version]
|
12
|
-
$?.exitstatus.should == 0
|
13
|
-
end
|
14
9
|
end
|
15
10
|
|
16
|
-
|
17
11
|
describe "read-only" do
|
18
|
-
it "should show the current git user credentials" do
|
19
|
-
Gitswitch.current_user_info.should =~ /^Your git user/
|
20
|
-
end
|
21
12
|
it "should show the current list of available gitswitch tags" do
|
22
|
-
|
13
|
+
|
23
14
|
end
|
24
15
|
end
|
25
16
|
|
26
|
-
|
27
17
|
describe "write methods" do
|
18
|
+
before :each do
|
19
|
+
Gitswitch.create_fresh_gitswitch_file
|
20
|
+
end
|
28
21
|
|
29
|
-
it "should allow you to add a new user entry" do
|
30
|
-
|
22
|
+
it "should allow you to add a new user entry" do
|
23
|
+
initial_user_count = Gitswitch.users.keys.count
|
24
|
+
set_test_entry
|
25
|
+
Gitswitch.users.keys.count.should be > initial_user_count
|
31
26
|
end
|
32
27
|
|
33
28
|
it "should allow you to update a user entry" do
|
34
|
-
|
29
|
+
set_test_entry
|
30
|
+
test_entry = get_test_entry
|
31
|
+
Gitswitch.set_gitswitch_entry(test_entry[0], 'testing@test.com', test_entry[2])
|
32
|
+
Gitswitch.get_user(test_entry[0])[:email].should eq('testing@test.com')
|
33
|
+
Gitswitch.get_user(test_entry[0])[:name].should eq(test_entry[2])
|
35
34
|
end
|
36
35
|
|
37
36
|
it "should allow you to delete a user entry" do
|
38
|
-
|
37
|
+
set_test_entry
|
38
|
+
Gitswitch.delete_gitswitch_entry(get_test_entry[0])
|
39
|
+
Gitswitch.users.keys.count.should == 0
|
39
40
|
end
|
40
41
|
|
41
42
|
it "should allow you to overwrite the current .gitswitch file and start fresh" do
|
42
|
-
|
43
|
+
set_test_entry
|
44
|
+
Gitswitch.create_fresh_gitswitch_file
|
45
|
+
Gitswitch.users.keys.count.should == 0
|
43
46
|
end
|
44
47
|
|
45
48
|
end
|
46
49
|
|
47
50
|
|
48
|
-
describe "
|
49
|
-
|
50
|
-
it "should allow you to change the global git user credentials" do
|
51
|
+
describe "weird outlier cases" do
|
52
|
+
it "in a git repo directory with no user info specified, show the global config header and user info" do
|
51
53
|
pending
|
52
54
|
end
|
53
|
-
|
54
|
-
it "should allow you to change a specific repository's user credentials" do
|
55
|
-
pending
|
56
|
-
end
|
57
55
|
end
|
58
56
|
|
59
57
|
|
60
|
-
|
61
|
-
|
62
|
-
it "in a git repo directory with no user info specified, show the global config header and user info" do
|
63
|
-
pending
|
64
|
-
end
|
65
|
-
|
58
|
+
it "should show the current git user credentials" do
|
59
|
+
Gitswitch.current_user_info.should =~ /^Your git user/
|
66
60
|
end
|
67
61
|
|
62
|
+
|
68
63
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,5 +8,14 @@ Bundler.setup
|
|
8
8
|
|
9
9
|
|
10
10
|
RSpec.configure do |c|
|
11
|
+
end
|
12
|
+
|
13
|
+
ENV['GITSWITCH_CONFIG_FILE'] = File.join(File.dirname(__FILE__), 'tmp', '.gitswitch')
|
11
14
|
|
15
|
+
def get_test_entry
|
16
|
+
['test','test@null.com', 'A. Tester']
|
12
17
|
end
|
18
|
+
|
19
|
+
def set_test_entry
|
20
|
+
Gitswitch.set_gitswitch_entry(*get_test_entry)
|
21
|
+
end
|
data/spec/tmp/.gitkeep
ADDED
File without changes
|
metadata
CHANGED
@@ -1,82 +1,80 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitswitch
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 2
|
10
|
-
version: 0.3.2
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Joe Alba
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2010-09-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: rake
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: thor
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
25
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: thor
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
47
38
|
type: :runtime
|
48
|
-
version_requirements: *id002
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: rspec
|
51
39
|
prerelease: false
|
52
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
41
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
62
53
|
version: 2.5.0
|
63
54
|
type: :development
|
64
|
-
|
65
|
-
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.5.0
|
62
|
+
description: Easily switch your git name/e-mail user info -- Handy for work vs. personal
|
63
|
+
and for pair programming
|
66
64
|
email: joe@joealba.com
|
67
|
-
executables:
|
65
|
+
executables:
|
68
66
|
- gitswitch
|
69
67
|
extensions: []
|
70
|
-
|
71
|
-
extra_rdoc_files:
|
68
|
+
extra_rdoc_files:
|
72
69
|
- LICENSE
|
73
70
|
- README.rdoc
|
74
|
-
files:
|
71
|
+
files:
|
75
72
|
- .bundle/config
|
76
73
|
- .document
|
77
74
|
- .gemtest
|
78
75
|
- .gitignore
|
79
76
|
- .rspec
|
77
|
+
- .travis.yml
|
80
78
|
- Gemfile
|
81
79
|
- LICENSE
|
82
80
|
- README.rdoc
|
@@ -86,43 +84,39 @@ files:
|
|
86
84
|
- lib/gitswitch.rb
|
87
85
|
- lib/gitswitch/cli.rb
|
88
86
|
- lib/gitswitch/commands.rb
|
87
|
+
- lib/gitswitch/git.rb
|
89
88
|
- lib/gitswitch/version.rb
|
89
|
+
- spec/git_spec.rb
|
90
90
|
- spec/gitswitch_spec.rb
|
91
91
|
- spec/spec_helper.rb
|
92
|
-
|
92
|
+
- spec/tmp/.gitkeep
|
93
93
|
homepage: http://github.com/joealba/gitswitch
|
94
94
|
licenses: []
|
95
|
-
|
96
95
|
post_install_message:
|
97
|
-
rdoc_options:
|
96
|
+
rdoc_options:
|
98
97
|
- --charset=UTF-8
|
99
|
-
require_paths:
|
98
|
+
require_paths:
|
100
99
|
- lib
|
101
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
101
|
none: false
|
103
|
-
requirements:
|
104
|
-
- -
|
105
|
-
- !ruby/object:Gem::Version
|
106
|
-
|
107
|
-
|
108
|
-
- 0
|
109
|
-
version: "0"
|
110
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
107
|
none: false
|
112
|
-
requirements:
|
113
|
-
- -
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
|
116
|
-
segments:
|
117
|
-
- 0
|
118
|
-
version: "0"
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
119
112
|
requirements: []
|
120
|
-
|
121
113
|
rubyforge_project:
|
122
|
-
rubygems_version: 1.
|
114
|
+
rubygems_version: 1.8.23
|
123
115
|
signing_key:
|
124
116
|
specification_version: 3
|
125
117
|
summary: Easy git user switching
|
126
|
-
test_files:
|
118
|
+
test_files:
|
119
|
+
- spec/git_spec.rb
|
127
120
|
- spec/gitswitch_spec.rb
|
128
121
|
- spec/spec_helper.rb
|
122
|
+
- spec/tmp/.gitkeep
|