mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 05:50:55 +01:00
Open editor on first modified line
Test Plan: Created diff, opened the file from Differential, opened the file in Diffusion. Reviewers: btrahan, epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3538
This commit is contained in:
parent
cad1eed24a
commit
e0e97b08b8
3 changed files with 16 additions and 4 deletions
|
@ -136,6 +136,7 @@ final class DifferentialDiff extends DifferentialDAO {
|
|||
$changeset = new DifferentialChangeset();
|
||||
$add_lines = 0;
|
||||
$del_lines = 0;
|
||||
$first_line = PHP_INT_MAX;
|
||||
$hunks = $change->getHunks();
|
||||
if ($hunks) {
|
||||
foreach ($hunks as $hunk) {
|
||||
|
@ -148,6 +149,10 @@ final class DifferentialDiff extends DifferentialDAO {
|
|||
$changeset->addUnsavedHunk($dhunk);
|
||||
$add_lines += $hunk->getAddLines();
|
||||
$del_lines += $hunk->getDelLines();
|
||||
$added_lines = $hunk->getChangedLines('new');
|
||||
if ($added_lines) {
|
||||
$first_line = min($first_line, head_key($added_lines));
|
||||
}
|
||||
}
|
||||
$lines += $add_lines + $del_lines;
|
||||
} else {
|
||||
|
@ -155,12 +160,17 @@ final class DifferentialDiff extends DifferentialDAO {
|
|||
$changeset->attachHunks(array());
|
||||
}
|
||||
|
||||
$metadata = $change->getAllMetadata();
|
||||
if ($first_line != PHP_INT_MAX) {
|
||||
$metadata['line:first'] = $first_line;
|
||||
}
|
||||
|
||||
$changeset->setOldFile($change->getOldPath());
|
||||
$changeset->setFilename($change->getCurrentPath());
|
||||
$changeset->setChangeType($change->getType());
|
||||
|
||||
$changeset->setFileType($change->getFileType());
|
||||
$changeset->setMetadata($change->getAllMetadata());
|
||||
$changeset->setMetadata($metadata);
|
||||
$changeset->setOldProperties($change->getOldProperties());
|
||||
$changeset->setNewProperties($change->getNewProperties());
|
||||
$changeset->setAwayPaths($change->getAwayPaths());
|
||||
|
|
|
@ -256,7 +256,8 @@ final class DifferentialChangesetListView extends AphrontView {
|
|||
$repository = $this->repository;
|
||||
if ($repository) {
|
||||
$meta['diffusionURI'] = (string)$repository->getDiffusionBrowseURIForPath(
|
||||
$changeset->getAbsoluteRepositoryPath($repository, $this->diff));
|
||||
$changeset->getAbsoluteRepositoryPath($repository, $this->diff),
|
||||
idx($changeset->getMetadata(), 'line:first'));
|
||||
}
|
||||
|
||||
$change = $changeset->getChangeType();
|
||||
|
@ -283,7 +284,7 @@ final class DifferentialChangesetListView extends AphrontView {
|
|||
$path = ltrim(
|
||||
$changeset->getAbsoluteRepositoryPath($repository, $this->diff),
|
||||
'/');
|
||||
$line = 1; // TODO: get first changed line
|
||||
$line = idx($changeset->getMetadata(), 'line:first', 1);
|
||||
$callsign = $repository->getCallsign();
|
||||
$editor_link = $user->loadEditorLink($path, $line, $callsign);
|
||||
if ($editor_link) {
|
||||
|
|
|
@ -60,7 +60,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getDiffusionBrowseURIForPath($path) {
|
||||
public function getDiffusionBrowseURIForPath($path, $line = null) {
|
||||
$drequest = DiffusionRequest::newFromDictionary(
|
||||
array(
|
||||
'repository' => $this,
|
||||
|
@ -70,6 +70,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO {
|
|||
return $drequest->generateURI(
|
||||
array(
|
||||
'action' => 'browse',
|
||||
'line' => $line,
|
||||
));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue