forked from vmware-archive/git_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-project
More file actions
executable file
·35 lines (32 loc) · 914 Bytes
/
Copy pathgit-project
File metadata and controls
executable file
·35 lines (32 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env ruby
require 'socket'
def check_ssh_config
if `grep -c id_github_current config`.to_i == 0
puts <<-WARNING
You must edit your .ssh/config file to include:
Host github.com
User git
IdentityFile /Users/pivotal/.ssh/id_github_current
WARNING
end
end
project = ARGV[0] || Dir.pwd.split('/').last
hostname = Socket.gethostname.split('.').first
possible_id_files = [
"id_#{hostname}_github_pivotal#{project}",
"id_github_pivotal#{project}",
"id_github_#{project}"
]
Dir.chdir(File.expand_path('~/.ssh')) do
possible_id_files.each do |id_file|
if File.exists?(id_file)
`ln -sf #{id_file} id_github_current`
puts "Now using key #{id_file}"
check_ssh_config
exit 0
end
end
puts "Key not found. You must create a ssh key in ~/.ssh/ called " +
possible_id_files[0..-2].join(", ") +
" or #{possible_id_files[-1]}"
end