Created
November 11, 2014 11:42
-
-
Save mpdude/13e90dca8171396ce12f to your computer and use it in GitHub Desktop.
Initialize .idea/vcs.xml file with all Git or Mercurial repos below current directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
print <<<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" | |
); | |
$paths = array($root); | |
foreach ($iter as $path => $dir) { | |
if ($dir->isDir() && preg_match('_^\.(/(?:.*))?/\.(git|hg)$_', $path, $matches)) { | |
print ' <mapping directory="$PROJECT_DIR$'.$matches[1].'" vcs="'.($matches[2] == 'hg' ? 'hg4idea' : 'Git').'" />' . "\n"; | |
} | |
} | |
print <<<END | |
</component> | |
</project> | |
END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment