gitswitch 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/gitswitch.gemspec +2 -2
  3. data/lib/gitswitch.rb +28 -17
  4. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/gitswitch.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gitswitch}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joe Alba"]
12
- s.date = %q{2010-09-15}
12
+ s.date = %q{2010-09-16}
13
13
  s.default_executable = %q{gitswitch}
14
14
  s.description = %q{Easily switch your git name/e-mail user info -- Handy for work vs. personal and for pair programming}
15
15
  s.email = %q{joe@joealba.com}
data/lib/gitswitch.rb CHANGED
@@ -42,42 +42,48 @@ class GitSwitch
42
42
  o.banner = "Usage: gitswitch [options]"
43
43
 
44
44
  o.on "-l", "--list", "Show all git users you have configured" do
45
- list_users and exit
45
+ list_users
46
+ exit
46
47
  end
47
48
 
48
49
  o.on "-i", "--info", "Show the current git user info." do
49
- print_info and exit
50
+ print_info
51
+ exit
50
52
  end
51
53
 
52
- o.on "-s", "--switch [TAG]", String, "Switch git user to the specified tag" do |tag|
54
+ o.on "-s", "--switch [TAG]", String, "Switch git user to the specified tag in your user's global git configuration" do |tag|
53
55
  tag ||= 'default'
54
- switch_user tag
56
+ switch_user(tag)
55
57
  print_info
56
58
  exit
57
59
  end
58
60
 
59
61
  o.on "-r", "--repo [TAG]", String, "Switch git user to the specified tag for the current directory's git repository" do |tag|
60
62
  tag ||= 'default'
61
- switch_repo_user tag
63
+ switch_repo_user(tag)
62
64
  exit
63
65
  end
64
66
 
65
67
  o.on "-h", "--help", "Show this help message." do
66
68
  print_info
67
- puts parser and exit
69
+ puts parser
70
+ exit
68
71
  end
69
72
 
70
73
  o.on "-o", "--overwrite", "Overwrite/create a .gitswitch file using your global git user info as default" do
71
74
  create_gitswitch_file
72
- print_info and exit
75
+ print_info
76
+ exit
73
77
  end
74
78
 
75
- o.on "-a", "--add", "Add a new gitswitch entry" do
76
- add_gitswitch_entry and exit
79
+ o.on "-a", "--add [TAG]", "Add a new gitswitch entry" do |tag|
80
+ add_gitswitch_entry(tag)
81
+ exit
77
82
  end
78
83
 
79
84
  o.on("-v", "--version", "Show the current version.") do
80
- print_version and exit
85
+ print_version
86
+ exit
81
87
  end
82
88
  end
83
89
 
@@ -158,7 +164,7 @@ class GitSwitch
158
164
  # Set the git user information for current repository
159
165
  # ==== Parameters
160
166
  # * +tag+ - The tag associated with your desired git info in .gitswitch. Defaults to "default".
161
- def switch_repo_user tag = "default"
167
+ def switch_repo_user(tag = "default")
162
168
  ## TODO: See if we're actually in a git repo
163
169
  if user = get_user(tag)
164
170
  puts "Switching git user to \"#{tag}\" tag for the current repository (#{user[:name]} <#{user[:email]}>)."
@@ -170,19 +176,24 @@ class GitSwitch
170
176
 
171
177
 
172
178
  # Add a user entry to your .gitswitch file
173
- def add_gitswitch_entry
174
- print "Enter a tag to describe this git user entry: "
175
- tag = gets.gsub(/\W+/,'')
179
+ def add_gitswitch_entry(tag = '')
180
+ if (!tag.empty?)
181
+ tag.gsub!(/\W+/,'')
182
+ else
183
+ print "Enter a tag to describe this git user entry: "
184
+ tag = gets.gsub(/\W+/,'')
185
+ end
176
186
 
177
187
  if tag.empty?
178
188
  puts "You must enter a short tag to describe the git user entry you would like to save."
179
189
  exit
180
190
  end
181
-
182
- print "E-mail address: "
191
+
192
+ puts "Adding a new gitswitch user entry for tag '#{tag}'"
193
+ print " E-mail address: "
183
194
  email = gets.chomp
184
195
 
185
- print "Name: (ENTER to use \"" + get_git_user_info({:global => true})[:name] + "\") "
196
+ print " Name: (ENTER to use \"" + get_git_user_info({:global => true})[:name] + "\") "
186
197
  name = gets.chomp
187
198
  name = get_git_user_info({:global => true})[:name] if name.empty?
188
199
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitswitch
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joe Alba
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-15 00:00:00 -04:00
18
+ date: 2010-09-16 00:00:00 -04:00
19
19
  default_executable: gitswitch
20
20
  dependencies: []
21
21