VersionPress\Utils\FileSystem::possiblyFixGitPermissions PHP Method

possiblyFixGitPermissions() private static method

Git for Windows makes files in .git/objects read-only. This method removes the flag so that operations like removing the folder work.
private static possiblyFixGitPermissions ( string $path )
$path string Either path to `.git` itself or its parent directory (repo root)
    private static function possiblyFixGitPermissions($path)
    {
        if (DIRECTORY_SEPARATOR == '/') {
            return;
        }
        $gitDir = null;
        if (is_dir($path)) {
            if (basename($path) == '.git') {
                $gitDir = $path;
            } else {
                if (is_dir($path . '/.git')) {
                    $gitDir = $path . '/.git';
                }
            }
        }
        if ($gitDir) {
            $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($gitDir . '/objects', FilesystemIterator::SKIP_DOTS));
            foreach ($iterator as $item) {
                if (is_file($item)) {
                    chmod($item, 0640);
                }
            }
        }
    }