Skip to content

Commit

Permalink
Show "Revision URL" in detailed log view instead of a separate column.
Browse files Browse the repository at this point in the history
  • Loading branch information
aik099 committed Apr 12, 2024
1 parent 735070f commit 5bb488e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 38 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Added `--preview` option to the `merge` command to display revisions, that will be merged instead of merging them.
- Added the `changelog` command, that will show changes included in the current SVN-Buddy release.
- Added `--author` option to the `log` command to display revisions, made by a specific author.
- Added `--with-revision-url` option to the `log` command to display URL (Phabricator only for now) for each shown revision.
- Show revision URL (Phabricator only for now) for each shown revision of the `log` command, when `--with-details` option is used.
- Sends a beep to the Terminal, when an error occurs during any command execution.

### Changed
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ The working copy revision row is highlighted in bold in revision list to ease id
* `--with-refs` - Shows revision refs
* `--with-merge-oracle` - Shows number of paths in the revision, that can cause conflict upon merging
* `--with-merge-status` - Shows merge revisions affecting this revision
* `--with-revision-url` - Shows revision URL
* `--max-count=MAX-COUNT` - Limit the number of revisions to output
* `-a`, `--aggregate` - Aggregate displayed revisions by bugs

Expand Down Expand Up @@ -701,7 +700,6 @@ Runs other command sequentially on every working copy on a path. Almost all othe
* `--with-refs` - Shows revision refs
* `--with-merge-oracle` - Shows number of paths in the revision, that can cause conflict upon merging
* `--with-merge-status` - Shows merge revisions affecting this revision
* `--with-revision-url` - Shows revision URL
* `--max-count=MAX-COUNT` - Limit the number of revisions to output
* `--ignore-externals` - Ignore externals definitions
* `--refresh-bug-tracking` - Refreshes value of "bugtraq:logregex" SVN property of the project
Expand Down
10 changes: 1 addition & 9 deletions src/SVNBuddy/Command/LogCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,6 @@ protected function configure()
InputOption::VALUE_NONE,
'Shows merge revisions affecting this revision'
)
->addOption(
'with-revision-url',
null,
InputOption::VALUE_NONE,
'Shows revision URL'
)
->addOption(
'max-count',
null,
Expand Down Expand Up @@ -602,7 +596,6 @@ protected function printRevisions(array $revisions)
'with-refs' => RevisionPrinter::COLUMN_REFS,
'with-merge-oracle' => RevisionPrinter::COLUMN_MERGE_ORACLE,
'with-merge-status' => RevisionPrinter::COLUMN_MERGE_STATUS,
'with-revision-url' => RevisionPrinter::COLUMN_REVISION_URL,
);

foreach ( $column_mapping as $option_name => $column ) {
Expand Down Expand Up @@ -653,8 +646,7 @@ public function getAggregatedOptions()
return array(
'merges', 'no-merges', 'merged', 'not-merged', 'action',
'kind', 'author', 'with-full-message', 'with-details', 'with-summary',
'with-refs', 'with-merge-oracle', 'with-merge-status', 'with-revision-url',
'max-count',
'with-refs', 'with-merge-oracle', 'with-merge-status', 'max-count',
);
}

Expand Down
46 changes: 20 additions & 26 deletions src/SVNBuddy/Repository/RevisionLog/RevisionPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class RevisionPrinter

const COLUMN_MERGE_STATUS = 6;

const COLUMN_REVISION_URL = 7;

/**
* Date helper.
*
Expand Down Expand Up @@ -218,22 +216,6 @@ public function printRevisions(RevisionLog $revision_log, array $revisions, Outp
$headers[] = 'Merged Via';
}

// Add "Revision URL" header.
$with_revision_url = in_array(self::COLUMN_REVISION_URL, $this->_columns);

if ( $with_revision_url ) {
$revision_url_mask = $revision_log->getRevisionURLBuilder()->getMask();

if ( strpos($revision_url_mask, '://') !== false ) {
// Add column only, when it will contain a URL.
$headers[] = 'Revision URL';
}
else {
// Don't add the column, when it won't contain a URL.
$with_revision_url = false;
}
}

$table->setHeaders($headers);

$prev_bugs = null;
Expand Down Expand Up @@ -263,6 +245,13 @@ public function printRevisions(RevisionLog $revision_log, array $revisions, Outp
);
}

$revision_url_mask = $revision_log->getRevisionURLBuilder()->getMask();

// Use mask only, when it contains an URL.
if ( strpos($revision_url_mask, '://') === false ) {
$revision_url_mask = '';
}

$first_revision = reset($revisions);

foreach ( $revisions as $revision ) {
Expand Down Expand Up @@ -311,11 +300,6 @@ public function printRevisions(RevisionLog $revision_log, array $revisions, Outp
$row[] = $this->_generateMergedViaColumn($revisions_merged_via[$revision], $revisions_merged_via_refs);
}

// Add "Revision URL" header.
if ( $with_revision_url ) {
$row[] = \str_replace('{revision}', $revision, $revision_url_mask);
}

if ( $revision === $this->_currentRevision ) {
foreach ( $row as $index => $cell ) {
$row[$index] = $this->applyStyle($cell, 'fg=white;options=bold');
Expand All @@ -334,7 +318,8 @@ public function printRevisions(RevisionLog $revision_log, array $revisions, Outp
$revisions_refs,
$revision_paths,
$merge_conflict_prediction,
$project_path
$project_path,
$revision_url_mask
);

$table->addRow(new TableSeparator());
Expand Down Expand Up @@ -558,6 +543,7 @@ private function _generateMergedViaColumn(array $merged_via, array $revisions_me
* @param array $revision_paths Revision paths.
* @param array $merge_conflict_prediction Merge conflict prediction.
* @param string $project_path Project path.
* @param string $revision_url_mask Revision URL mask.
*
* @return string
*/
Expand All @@ -566,9 +552,17 @@ private function _generateDetailsRowContent(
array $revisions_refs,
array $revision_paths,
array $merge_conflict_prediction,
$project_path
$project_path,
$revision_url_mask
) {
$details = '<fg=white;options=bold>Changed Paths:</>';
$details = '';

if ( $revision_url_mask ) {
$details .= '<fg=white;options=bold>Revision URL:</>' . PHP_EOL;
$details .= str_replace('{revision}', $revision, $revision_url_mask) . PHP_EOL . PHP_EOL;
}

$details .= '<fg=white;options=bold>Changed Paths:</>';
$path_cut_off_regexp = $this->getPathCutOffRegExp($project_path, $revisions_refs[$revision]);

foreach ( $revision_paths as $path_data ) {
Expand Down

0 comments on commit 5bb488e

Please sign in to comment.