You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by tm...@apache.org on 2020/07/10 07:26:06 UTC

[netbeans] branch master updated: [NETBEANS-4507] Fix Composer search when package has no description

This is an automated email from the ASF dual-hosted git repository.

tmysik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 191c35f  [NETBEANS-4507] Fix Composer search when package has no description
     new 747e0c4  Merge pull request #2245 from KacerCZ/netbeans-4507-fix-composer-search
191c35f is described below

commit 191c35f3f0ac5ad7da2aff7047ed1598131c0b96
Author: Tomas Prochazka <ka...@razdva.cz>
AuthorDate: Thu Jul 9 22:35:23 2020 +0200

    [NETBEANS-4507] Fix Composer search when package has no description
    
    https://issues.apache.org/jira/browse/NETBEANS-4507
    
    Fixed parsing of `composer search` output when package does not have
    description.
    
    This happens when [composer-asset-plugin](https://github.com/fxpio/composer-asset-plugin) is installed. Then output contains also packages without description.
---
 .../modules/php/composer/output/parsers/CliParser.java        |  3 ++-
 .../modules/php/composer/output/parsers/CliParserTest.java    | 11 ++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/php/php.composer/src/org/netbeans/modules/php/composer/output/parsers/CliParser.java b/php/php.composer/src/org/netbeans/modules/php/composer/output/parsers/CliParser.java
index 2bfe18e..f841400 100644
--- a/php/php.composer/src/org/netbeans/modules/php/composer/output/parsers/CliParser.java
+++ b/php/php.composer/src/org/netbeans/modules/php/composer/output/parsers/CliParser.java
@@ -56,7 +56,8 @@ class CliParser implements Parser {
             }
             // current
             split = line.split(" ", 2); // NOI18N
-            result.add(new SearchResult(split[0].trim(), split[1].trim()));
+            String description = split.length == 2 ? split[1].trim() : ""; // NOI18N
+            result.add(new SearchResult(split[0].trim(), description));
         }
         return result;
     }
diff --git a/php/php.composer/test/unit/src/org/netbeans/modules/php/composer/output/parsers/CliParserTest.java b/php/php.composer/test/unit/src/org/netbeans/modules/php/composer/output/parsers/CliParserTest.java
index 03002d1..2790ec5 100644
--- a/php/php.composer/test/unit/src/org/netbeans/modules/php/composer/output/parsers/CliParserTest.java
+++ b/php/php.composer/test/unit/src/org/netbeans/modules/php/composer/output/parsers/CliParserTest.java
@@ -107,7 +107,7 @@ public class CliParserTest extends NbTestCase {
         assertEquals("Sends your logs to: files, sockets, inboxes, databases and various web services", result.getDescription());
     }
 
-    public void testParseSearchEmptyDescription() {
+    public void testParseSearchEmptyDescriptionLegacy() {
         String chunk = "monolog/monolog:";
         List<SearchResult> results = cliParser.parseSearch(chunk);
         assertEquals(1, results.size());
@@ -116,6 +116,15 @@ public class CliParserTest extends NbTestCase {
         assertEquals("", result.getDescription());
     }
 
+    public void testParseSearchEmptyDescription() {
+        String chunk = "monolog/monolog";
+        List<SearchResult> results = cliParser.parseSearch(chunk);
+        assertEquals(1, results.size());
+        SearchResult result = results.get(0);
+        assertEquals("monolog/monolog", result.getName());
+        assertEquals("", result.getDescription());
+    }
+
     public void testParseSearchIncorrectLine() {
         String chunk = "No composer.json found in the current directory, showing packages from packagist\n";
         List<SearchResult> results = cliParser.parseSearch(chunk);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists