From 5bb488e156698441c10069e4e121e64ef73005ee Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 12 Apr 2024 10:45:48 +0300 Subject: [PATCH] Show "Revision URL" in detailed log view instead of a separate column. --- CHANGELOG.md | 2 +- README.md | 2 - src/SVNBuddy/Command/LogCommand.php | 10 +--- .../RevisionLog/RevisionPrinter.php | 46 ++++++++----------- 4 files changed, 22 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4396ac6..2270e5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index b7464c7..64428cd 100755 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/src/SVNBuddy/Command/LogCommand.php b/src/SVNBuddy/Command/LogCommand.php index 3c3aef2..d0be0e8 100644 --- a/src/SVNBuddy/Command/LogCommand.php +++ b/src/SVNBuddy/Command/LogCommand.php @@ -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, @@ -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 ) { @@ -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', ); } diff --git a/src/SVNBuddy/Repository/RevisionLog/RevisionPrinter.php b/src/SVNBuddy/Repository/RevisionLog/RevisionPrinter.php index e7d603b..5d3f946 100644 --- a/src/SVNBuddy/Repository/RevisionLog/RevisionPrinter.php +++ b/src/SVNBuddy/Repository/RevisionLog/RevisionPrinter.php @@ -33,8 +33,6 @@ class RevisionPrinter const COLUMN_MERGE_STATUS = 6; - const COLUMN_REVISION_URL = 7; - /** * Date helper. * @@ -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; @@ -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 ) { @@ -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'); @@ -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()); @@ -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 */ @@ -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 = 'Changed Paths:'; + $details = ''; + + if ( $revision_url_mask ) { + $details .= 'Revision URL:' . PHP_EOL; + $details .= str_replace('{revision}', $revision, $revision_url_mask) . PHP_EOL . PHP_EOL; + } + + $details .= 'Changed Paths:'; $path_cut_off_regexp = $this->getPathCutOffRegExp($project_path, $revisions_refs[$revision]); foreach ( $revision_paths as $path_data ) {