[SCM] ci-tooling packaging branch, master, updated. 38c796a485dac23384bcad370db9a4716050bb34

Harald Sitter apachelogger-guest at moszumanska.debian.org
Tue Oct 27 10:54:32 UTC 2015


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

The following commit has been merged in the master branch:
commit 38c796a485dac23384bcad370db9a4716050bb34
Author: Harald Sitter <sitter at kde.org>
Date:   Tue Oct 27 11:54:22 2015 +0100

    remove kubuntu_ hardcoding from Project class, instead use a branch param
    
    this presently uses compatibility behavior until all uses are ported to
    branch which might take a while given the crap design at hand
---
 lib/projects.rb                          | 24 ++++++++++++++--------
 test/data/test_projects/test_init_branch |  1 +
 test/test_projects.rb                    | 35 ++++++++++++++++++++++++++++++++
 3 files changed, 52 insertions(+), 8 deletions(-)

diff --git a/lib/projects.rb b/lib/projects.rb
index 6f69787..7ea4ddd 100644
--- a/lib/projects.rb
+++ b/lib/projects.rb
@@ -7,10 +7,14 @@ require_relative 'ci/upstream_scm'
 require_relative 'debian/control'
 require_relative 'debian/source'
 
+require_relative 'deprecate'
+
 class Project
   class Error < Exception; end
   class GitTransactionError < Error; end
 
+  extend Deprecate
+
   # Name of the thing (e.g. the repo name)
   attr_reader :name
   # Super component (e.g. plasma)
@@ -41,11 +45,15 @@ class Project
   #   part of the repo path)
   # @param url_base the base path of the full repo URI. Combined with name and
   #   component this should form a repo URI
+  # @param branch branch name in packaging repository to use
+  #   branches.
   # @param type the type of integration project (unstable/stable..).
   #   This indicates whether to look for kubuntu_unstable or kubuntu_stable
-  #   branches
+  #   NB: THIS is mutually exclusive with branch!
   def initialize(name, component, url_base = 'git.debian.org:/git/pkg-kde',
-                 type:)
+                 type: nil,
+                 branch: "kubuntu_#{type}")
+    variable_deprecation(:type, :branch) unless type.nil?
     @name = name
     @component = component
     @upstream_scm = nil
@@ -77,8 +85,8 @@ class Project
         end
         fail GitTransactionError, 'Failed to pull' if i >= 5
 
-        unless system("git checkout kubuntu_#{type}")
-          fail GitTransactionError, "No branch #{type}"
+        unless system("git checkout #{branch}")
+          fail GitTransactionError, "No branch #{branch}"
         end
 
         next unless File.exist?('debian/control')
@@ -95,13 +103,13 @@ class Project
           @provided_binaries << binary['package']
         end
 
-        branches = `git for-each-ref --format='%(refname)' refs/remotes/origin/kubuntu_#{type}_\*`.strip.lines
-        branches.each do |branch|
-          @series_branches << branch.gsub('refs/remotes/origin/', '')
+        branches = `git for-each-ref --format='%(refname)' refs/remotes/origin/#{branch}_\*`.strip.lines
+        branches.each do |b|
+          @series_branches << b.gsub('refs/remotes/origin/', '')
         end
 
         unless Debian::Source.new(Dir.pwd).format.type == :native
-          @upstream_scm = UpstreamSCM.new(@packaging_scm, "kubuntu_#{type}")
+          @upstream_scm = UpstreamSCM.new(@packaging_scm, branch)
         end
 
         # FIXME: Probably should be converted to a symbol at a later point
diff --git a/test/data/test_projects/test_init_branch b/test/data/test_projects/test_init_branch
new file mode 120000
index 0000000..9149d97
--- /dev/null
+++ b/test/data/test_projects/test_init_branch
@@ -0,0 +1 @@
+test_init
\ No newline at end of file
diff --git a/test/test_projects.rb b/test/test_projects.rb
index 5493059..e7a0bf9 100644
--- a/test/test_projects.rb
+++ b/test/test_projects.rb
@@ -87,6 +87,41 @@ class ProjectTest < TestCase
     end
   end
 
+  # Tests init with explicit branch name instead of just type specifier
+  def test_init_branch
+    name = 'tn'
+    component = 'tc'
+
+    gitrepo = create_fake_git(name: name,
+                              component: component,
+                              branches: %w(kittens kittens_vivid))
+    assert_not_nil(gitrepo)
+    assert_not_equal(gitrepo, '')
+
+    tmpdir = Dir.mktmpdir(self.class.to_s)
+    Dir.chdir(tmpdir) do
+      # Force duplicated slashes in the git repo path. The init is supposed
+      # to clean up the path.
+      # Make sure the root isn't a double slash though as that contstitues
+      # a valid URI meaning whatever protocol is being used. Not practically
+      # useful for us but good to keep that option open all the same.
+      # Also make sure we have a trailing slash. Should we get a super short
+      # tmpdir that way we can be sure that at least one pointless slash is
+      # in the url.
+      slashed_gitrepo = gitrepo.gsub('/', '//').sub('//', '/') + '/'
+      project = Project.new(name, component, slashed_gitrepo, branch: 'kittens')
+      # FIXME: branch isn't actually stored in the projects because the
+      #        entire thing is frontend driven (i.e. the update script calls
+      #        Projects.new for each type manually). If this was backend/config
+      #        driven we'd be much better off. OTOH we do rather differnitiate
+      #        between types WRT dependency tracking and so forth....
+      assert_equal(%w(kittens_vivid), project.series_branches)
+    end
+  ensure
+    FileUtils.rm_rf(tmpdir) unless tmpdir.nil?
+    FileUtils.rm_rf(gitrepo) unless gitrepo.nil?
+  end
+
   def test_native
     name = 'tn'
     component = 'tc'

-- 
ci-tooling packaging



More information about the pkg-kde-commits mailing list