Skip to content

Instantly share code, notes, and snippets.

@novomirskoy
Created January 11, 2020 11:41
Show Gist options
  • Save novomirskoy/7b15045d769cb65e36c929ebd58893ab to your computer and use it in GitHub Desktop.
Save novomirskoy/7b15045d769cb65e36c929ebd58893ab to your computer and use it in GitHub Desktop.
Скрипт который добавляет репозитории из директории vendor в PHPStorm
#!/usr/bin/env php
<?php
echo <<<HEAD
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
HEAD;
$iter = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator('.', RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST,
RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
);
foreach ($iter as $path => $dir) {
if ($dir->isDir() && preg_match('_^\.(/(?:.*))?/\.(git|hg)$_', $path, $matches)) {
echo ' <mapping directory="$PROJECT_DIR$'.$matches[1].'" vcs="'.($matches[2] == 'hg' ? 'hg4idea' : 'Git').'" />' . PHP_EOL;
}
}
echo <<<END
</component>
</project>
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment