Created
February 7, 2011 13:34
-
-
Save hotchpotch/814366 to your computer and use it in GitHub Desktop.
git repos create over ssh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
confbase = 'git-ssh-create' | |
init_command = 'git init --bare --shared=true' | |
server = `git config --global #{confbase}.server`.chomp | |
if server.empty? | |
warn "Please set git config server." | |
warn " git config --global #{confbase}.server '[username@]yourserver.example.com'" | |
exit 1 | |
end | |
repos = `git config --global #{confbase}.repos`.chomp | |
if repos.empty? | |
warn "Please set git config repos." | |
warn " git config --global #{confbase}.repos 'var/git/repos/'" | |
exit 1 | |
end | |
full_repos = (repos + '/' + (ARGV[0] || File.basename(Dir.pwd))).gsub('//', '/') + '.git' | |
commands = ["ssh", server, "mkdir -p '#{full_repos}' && cd '#{full_repos}' && #{init_command}"] | |
if system(*commands) | |
warn 'ssh publish successed!' | |
warn 'next:' | |
warn " git remote add origin #{server}:#{full_repos}" | |
warn " git push origin master" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment