Skip to content

Instantly share code, notes, and snippets.

@keithrbennett
Last active September 23, 2021 00:50
Show Gist options
  • Save keithrbennett/d026694d25d826f80a37e875190d75a8 to your computer and use it in GitHub Desktop.
Save keithrbennett/d026694d25d826f80a37e875190d75a8 to your computer and use it in GitHub Desktop.
Installs all repos needed for Ruby for Good 2021.
#!/usr/bin/env ruby
REPO_URLS = %w{
https://github.com/rubyforgood/casa
https://github.com/rubyforgood/cep-backend
https://github.com/rubyforgood/cep-ui
https://github.com/rubyforgood/circulate
https://github.com/rubyforgood/human-essentials
https://github.com/rubyforgood/shelter-assist
}
GIT_CLONE_URLS = REPO_URLS.map { |url| url.gsub('https://github.com/', 'git@github.com:') + '.git' }
HTTPS_CLONE_URLS = REPO_URLS.map { |url| url + '.git' }
def repo_name(url)
url.split('/').last.gsub('.git', '')
end
def proj_name_and_url(url)
sprintf("%-20s%s\n", repo_name(url), url)
end
def dump_url_array(urls, caption)
puts "\n\n#{caption}\n\n"
urls.each { |url| puts proj_name_and_url(url) }
end
dump_url_array(REPO_URLS, "Repo URL's:")
dump_url_array(GIT_CLONE_URLS, "Git clone URL's:")
dump_url_array(HTTPS_CLONE_URLS, "HTTPS clone URL's:")
def wrap_in_lines(string)
line = '-' * 80
"#{line}\n#{string.center(80)}\n#{line}\n"
end
def clone_projects(urls)
puts wrap_in_lines('Cloning projects...')
urls.each do |url|
puts wrap_in_lines("Cloning project #{repo_name(url)}...")
`git clone #{url}`
end
end
clone_projects(GIT_CLONE_URLS) # or HTTPS_CLONE_URLS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment