diff options
author | Nick Thomas <nick@gitlab.com> | 2018-01-12 13:26:03 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-01-12 13:38:06 +0000 |
commit | 73e2cf531ca8b92dc48da5024c8095256aa10818 (patch) | |
tree | e9062e256967e9782527b4e032be7c44d60e388b /bin | |
parent | f8f314890758983e9d167529cb3a332a01262d5c (diff) | |
download | gitlab-shell-73e2cf531ca8b92dc48da5024c8095256aa10818.tar.gz |
Remove the GitlabProjects implementation
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/create-hooks | 26 | ||||
-rwxr-xr-x | bin/gitlab-projects | 29 |
2 files changed, 24 insertions, 31 deletions
diff --git a/bin/create-hooks b/bin/create-hooks index d4111dc..e8b53c1 100755 --- a/bin/create-hooks +++ b/bin/create-hooks @@ -5,16 +5,38 @@ # This script is used when restoring a GitLab backup. require_relative '../lib/gitlab_init' -require File.join(ROOT_PATH, 'lib', 'gitlab_projects') require File.join(ROOT_PATH, 'lib', 'gitlab_metrics') +def create_hooks(path) + global_hooks_directory = File.join(ROOT_PATH, 'hooks') + local_hooks_directory = File.join(path, 'hooks') + real_local_hooks_directory = :not_found + + begin + real_local_hooks_directory = File.realpath(local_hooks_directory) + rescue Errno::ENOENT + # real_local_hooks_directory == :not_found + end + + if real_local_hooks_directory != File.realpath(global_hooks_directory) + if File.exist?(local_hooks_directory) + $logger.info "Moving existing hooks directory and symlinking global hooks directory for #{path}." + FileUtils.mv(local_hooks_directory, "#{local_hooks_directory}.old.#{Time.now.to_i}") + end + FileUtils.ln_sf(global_hooks_directory, local_hooks_directory) + else + $logger.info "Hooks already exist for #{path}." + true + end +end + repository_storage_paths = ARGV repository_storage_paths.each do |repo_path| Dir["#{repo_path.chomp('/')}/**/*.git"].each do |repo| begin GitlabMetrics.measure('command-create-hooks') do - GitlabProjects.create_hooks(repo) + create_hooks(repo) end rescue Errno::ENOENT # The user must have deleted their repository. Ignore. diff --git a/bin/gitlab-projects b/bin/gitlab-projects deleted file mode 100755 index 22b0022..0000000 --- a/bin/gitlab-projects +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env ruby - - -require_relative '../lib/gitlab_init' - -# -# GitLab Projects shell. Add/remove projects from /home/git/repositories -# -# Ex. -# /bin/gitlab-projects add-project gitlab/gitlab-ci.git -# -# /bin/gitlab-projects rm-project gitlab/gitlab-ci.git -# -# /bin/gitlab-projects list-projects -# -# /bin/gitlab-projects mv-project gitlab/gitlab-ci.git randx/fork.git -# -# /bin/gitlab-projects fork-project gitlab/gitlab-ci.git randx -# -# /bin/gitlab-projects import-project randx/six.git https://github.com/randx/six.git -# -require File.join(ROOT_PATH, 'lib', 'gitlab_projects') - -# Return non-zero if command execution was not successful -if GitlabProjects.new.exec - exit 0 -else - exit 1 -end |