#!/usr/bin/env ruby-2.1

# Recreate GitLab hooks in the Git repositories managed by GitLab.
#
# This script is used when restoring a GitLab backup.

require_relative '../lib/gitlab_init'
require File.join(ROOT_PATH, 'lib', 'gitlab_projects')

Dir["#{GitlabConfig.new.repos_path}/*/*.git"].each do |repo|
  begin
    GitlabProjects.create_hooks(repo)
  rescue Errno::ENOENT
    # The user must have deleted their repository. Ignore.
  end
end
