diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index a23254aa3c..5c71e0d2de 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -163,6 +163,7 @@ phutil_register_library_map(array( 'DiffusionFileContentQuery' => 'applications/diffusion/query/filecontent/base', 'DiffusionGitBranchQuery' => 'applications/diffusion/query/branch/git', 'DiffusionGitBrowseQuery' => 'applications/diffusion/query/browse/git', + 'DiffusionGitDiffQuery' => 'applications/diffusion/query/diff/git', 'DiffusionGitFileContentQuery' => 'applications/diffusion/query/filecontent/git', 'DiffusionGitHistoryQuery' => 'applications/diffusion/query/history/git', 'DiffusionGitPathIDQuery' => 'applications/diffusion/query/pathid/base', @@ -531,6 +532,7 @@ phutil_register_library_map(array( 'DiffusionDiffController' => 'DiffusionController', 'DiffusionGitBranchQuery' => 'DiffusionBranchQuery', 'DiffusionGitBrowseQuery' => 'DiffusionBrowseQuery', + 'DiffusionGitDiffQuery' => 'DiffusionDiffQuery', 'DiffusionGitFileContentQuery' => 'DiffusionFileContentQuery', 'DiffusionGitHistoryQuery' => 'DiffusionHistoryQuery', 'DiffusionGitRequest' => 'DiffusionRequest', diff --git a/src/applications/diffusion/query/diff/git/DiffusionGitDiffQuery.php b/src/applications/diffusion/query/diff/git/DiffusionGitDiffQuery.php new file mode 100644 index 0000000000..38245cb4ba --- /dev/null +++ b/src/applications/diffusion/query/diff/git/DiffusionGitDiffQuery.php @@ -0,0 +1,61 @@ +getRequest(); + $repository = $drequest->getRepository(); + + $options = array( + '-M', + '-C', + '--no-ext-diff', + '--no-color', + '--src-prefix=a/', + '--dst-prefix=b/', + '-U65535', + ); + $options = implode(' ', $options); + + list($raw_diff) = execx( + "(cd %s && git diff {$options} %s^ %s -- %s)", + $repository->getDetail('local-path'), + $drequest->getCommit(), + $drequest->getCommit(), + $drequest->getPath()); + + $parser = new ArcanistDiffParser(); + $parser->setDetectBinaryFiles(true); + $changes = $parser->parseDiff($raw_diff); + + $diff = DifferentialDiff::newFromRawChanges($changes); + $changesets = $diff->getChangesets(); + $changeset = reset($changesets); + + $id = + $drequest->getBranch().'/'. + $drequest->getPath().';'. + $drequest->getCommit(); + + $changeset->setID($id); + + return $changeset; + } + +} diff --git a/src/applications/diffusion/query/diff/git/__init__.php b/src/applications/diffusion/query/diff/git/__init__.php new file mode 100644 index 0000000000..3a9b21da1f --- /dev/null +++ b/src/applications/diffusion/query/diff/git/__init__.php @@ -0,0 +1,17 @@ +