lib/open_project/gitolite/gitolite_wrapper/repositories_helper.rb
# Removes the repository path and all parent repositories that are empty
#
# (i.e., if moving foo/bar/repo.git to foo/repo.git, foo/bar remains and is possibly abandoned)
# This moves up from the lowermost point, and deletes all empty directories.
Removes the repository path and all parent repositories that are empty

This moves up from the lowermost point, and deletes all empty directories.
Removes the repository path and all parent repositories that are empty This moves up from the lowermost point and deletes all empty directories .
def clean_repo_dir(path)
      repo_root = OpenProject::Gitolite::GitoliteWrapper.gitolite_global_storage_path
      full_path = File.join(repo_root, path)
      Dir.chdir(repo_root) do
        if File.directory?(full_path)
          logger.info("Deleting obsolete repository #{full_path}")
          OpenProject::Gitolite::Commands.sudo_rm_rf(full_path) 
        end
        parent = Pathname.new(full_path).parent
        loop do
          break unless parent.children(false).empty?
          break if parent == repo_root
          logger.info("#{@action} : Cleaning repository parent #{parent} ... ")
          FileUtils.rmdir(parent)
          parent = parent.parent
        end
      end
    end
def clean_repo_dir ( path ) repo_root = OpenProject :: Gitolite :: GitoliteWrapper . gitolite_global_storage_path full_path = File . join ( repo_root , path ) Dir . chdir ( repo_root ) do if File . directory? ( full_path ) logger . info ( "Deleting obsolete repository #{full_path}" ) OpenProject :: Gitolite :: Commands . sudo_rm_rf ( full_path ) end parent = Pathname . new ( full_path ) . parent loop do break unless parent . children ( false ) . empty? break if parent == repo_root logger . info ( "#{@action} : Cleaning repository parent #{parent} ... " ) FileUtils . rmdir ( parent ) parent = parent . parent end end end
Removes the repository path and all parent repositories that are empty
(i.e., if moving foo/bar/repo.git to foo/repo.git, foo/bar remains and is possibly abandoned)
This moves up from the lowermost point, and deletes all empty directories.
Removes the repository path and all parent repositories that are empty ( i . e . if moving foo / bar / repo . git to foo / repo . git foo / bar remains and is possibly abandoned ) This moves up from the lowermost point and deletes all empty directories .
# If no repository was created, break early #break unless File.directory?(full_path) # Delete the repository project itself. #To prevent error while deleting repos that use SmartHTTP (still need to find why error is produced) #FileUtils.remove_dir(path) # Traverse all parent directories within repositories, # searching for empty project directories. # Stop deletion upon finding a non-empty parent repository # Stop if we're in the project root
path