Created
May 4, 2012 00:45
-
-
Save danieljpeter/2590737 to your computer and use it in GitHub Desktop.
remove git files
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
//remove all the files from the local github repo which aren't in the metadata repo (in case these were objects which were deleted in salesforce) | |
//get the an array of each file listings, recursively. Strip off the beginning path from each entry in the array so we can do text comparison | |
$arrMetadata = stripBlanks(str_replace('/home/dpeter/sf/metadata', '', getFilesFromDir('/home/dpeter/sf/metadata'))); | |
$arrGit = stripBlanks(str_replace('/home/dpeter/sf/git/salesforce-metadata', '', getFilesFromDir('/home/dpeter/sf/git/salesforce-metadata'))); | |
//remove array entries in the /.git directory | |
$arrGit = stripGit($arrGit); | |
$arrDeleteFromGit = array(); | |
$fileInGitAndMetadata = false; | |
foreach ($arrGit as $gitFile) { | |
$fileInGitAndMetadata = false; | |
foreach ($arrMetadata as $metadataFile) { | |
if ($gitFile == $metadataFile) { | |
$fileInGitAndMetadata = true; | |
} | |
} | |
if (!$fileInGitAndMetadata) { | |
array_push($arrDeleteFromGit, $gitFile); | |
} | |
} | |
//print_r($arrDeleteFromGit); | |
foreach ($arrDeleteFromGit as $gitFile) { | |
echo shell_exec('git --git-dir=/home/dpeter/sf/git/salesforce-metadata/.git --work-tree=/home/dpeter/sf/git/salesforce-metadata/ rm -r -f /home/dpeter/sf/git/salesforce-metadata'.$gitFile); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment