Last active
August 29, 2015 14:23
-
-
Save brandoncc/1e7612b371b944d7c749 to your computer and use it in GitHub Desktop.
This file contains 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
# I wrote this script because I had a bunch of heroku apps on my account that I didn't know what | |
# local apps they matched. Just search the heroku app name and this script will find the local | |
# app for you. | |
# | |
# Feel free to use and alter this script as much as you want. | |
unless ARGV[0] | |
fail 'You pust provide repo name to search for' | |
end | |
repo_text = ARGV[0] | |
search_path = ARGV[1] || '~' | |
found_files = [] | |
system 'clear' or system 'cls' | |
puts "Finding git configuration directories in #{search_path}" | |
directories = `find #{search_path} -d -name '.git'`.split("\n") | |
files = directories.map { |d| "#{d}/config" if File.exists?("#{d}/config") }.compact | |
files.each do |file| | |
contents = IO.read(file) | |
if contents.match(/^\s*url\s*=[^\n]*#{Regexp.quote(repo_text)}/) | |
found_files << file | |
end | |
end | |
if found_files.count > 0 | |
puts "The local repos which match the remote repo text provided are:" | |
found_files.each do |file| | |
puts File.expand_path('../..', file) | |
end | |
else | |
puts "No repos found" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment