Skip to content

Commit 69c64c1

Browse files
committed
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
1 parent 94c0774 commit 69c64c1

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/applications/diffusion/conduit/DiffusionDiffQueryConduitAPIMethod.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ protected function defineCustomParamTypes() {
2323
return array(
2424
'path' => 'required string',
2525
'commit' => 'optional string',
26+
'encoding' => 'optional string',
2627
);
2728
}
2829

@@ -212,18 +213,20 @@ private function getGitOrMercurialResult(ConduitAPIRequest $request) {
212213
return $this->getEmptyResult();
213214
}
214215

215-
$parser = $this->getDefaultParser();
216+
$parser = $this->getDefaultParser($request);
216217
$changes = $parser->parseDiff($raw_diff);
217218

218219
return $changes;
219220
}
220221

221-
private function getDefaultParser() {
222+
private function getDefaultParser(ConduitAPIRequest $request) {
222223
$drequest = $this->getDiffusionRequest();
223224
$repository = $drequest->getRepository();
224225

225226
$parser = new ArcanistDiffParser();
226-
$try_encoding = $repository->getDetail('encoding');
227+
$try_encoding = coalesce(
228+
$request->getValue('encoding'),
229+
$repository->getDetail('encoding'));
227230
if ($try_encoding) {
228231
$parser->setTryEncoding($try_encoding);
229232
}

src/applications/diffusion/controller/DiffusionDiffController.php

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function handleRequest(AphrontRequest $request) {
4848
array(
4949
'commit' => $drequest->getCommit(),
5050
'path' => $drequest->getPath(),
51+
'encoding' => $request->getStr('encoding'),
5152
));
5253
$drequest->updateSymbolicCommit($data['effectiveCommit']);
5354
$raw_changes = ArcanistDiffChange::newFromConduit($data['changes']);

0 commit comments

Comments
 (0)