return implode("\n", $summary);
}
+ public function getSymlinkTarget() {
+ if ($this->getFileType() != ArcanistDiffChangeType::FILE_SYMLINK) {
+ throw new Exception("Not a symlink!");
+ }
+ $hunks = $this->getHunks();
+ $hunk = reset($hunks);
+ $corpus = $hunk->getCorpus();
+ $match = null;
+ if (!preg_match('/^\+(?:link )?(.*)$/m', $corpus, $match)) {
+ throw new Exception("Failed to extract link target!");
+ }
+ return trim($match[1]);
+ }
}
$patches = array();
$propset = array();
$adds = array();
+ $symlinks = array();
$changes = $bundle->getChanges();
foreach ($changes as $change) {
$type = $change->getType();
$should_patch = true;
+
+ $filetype = $change->getFileType();
+ switch ($filetype) {
+ case ArcanistDiffChangeType::FILE_SYMLINK:
+ $should_patch = false;
+ $symlinks[] = $change;
+ break;
+ }
+
switch ($type) {
case ArcanistDiffChangeType::TYPE_MOVE_AWAY:
case ArcanistDiffChangeType::TYPE_MULTICOPY:
$delete));
}
+ foreach ($symlinks as $symlink) {
+ $link_target = $symlink->getSymlinkTarget();
+ $link_path = $symlink->getCurrentPath();
+ switch ($symlink->getType()) {
+ case ArcanistDiffChangeType::TYPE_ADD:
+ case ArcanistDiffChangeType::TYPE_MODIFY:
+ case ArcanistDiffChangeType::TYPE_MOVE_HERE:
+ case ArcanistDiffChangeType::TYPE_COPY_HERE:
+ execx(
+ '(cd %s && ln -sf %s %s)',
+ $repository_api->getPath(),
+ $link_target,
+ $link_path);
+ break;
+ }
+ }
+
foreach ($patches as $path => $patch) {
$tmp = new TempFile();
Filesystem::writeFile($tmp, $patch);