[SCM] ci-tooling packaging branch, master, updated. 204b0d8feae0b9d0ee9106da676c56e2e0b79241

Harald Sitter apachelogger-guest at moszumanska.debian.org
Mon Apr 13 16:19:10 UTC 2015


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

The following commit has been merged in the master branch:
commit 25135a6dc1b4ef43f5b2cd55271171004e32cbca
Author: Harald Sitter <sitter at kde.org>
Date:   Mon Apr 13 18:15:44 2015 +0200

    add a fancy patchseries class to parse debian/patches/series
---
 lib/debian/patchseries.rb                          | 29 ++++++++++++++++++++++
 .../test_read/debian/patches/series                |  6 +++++
 test/test_debian_patchseries.rb                    | 13 ++++++++++
 3 files changed, 48 insertions(+)

diff --git a/lib/debian/patchseries.rb b/lib/debian/patchseries.rb
new file mode 100644
index 0000000..a42fafd
--- /dev/null
+++ b/lib/debian/patchseries.rb
@@ -0,0 +1,29 @@
+module Debian
+  # A debian patch series as seen in debian/patches/series
+  class PatchSeries
+    attr_reader :patches
+
+    def initialize(package_path)
+      @package_path = package_path
+      fail 'not a package path' unless Dir.exist?("#{package_path}/debian")
+      @patches = []
+      parse
+    end
+
+    private
+
+    def parse
+      path = "#{@package_path}/debian/patches/series"
+      return unless File.exist?(path)
+      data = File.read(path)
+      data.split($/).each do |line|
+        next if line.chop.strip.empty? || line.start_with?('#')
+        # series names really shouldn't use paths, so strip by space. This
+        # enforces the simple series format described in the dpkg-source manpage
+        # which unlike quilt does not support additional arguments such as
+        # -pN.
+        @patches << line.split(' ').first
+      end
+    end
+  end
+end
diff --git a/test/data/test_debian_patchseries/test_read/debian/patches/series b/test/data/test_debian_patchseries/test_read/debian/patches/series
new file mode 100644
index 0000000..4f07fb3
--- /dev/null
+++ b/test/data/test_debian_patchseries/test_read/debian/patches/series
@@ -0,0 +1,6 @@
+a.patch
+b.patch
+# comment
+     
+above-is-garbage.patch
+level.patch -p8
diff --git a/test/test_debian_patchseries.rb b/test/test_debian_patchseries.rb
new file mode 100644
index 0000000..46880f9
--- /dev/null
+++ b/test/test_debian_patchseries.rb
@@ -0,0 +1,13 @@
+require_relative '../lib/debian/patchseries'
+require_relative 'lib/testcase'
+
+# Test debian patch series
+class DebianPatchSeriesTest < TestCase
+  def test_read
+    s = Debian::PatchSeries.new(data)
+    assert_equal(4, s.patches.size)
+    %w(a.patch b.patch above-is-garbage.patch level.patch).each do |f|
+      assert_include(s.patches, f, "patch #{f} should be in series")
+    end
+  end
+end

-- 
ci-tooling packaging



More information about the pkg-kde-commits mailing list