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 +4 -4
- data/lib/git_switch/config.rb +8 -4
- data/lib/git_switch/switcher.rb +14 -12
- data/lib/git_switch/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f34c15659dbf757f6ae047445f05afa0050899d6da90e9c1015907cdfb34faa8
|
4
|
+
data.tar.gz: 7dba73abededbefb3755e3135ec7b8270da70ba909899e52f75e763a9ed134e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8ae7bd065bb39786fe6fd747c387d4927dc9a2a0edeb845a7626779d8ab7f67d94c6ab0396c73af77c017a3313220d014b0ed95386c91039b4db365f996b67a
|
7
|
+
data.tar.gz: 808140af72dcee08f62baeb6e92b1376d5384560edf50808d893fa4592d78f6f41ac44c2ef461b5fb18f603523a3c136cfb6f15ed2cf0994668b6ae1f85c3e72
|
data/lib/git_switch/config.rb
CHANGED
@@ -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
|
data/lib/git_switch/switcher.rb
CHANGED
@@ -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
|
-
|
42
|
-
|
43
|
-
set_git_config(flag)
|
41
|
+
set_git_config
|
44
42
|
set_ssh
|
45
|
-
print_settings
|
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
|
50
|
+
def print_settings
|
53
51
|
if options.verbose?
|
54
52
|
puts "\nGit Config:"
|
55
|
-
puts `git config #{
|
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
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
-
`
|
74
|
+
`git config #{git_config_flag} core.sshCommand "#{ssh_command}"`
|
73
75
|
`ssh-add #{ssh}`
|
74
76
|
end
|
75
77
|
|
data/lib/git_switch/version.rb
CHANGED