]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
Extract only required keys from %IRSSI headers
authorAilin Nemui <redacted>
Sat, 17 Jan 2015 16:49:19 +0000 (17:49 +0100)
committerAilin Nemui <redacted>
Sun, 18 Jan 2015 01:21:52 +0000 (02:21 +0100)
This change will limit the keys in scripts.yaml to a set of explicitly
specified keys, omitting such entries as default_package and changed

_testing/README.markdown
_testing/config.yml
_testing/travis/update-scripts-yaml.pl

index 0a5b751b949c0cf1772f39c22dd98ab6ee8ece11..7e2f8f1725309641512834bcbf795826bb5a8903 100644 (file)
@@ -42,3 +42,4 @@ The following keys are recognised in config.yml:
   * broken_modules: - modules to never auto-install, for example
                       because they hang Travis
 * whitelist: - list of scripts that are allowed to fail
+* scripts_yaml_keys: - list of keys to copy from irssi header to scripts.dmp
index e5118c4ad2b06ca3507b45db8196a2b91ac90ed7..75998e5e94a993d0390d1e66dc8fbd192ca24ac5 100644 (file)
@@ -1,4 +1,20 @@
 ---
+scripts_yaml_keys:
+  # required
+  - filename
+  - version
+  - authors
+  - contact
+  - name
+  - description
+  - license
+  # optional
+  - url
+  - commands
+  - note
+  - modules
+  # explicit
+  - modified
 additional_system_deps:
   - libconfig-simple-perl
   - libyaml-perl
index d3384a8305275f3021ec6708480868cd7851511e..57620963c423620ad6610d8575bb4003484b31c2 100644 (file)
@@ -1,5 +1,21 @@
 use strict; use warnings;
 use YAML::Tiny;
+use Scalar::Util;
+BEGIN {
+    sub YAML::Tiny::_has_internal_string_value {
+       !Scalar::Util::looks_like_number($_[0])
+    }
+}
+
+my @config;
+if (open my $ef, '<:utf8', '_testing/config.yml') {
+    @config = Load(do { local $/; <$ef> });
+}
+my @yaml_keys;
+if (@config) {
+    @yaml_keys = @{ $config[0]{scripts_yaml_keys}//[] };
+}
+die "no keys defined in config.yaml\n" unless @yaml_keys;
 
 my @docs;
 { open my $ef, '<:utf8', '_data/scripts.yaml' or die $!;
@@ -49,15 +65,20 @@ for my $file (<scripts/*.pl>) {
        print "MISSING META FOR $base\n";
     }
 }
-my @newdoc = map { $newmeta{$_} } sort keys %newmeta;
+my @newdoc = map {
+    my $v = $newmeta{$_};
+    +{
+        map {
+            exists $v->{$_}
+                ? ($_ => $v->{$_})
+                : ()
+        } sort @yaml_keys
+    }
+} sort keys %newmeta;
 { open my $ef, '>:utf8', '_data/scripts.yaml' or die $!;
   print $ef Dump \@newdoc;
 }
 
-my @config;
-if (open my $ef, '<:utf8', '_testing/config.yml') {
-    @config = Load(do { local $/; <$ef> });
-}
 if (@config && @{$config[0]{whitelist}//[]}) {
     my $changed;
     my @wl;
git clone https://git.99rst.org/PROJECT