lib/open_project/gitolite/gitolite_wrapper/repositories_helper.rb
# Move a repository in gitolite-admin from its old entry to a new one
#
# This involves the following steps:
# 1. Remove the old entry (+old_name+)
# 2. Move the physical repository on filesystem.
# 3. Add the repository using +repo.gitolite_repository_name+
#
Move a repository in gitolite-admin from its old entry to a new one
This involves the following steps:
1. Remove the old entry (+old_name+)
2. Move the physical repository on filesystem.
3. Add the repository using +repo.gitolite_repository_name+
Move a repository in gitolite - admin from its old entry to a new one This involves the following steps : 1 . Remove the old entry ( + old_name + ) 2 . Move the physical repository on filesystem . 3 . Add the repository using + repo . gitolite_repository_name +
def do_move_repository(repo, old_path, old_name)
      gitolite_repos_root = OpenProject::Gitolite::GitoliteWrapper.gitolite_global_storage_path
      new_path  = repo.managed_repository_path
      new_relative_path = Pathname.new(new_path).relative_path_from(Pathname.new(gitolite_repos_root))
      if File.dirname(new_path).to_s == gitolite_repos_root.to_s.chomp("/")
        new_name = File.basename(new_relative_path.to_s, '.git')
      else
        new_name = File.join(File.dirname(new_relative_path.to_s), File.basename(new_relative_path.to_s, '.git'))
      end
      logger.info("#{@action} : Moving '#{old_name}' -> '#{new_name}'")
      logger.debug("-- On filesystem, this means '#{old_path}' -> '#{new_path}'")
      @gitolite_config.rm_repo(old_name)
      if move_physical_repo(old_path, old_name, new_path, new_name, true)
        repo.url = new_path
        repo.root_url = new_path
        repo.save
        handle_repository_add(repo)
      end
    end
def do_move_repository ( repo , old_path , old_name ) gitolite_repos_root = OpenProject :: Gitolite :: GitoliteWrapper . gitolite_global_storage_path new_path = repo . managed_repository_path new_relative_path = Pathname . new ( new_path ) . relative_path_from ( Pathname . new ( gitolite_repos_root ) ) if File . dirname ( new_path ) . to_s == gitolite_repos_root . to_s . chomp ( "/" ) new_name = File . basename ( new_relative_path . to_s , '.git' ) else new_name = File . join ( File . dirname ( new_relative_path . to_s ) , File . basename ( new_relative_path . to_s , '.git' ) ) end logger . info ( "#{@action} : Moving '#{old_name}' -> '#{new_name}'" ) logger . debug ( "-- On filesystem, this means '#{old_path}' -> '#{new_path}'" ) @gitolite_config . rm_repo ( old_name ) if move_physical_repo ( old_path , old_name , new_path , new_name , true ) repo . url = new_path repo . root_url = new_path repo . save handle_repository_add ( repo ) end end
Move a repository in gitolite-admin from its old entry to a new one
This involves the following steps:
1.
Move a repository in gitolite - admin from its old entry to a new one This involves the following steps : 1 .
# Build the path (where the repo should be) from the project's settings # Remove old config entry in Gitolite # Move the repo on filesystem # Add the repo as new in Gitolite
repo
old_path
old_name