[SCM] ci-tooling packaging branch, master, updated. 70aead8faeda9ce643db7b7bc9561cc6925c530c

Rohan Garg rohangarg-guest at moszumanska.debian.org
Tue May 5 12:41:33 UTC 2015


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

The following commit has been merged in the master branch:
commit 70aead8faeda9ce643db7b7bc9561cc6925c530c
Author: Rohan Garg <rohan at garg.io>
Date:   Tue May 5 14:40:54 2015 +0200

    Add appropriate fallovers when os-release doesn't have the VERSION_ID field
---
 lib/ci/build_version.rb       | 14 +++++++++++++-
 test/test_ci_build_version.rb | 31 +++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/lib/ci/build_version.rb b/lib/ci/build_version.rb
index 761a7fa..4d570b6 100644
--- a/lib/ci/build_version.rb
+++ b/lib/ci/build_version.rb
@@ -17,7 +17,7 @@ module CI
 
     def initialize(changelog)
       @changelog = changelog
-      @suffix = format('+git%s+%s', time, OS::VERSION_ID)
+      @suffix = format('+git%s+%s', time, version_id)
       @tar = "#{clean_base}#{@suffix}"
       @base = "#{changelog.version(Changelog::EPOCH)}#{clean_base}#{@suffix}"
       @full = "#{base}-0"
@@ -46,5 +46,17 @@ module CI
       fail 'Failed to find numeric version in the changelog version:' \
            " #{@changelog.version(Changelog::BASE)}"
     end
+
+    def version_id
+      return OS::VERSION_ID if OS.to_h.key?(:VERSION_ID) &&
+                               !OS::VERSION_ID.nil? &&
+                               !OS::VERSION_ID.empty?
+
+      if OS::ID == 'debian'
+        '9'
+      else
+        fail 'VERSION_ID not defined!'
+      end
+    end
   end
 end
diff --git a/test/test_ci_build_version.rb b/test/test_ci_build_version.rb
index b4ab68a..eaf27a8 100644
--- a/test/test_ci_build_version.rb
+++ b/test/test_ci_build_version.rb
@@ -51,6 +51,37 @@ class CIBuildVersionTest < TestCase
     assert_equal(v.full, v.to_s)
   end
 
+  def test_bad_os_release
+    # os-release doesn't have the var
+    OS.reset
+    OS.instance_variable_set(:@hash, ID: 'debian')
+    c = Changelog.new(data)
+    v = CI::BuildVersion.new(c)
+    suffix = v.send(:instance_variable_get, :@suffix)
+    parts = suffix.split('+')
+    assert_equal('9', parts[2])
+
+    OS.instance_variable_set(:@hash, ID: 'ubuntu')
+    c = Changelog.new(data)
+    assert_raise RuntimeError do
+      v = CI::BuildVersion.new(c)
+    end
+
+    # Value is nil
+    OS.instance_variable_set(:@hash, VERSION_ID: nil, ID: 'ubuntu')
+    c = Changelog.new(data)
+    assert_raise RuntimeError do
+      v = CI::BuildVersion.new(c)
+    end
+
+    # Value is empty
+    OS.instance_variable_set(:@hash, VERSION_ID: '', ID: 'ubuntu')
+    c = Changelog.new(data)
+    assert_raise RuntimeError do
+      v = CI::BuildVersion.new(c)
+    end
+  end
+
   def test_time
     unalias_time
     c = Changelog.new(data)

-- 
ci-tooling packaging



More information about the pkg-kde-commits mailing list