[SCM] ci-tooling packaging branch, master, updated. 2177d2a534db3455d80cf1f63851e81ad7203228

Harald Sitter apachelogger-guest at moszumanska.debian.org
Mon Apr 27 12:22:06 UTC 2015


Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=2177d2a

The following commit has been merged in the master branch:
commit 2177d2a534db3455d80cf1f63851e81ad7203228
Author: Harald Sitter <sitter at kde.org>
Date:   Mon Apr 27 13:40:13 2015 +0200

    port upstream_scm to new pattern stuff
---
 lib/ci/upstream_scm.rb | 35 ++++++++++++++---------------------
 1 file changed, 14 insertions(+), 21 deletions(-)

diff --git a/lib/ci/upstream_scm.rb b/lib/ci/upstream_scm.rb
index f68f643..ba4abbd 100644
--- a/lib/ci/upstream_scm.rb
+++ b/lib/ci/upstream_scm.rb
@@ -2,6 +2,8 @@ require 'erb'
 require 'json'
 require 'yaml'
 
+require_relative 'pattern'
+
 # Construct an upstream scm instance and fold in overrides set via
 # meta/upstream_scm.json.
 class UpstreamSCM
@@ -60,20 +62,6 @@ class UpstreamSCM
 
   private
 
-  def best_pattern(patterns, reference)
-    best = nil
-    patterns.each do |pattern|
-      next unless File.fnmatch(pattern, reference)
-      best ||= pattern
-      # If best_pattern matches the pattern at hand the new pattern is better
-      # yet as it is a more restrictive version of the current best pattern.
-      best = pattern if File.fnmatch(best, pattern)
-      # If the pattern is a precise match we might as well stop here.
-      break if best == reference
-    end
-    best
-  end
-
   def override_apply(override)
     context = BindingContext.new(self)
 
@@ -91,19 +79,24 @@ class UpstreamSCM
   def global_override_load
     base = File.expand_path(File.dirname(File.dirname(File.dirname(__FILE__))))
     file = File.join(base, 'data', 'upstream-scm.yml')
-    YAML.load(File.read(file))
+    hash = YAML.load(File.read(file))
+    hash = CI::PatternHash.new(hash, recurse: false)
+    hash.each do |k, v|
+      hash[k] = CI::PatternHash.new(v, recurse: false)
+    end
+    hash
   end
 
   def global_override!
     overrides = global_override_load
-    repo_pattern = best_pattern(overrides.keys, @packaging_repo)
-    return unless repo_pattern
+    repo_patterns = overrides.filter(@packaging_repo)
+    return if repo_patterns.empty?
 
-    branches = overrides[repo_pattern]
-    branch_pattern = best_pattern(branches.keys, @packaging_branch)
-    return unless branch_pattern
+    branches = overrides[repo_patterns.flatten.first]
+    branch_patterns = branches.filter(@packaging_branch)
+    return if branch_patterns.empty?
 
-    override_apply(branches[branch_pattern])
+    override_apply(branches[branch_patterns.flatten.first])
   end
 
   def repo_override!

-- 
ci-tooling packaging



More information about the pkg-kde-commits mailing list