Skip to content

Instantly share code, notes, and snippets.

@jonico
Last active March 3, 2021 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonico/eed1fca0d4a9bf6ce95286d99aea177b to your computer and use it in GitHub Desktop.
Save jonico/eed1fca0d4a9bf6ce95286d99aea177b to your computer and use it in GitHub Desktop.
Search through all reachable commits in all branches and tags in all repos on GitHub Enterprise Server for a pattern (run it on a backup system)
# Replace the string "Hyrule" with your search pattern - only run on backup system - will take a LOOOONG time to run through
ghe-console -y <<'ENDSCRIPT'
Repository.find_each do |repository|
if repository.active && !repository.empty? then
host,path = GitHub::Routing.lookup_route(repository.nwo)
puts "Processing repo #{repository.nwo} ..."
refs=`git --git-dir=#{path} rev-list --branches --tags | sort | uniq`
refs.each_line do |ref|
if system("git --git-dir=#{path} grep 'Hyrule' #{ref}")
puts "Found pattern in ref #{ref} in repo #{repository.nwo}: "
puts `git --git-dir=#{path} grep 'Hyrule' #{ref}`
end
end
end
end
ENDSCRIPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment