git_switch 0.4.0 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4682e1a21cd0fcf56ba298bc9de39312bc7de40fd2cc7060853c9f452a934b79
4
- data.tar.gz: 378010b8b024f582759db350d4d6eeb21c15cc8ee7fe3a4807985bb37e335c55
3
+ metadata.gz: f34c15659dbf757f6ae047445f05afa0050899d6da90e9c1015907cdfb34faa8
4
+ data.tar.gz: 7dba73abededbefb3755e3135ec7b8270da70ba909899e52f75e763a9ed134e3
5
5
  SHA512:
6
- metadata.gz: f825028bb0d5296d3a260b5a6dd142e3c457debf9aee12ddd01d2f069007a85940b464e0366fde6cc1761e81230ab2daa2802ad3e47bb2e7b33ff382d92827c3
7
- data.tar.gz: 2a0a4755354d88147f41459bae0aeef877a7a145300e77b49d830b972253caa9240776c69d0a85ee48430487ea3516ab78419c330c76cf4bb7e8e80de43da424
6
+ metadata.gz: d8ae7bd065bb39786fe6fd747c387d4927dc9a2a0edeb845a7626779d8ab7f67d94c6ab0396c73af77c017a3313220d014b0ed95386c91039b4db365f996b67a
7
+ data.tar.gz: 808140af72dcee08f62baeb6e92b1376d5384560edf50808d893fa4592d78f6f41ac44c2ef461b5fb18f603523a3c136cfb6f15ed2cf0994668b6ae1f85c3e72
@@ -13,10 +13,6 @@ module GitSwitch
13
13
  args.detect {|a| !a.start_with? '-'}
14
14
  end
15
15
 
16
- def name
17
- profiles[selected_profile]["name"]
18
- end
19
-
20
16
  def username
21
17
  profiles[selected_profile]["username"]
22
18
  end
@@ -25,10 +21,18 @@ module GitSwitch
25
21
  profiles[selected_profile]["email"]
26
22
  end
27
23
 
24
+ def name
25
+ profiles[selected_profile]["name"]
26
+ end
27
+
28
28
  def ssh
29
29
  profiles[selected_profile]["ssh"]
30
30
  end
31
31
 
32
+ def ssh_command
33
+ "ssh -i #{ssh}"
34
+ end
35
+
32
36
  def profile
33
37
  @selected_profile
34
38
  end
@@ -5,7 +5,7 @@ module GitSwitch
5
5
  class Switcher
6
6
  attr_reader :config, :options
7
7
  delegate :usage?, :config?, :list?, :global?, to: :options
8
- delegate :profile, :name, :username, :email, :ssh, :print_list, :configure!, :valid_profile?, to: :config
8
+ delegate :profile, :name, :username, :email, :ssh, :ssh_command, :print_list, :configure!, :valid_profile?, to: :config
9
9
 
10
10
  def initialize(args)
11
11
  raise ArgumentError unless args.is_a? Array
@@ -38,21 +38,19 @@ module GitSwitch
38
38
  def set!
39
39
  return unless valid_profile? && git_repo?
40
40
 
41
- flag = global? ? '--global' : ''
42
-
43
- set_git_config(flag)
41
+ set_git_config
44
42
  set_ssh
45
- print_settings(flag)
43
+ print_settings
46
44
  end
47
45
 
48
46
  def print_usage
49
47
  puts usage
50
48
  end
51
49
 
52
- def print_settings(flag = '')
50
+ def print_settings
53
51
  if options.verbose?
54
52
  puts "\nGit Config:"
55
- puts `git config #{flag} -l --show-origin | grep user`
53
+ puts `git config #{git_config_flag} -l --show-origin | grep user`
56
54
  puts "\nSSH:"
57
55
  puts `ssh-add -l`
58
56
  else
@@ -62,14 +60,18 @@ module GitSwitch
62
60
 
63
61
  private
64
62
 
65
- def set_git_config(flag)
66
- `git config #{flag} user.name "#{name}"`
67
- `git config #{flag} user.username "#{username}"`
68
- `git config #{flag} user.email "#{email}"`
63
+ def git_config_flag
64
+ @git_config_flag ||= global? ? '--global' : ''
65
+ end
66
+
67
+ def set_git_config
68
+ `git config #{git_config_flag} user.name "#{name}"`
69
+ `git config #{git_config_flag} user.username "#{username}"`
70
+ `git config #{git_config_flag} user.email "#{email}"`
69
71
  end
70
72
 
71
73
  def set_ssh
72
- `ssh-add -D`
74
+ `git config #{git_config_flag} core.sshCommand "#{ssh_command}"`
73
75
  `ssh-add #{ssh}`
74
76
  end
75
77
 
@@ -1,3 +1,3 @@
1
1
  module GitSwitch
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_switch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Randall Reed, Jr.