Repository: ant
Updated Branches:
  refs/heads/master dc37a17ff -> 33d20f436


make complete-ant.pl provide all targets as completions

Patch by Christian Schmidt

Fixes bugzilla issues 57542 and 51931


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/33d20f43
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/33d20f43
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/33d20f43

Branch: refs/heads/master
Commit: 33d20f43659475bf234aa1c22ca9bbbd2a3b9d1e
Parents: dc37a17
Author: Stefan Bodewig <[email protected]>
Authored: Sat Feb 7 15:26:07 2015 +0100
Committer: Stefan Bodewig <[email protected]>
Committed: Sat Feb 7 15:26:07 2015 +0100

----------------------------------------------------------------------
 WHATSNEW                       |  7 +++++++
 src/script/complete-ant-cmd.pl | 11 +++++++----
 2 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/33d20f43/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index f53145f..b25e43a 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -70,6 +70,13 @@ Fixed bugs:
    the file.
    Bugzilla Report 57533
 
+ * complete-ant-cmd.pl would incorrectly suggest words from the build
+   file description.
+   Bugzilla Report 51931
+
+ * complete-ant-cmd.pl now also completes tasks without a description.
+   Bugzilla Report 57542
+
 Other changes:
 --------------
 

http://git-wip-us.apache.org/repos/asf/ant/blob/33d20f43/src/script/complete-ant-cmd.pl
----------------------------------------------------------------------
diff --git a/src/script/complete-ant-cmd.pl b/src/script/complete-ant-cmd.pl
index 4dd51a7..40c5a9a 100644
--- a/src/script/complete-ant-cmd.pl
+++ b/src/script/complete-ant-cmd.pl
@@ -77,16 +77,19 @@ sub getTargets {
     }
     return () unless (-f $buildFile);
 
-    # Run "ant -projecthelp" to list targets.  Keep a cache of results in a
-    # cache-file.
+    # Run "ant -projecthelp -debug" to list targets (-debug is required to get
+    # "Other targets", i.e. targets without a description).  Keep a cache of
+    # results in a cache-file.
     my $cacheFile = $buildFile;
     $cacheFile =~ s|(.*/)?(.*)|${1}.ant-targets-${2}|;
     if ((!-e $cacheFile) || (-z $cacheFile) || (-M $buildFile) < (-M 
$cacheFile)) {
         open( CACHE, '>'.$cacheFile ) || die "can\'t write $cacheFile: $!\n";
-        open( HELP, "$antCmd -projecthelp -f '$buildFile'|" ) || return(); 
+        open( HELP, "$antCmd -projecthelp -debug -buildfile '$buildFile'|" ) 
|| return(); 
         my %targets;
         while( <HELP> ) {
-            if (/^\s+(\S+)/) {
+            # Exclude target names starting with dash, because they cannot be
+            # specified on the command line.
+            if (/^\s+\+Target:\s+(?!-)(\S+)/) {
                 $targets{$1}++;
             }
         }

Reply via email to