def update!
      ensure_remotes_directory
      dirty_remotes.each do |_name, remote|
        dir = workspace_of(remote)
        if remote[:path] || path_enabled?(remote)
          if symlink?(dir)
            delete_symlink(dir)
          else
            FileUtils.rm_rf(dir) if File.exist?(dir)
          end
        end
        if remote[:path]
          create_symlink(remote[:path], dir)
        else
          rc_url = remote[:rc_url] || remote[:vault]
          tag = remote[:tag].nil? ? Origen::VersionString.new(remote[:version]) : Origen::VersionString.new(remote[:tag])
          version_file = dir.to_s + '/.current_version'
          begin
            if File.exist?("#{dir}/.initial_populate_successful")
              FileUtils.rm_f(version_file) if File.exist?(version_file)
              rc = RevisionControl.new remote: rc_url, local: dir
              rc.send rc.remotes_method, version: prefix_tag(tag), force: true
              File.open(version_file, 'w') do |f|
                f.write tag
              end
            else
              rc = RevisionControl.new remote: rc_url, local: dir
              rc.send rc.remotes_method, version: prefix_tag(tag), force: true
              FileUtils.touch "#{dir}/.initial_populate_successful"
              File.open(version_file, 'w') do |f|
                f.write tag
              end
            end
          rescue Origen::GitError, Origen::DesignSyncError, Origen::PerforceError  => e
            # If Git failed in the remote, its usually easy to see what the problem is, but now *where* it is.
            # This will prepend the failing remote along with the error from the revision control system,
            # then rethrow the error
            e.message.prepend "When updating remotes for #{remote[:importer].name}: "
            raise e
          end
        end
      end
    end
def update!
      ensure_remotes_directory
      dirty_remotes.each do |_name, remote|
        dir = workspace_of(remote)
        if remote[:path] || path_enabled?(remote)
          if symlink?(dir)
            delete_symlink(dir)
          else
            FileUtils.rm_rf(dir) if File.exist?(dir)
          end
        end
        if remote[:path]
          create_symlink(remote[:path], dir)
        else
          rc_url = remote[:rc_url] || remote[:vault]
          tag = remote[:tag].nil? ? Origen::VersionString.new(remote[:version]) : Origen::VersionString.new(remote[:tag])
          version_file = dir.to_s + '/.current_version'
          begin
            if File.exist?("#{dir}/.initial_populate_successful")
              FileUtils.rm_f(version_file) if File.exist?(version_file)
              rc = RevisionControl.new remote: rc_url, local: dir
              rc.send rc.remotes_method, version: prefix_tag(tag), force: true
              File.open(version_file, 'w') do |f|
                f.write tag
              end
            else
              rc = RevisionControl.new remote: rc_url, local: dir
              rc.send rc.remotes_method, version: prefix_tag(tag), force: true
              FileUtils.touch "#{dir}/.initial_populate_successful"
              File.open(version_file, 'w') do |f|
                f.write tag
              end
            end
          rescue Origen::GitError, Origen::DesignSyncError, Origen::PerforceError  => e
            # If Git failed in the remote, its usually easy to see what the problem is, but now *where* it is.
            # This will prepend the failing remote along with the error from the revision control system,
            # then rethrow the error
            e.message.prepend "When updating remotes for #{remote[:importer].name}: "
            raise e
          end
        end
      end
    end
Makes all dirty remotes clean