mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 03:50:54 +01:00
Convert "falsey" binary hunks if we have a repository encoding
Summary: This adds an encoding detail to the repository, so we can attempt to convert hunks previously detected as binary. We also add the encoding information to the arcanist projectinfo API so we can pull the information if we have it when uploading changes via arc. Test Plan: Changed encoding through the edit UI, and saw "This is binary file", and changed it back and saw the correct output from the diff. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: 1009
This commit is contained in:
parent
c20608f066
commit
4e900c096f
5 changed files with 39 additions and 0 deletions
|
@ -67,6 +67,7 @@ class ConduitAPI_arcanist_projectinfo_Method
|
|||
'phid' => $project->getPHID(),
|
||||
'repositoryPHID' => $repository_phid,
|
||||
'tracked' => $tracked,
|
||||
'encoding' => $repository->getDetail('encoding')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,12 @@ final class DiffusionGitDiffQuery extends DiffusionDiffQuery {
|
|||
}
|
||||
|
||||
$parser = new ArcanistDiffParser();
|
||||
|
||||
$try_encoding = $repository->getDetail('encoding');
|
||||
if ($try_encoding) {
|
||||
$parser->setTryEncoding($try_encoding);
|
||||
}
|
||||
|
||||
$parser->setDetectBinaryFiles(true);
|
||||
$changes = $parser->parseDiff($raw_diff);
|
||||
|
||||
|
|
|
@ -38,6 +38,12 @@ final class DiffusionMercurialDiffQuery extends DiffusionDiffQuery {
|
|||
$path);
|
||||
|
||||
$parser = new ArcanistDiffParser();
|
||||
|
||||
$try_encoding = $repository->getDetail('encoding');
|
||||
if ($try_encoding) {
|
||||
$parser->setTryEncoding($try_encoding);
|
||||
}
|
||||
|
||||
$parser->setDetectBinaryFiles(true);
|
||||
$changes = $parser->parseDiff($raw_diff);
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ final class DiffusionSvnDiffQuery extends DiffusionDiffQuery {
|
|||
|
||||
protected function executeQuery() {
|
||||
$drequest = $this->getRequest();
|
||||
$repository = $drequest->getRepository();
|
||||
|
||||
if (!$drequest->getRawCommit()) {
|
||||
$effective_commit = $this->getEffectiveCommit();
|
||||
|
@ -111,6 +112,12 @@ final class DiffusionSvnDiffQuery extends DiffusionDiffQuery {
|
|||
$raw_diff = $engine->generateRawDiffFromFileContent($old_data, $new_data);
|
||||
|
||||
$parser = new ArcanistDiffParser();
|
||||
|
||||
$try_encoding = $repository->getDetail('encoding');
|
||||
if ($try_encoding) {
|
||||
$parser->setTryEncoding($try_encoding);
|
||||
}
|
||||
|
||||
$parser->setDetectBinaryFiles(true);
|
||||
|
||||
$arcanist_changes = DiffusionPathChange::convertToArcanistChanges(
|
||||
|
|
|
@ -113,6 +113,7 @@ class PhabricatorRepositoryEditController
|
|||
}
|
||||
|
||||
$repository->setDetail('description', $request->getStr('description'));
|
||||
$repository->setDetail('encoding', $request->getStr('encoding'));
|
||||
|
||||
if (!$errors) {
|
||||
$repository->save();
|
||||
|
@ -134,6 +135,9 @@ class PhabricatorRepositoryEditController
|
|||
'Repository changes were saved.');
|
||||
}
|
||||
|
||||
$encoding_doc_link = PhabricatorEnv::getDoclink(
|
||||
'article/User_Guide:_UTF-8_and_Character_Encoding.html');
|
||||
|
||||
$form = new AphrontFormView();
|
||||
$form
|
||||
->setUser($user)
|
||||
|
@ -156,6 +160,21 @@ class PhabricatorRepositoryEditController
|
|||
->setLabel('Callsign')
|
||||
->setName('callsign')
|
||||
->setValue($repository->getCallsign()))
|
||||
->appendChild('
|
||||
<p class="aphront-form-instructions">'.
|
||||
'If source code in this repository uses a character '.
|
||||
'encoding other than UTF-8 (for example, ISO-8859-1), '.
|
||||
'specify it here. You can usually leave this field blank. '.
|
||||
'See User Guide: '.
|
||||
'<a href="'.$encoding_doc_link.'">'.
|
||||
'UTF-8 and Character Encoding'.
|
||||
'</a> for more information.'.
|
||||
'</p>')
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel('Encoding')
|
||||
->setName('encoding')
|
||||
->setValue($repository->getDetail('encoding')))
|
||||
->appendChild(
|
||||
id(new AphrontFormStaticControl())
|
||||
->setLabel('Type')
|
||||
|
|
Loading…
Reference in a new issue