@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Don't pass "No newline at end of file." annotations to DocumentEngines as literal diff text

Summary: See PHI1707, which has a Jupyter notebook which fails to diff nicely when modified. The root cause seems to be that the document does not end in a newline.

Test Plan: Applied patch, diffed the file, got a Jupyter diff out of it.

Differential Revision: https://secure.phabricator.com/D21159

+18 -8
+18 -8
src/applications/differential/parser/DifferentialChangesetParser.php
··· 1714 1714 if ($old_file) { 1715 1715 $old_ref->setFile($old_file); 1716 1716 } else { 1717 - $old_data = $this->old; 1718 - $old_data = ipull($old_data, 'text'); 1719 - $old_data = implode('', $old_data); 1720 - 1717 + $old_data = $this->getRawDocumentEngineData($this->old); 1721 1718 $old_ref->setData($old_data); 1722 1719 } 1723 1720 } ··· 1730 1727 if ($new_file) { 1731 1728 $new_ref->setFile($new_file); 1732 1729 } else { 1733 - $new_data = $this->new; 1734 - $new_data = ipull($new_data, 'text'); 1735 - $new_data = implode('', $new_data); 1736 - 1730 + $new_data = $this->getRawDocumentEngineData($this->new); 1737 1731 $new_ref->setData($new_data); 1738 1732 } 1739 1733 } ··· 1901 1895 return id(new PhabricatorChangesetResponse()) 1902 1896 ->setRenderedChangeset($rendered_changeset) 1903 1897 ->setChangesetState($state); 1898 + } 1899 + 1900 + private function getRawDocumentEngineData(array $lines) { 1901 + $text = array(); 1902 + 1903 + foreach ($lines as $line) { 1904 + // If this is a "No newline at end of file." annotation, don't hand it 1905 + // off to the DocumentEngine. 1906 + if ($line['type'] == '\\') { 1907 + continue; 1908 + } 1909 + 1910 + $text[] = $line['text']; 1911 + } 1912 + 1913 + return implode('', $text); 1904 1914 } 1905 1915 1906 1916 }