1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +01:00

Teach Commit View about Encoding

Summary:
If the user specifies a text encoding via the "View Options" dropdown, respect this choice.
Ref Q68.

Test Plan: Play with the Encoding button in the view

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tinloaf, speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25360
This commit is contained in:
Aviv Eyal 2023-08-31 10:55:13 -07:00
parent 94c0774d80
commit 69c64c1e83
2 changed files with 7 additions and 3 deletions

View file

@ -23,6 +23,7 @@ final class DiffusionDiffQueryConduitAPIMethod
return array( return array(
'path' => 'required string', 'path' => 'required string',
'commit' => 'optional string', 'commit' => 'optional string',
'encoding' => 'optional string',
); );
} }
@ -212,18 +213,20 @@ final class DiffusionDiffQueryConduitAPIMethod
return $this->getEmptyResult(); return $this->getEmptyResult();
} }
$parser = $this->getDefaultParser(); $parser = $this->getDefaultParser($request);
$changes = $parser->parseDiff($raw_diff); $changes = $parser->parseDiff($raw_diff);
return $changes; return $changes;
} }
private function getDefaultParser() { private function getDefaultParser(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest(); $drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository(); $repository = $drequest->getRepository();
$parser = new ArcanistDiffParser(); $parser = new ArcanistDiffParser();
$try_encoding = $repository->getDetail('encoding'); $try_encoding = coalesce(
$request->getValue('encoding'),
$repository->getDetail('encoding'));
if ($try_encoding) { if ($try_encoding) {
$parser->setTryEncoding($try_encoding); $parser->setTryEncoding($try_encoding);
} }

View file

@ -48,6 +48,7 @@ final class DiffusionDiffController extends DiffusionController {
array( array(
'commit' => $drequest->getCommit(), 'commit' => $drequest->getCommit(),
'path' => $drequest->getPath(), 'path' => $drequest->getPath(),
'encoding' => $request->getStr('encoding'),
)); ));
$drequest->updateSymbolicCommit($data['effectiveCommit']); $drequest->updateSymbolicCommit($data['effectiveCommit']);
$raw_changes = ArcanistDiffChange::newFromConduit($data['changes']); $raw_changes = ArcanistDiffChange::newFromConduit($data['changes']);