mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 00:32:41 +01:00
Improve representation of replaced symlinks in Git
Summary: See T584. Git renders these types of changes somewhat unusually. Ensure they are rendered as changes. The fact that a symlink was replaced is not explicitly rendered (e.g., "This path was changed from a symlink to a regular file."), but can be inferred from the 'unix:filemode' property change that will accompany the changeset. We could also make it explicit but this type of change is rare enough that it's probably good enough as-is. Test Plan: - Ran unit test, which previously failed and now passes. - Created a diff which replaces a file with a symlink, verified it rendered a little more sensibly. Reviewers: aravindn, dschleimer, jungejason, nh, tuomaspelkonen Reviewed By: nh CC: aran, goldshlager, nh Differential Revision: 1030
This commit is contained in:
parent
df8c0e5e25
commit
a85e344425
3 changed files with 30 additions and 1 deletions
|
@ -503,8 +503,15 @@ class ArcanistDiffParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($match['new'])) {
|
if (!empty($match['new'])) {
|
||||||
|
// If you replace a symlink with a normal file, git renders the change
|
||||||
|
// as a "delete" of the symlink plus an "add" of the new file. We
|
||||||
|
// prefer to represent this as a change.
|
||||||
|
if ($change->getType() == ArcanistDiffChangeType::TYPE_DELETE) {
|
||||||
|
$change->setType(ArcanistDiffChangeType::TYPE_CHANGE);
|
||||||
|
} else {
|
||||||
$change->setType(ArcanistDiffChangeType::TYPE_ADD);
|
$change->setType(ArcanistDiffChangeType::TYPE_ADD);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($match['old'])) {
|
if (!empty($match['old'])) {
|
||||||
$change->setOldPath($match['old']);
|
$change->setOldPath($match['old']);
|
||||||
|
|
|
@ -487,6 +487,13 @@ EOTEXT
|
||||||
ArcanistDiffChangeType::FILE_BINARY,
|
ArcanistDiffChangeType::FILE_BINARY,
|
||||||
$change->getFileType());
|
$change->getFileType());
|
||||||
break;
|
break;
|
||||||
|
case 'git-replace-symlink.gitdiff':
|
||||||
|
$this->assertEqual(1, count($changes));
|
||||||
|
$change = array_shift($changes);
|
||||||
|
$this->assertEqual(
|
||||||
|
ArcanistDiffChangeType::TYPE_CHANGE,
|
||||||
|
$change->getType());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception("No test block for diff file {$diff_file}.");
|
throw new Exception("No test block for diff file {$diff_file}.");
|
||||||
break;
|
break;
|
||||||
|
|
15
src/parser/diff/__tests__/data/git-replace-symlink.gitdiff
Normal file
15
src/parser/diff/__tests__/data/git-replace-symlink.gitdiff
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
diff --git a/derp b/derp
|
||||||
|
deleted file mode 120000
|
||||||
|
index d6d9d34..0000000
|
||||||
|
--- a/derp
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1 +0,0 @@
|
||||||
|
-blah
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/derp b/derp
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..54a5dbc
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/derp
|
||||||
|
@@ -0,0 +1 @@
|
||||||
|
+derp derp
|
Loading…
Reference in a new issue