[SCM] ci-tooling packaging branch, master, updated. 9e491f86f830729ca250f42cb766087867915b09

Harald Sitter apachelogger-guest at moszumanska.debian.org
Mon Mar 9 10:32:14 UTC 2015


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

The following commit has been merged in the master branch:
commit 9e491f86f830729ca250f42cb766087867915b09
Author: Harald Sitter <sitter at kde.org>
Date:   Mon Mar 9 11:32:11 2015 +0100

    format projects and fix a whole bunch of rubocop warnings
---
 lib/projects.rb | 308 ++++++++++++++++++++++++++++----------------------------
 1 file changed, 154 insertions(+), 154 deletions(-)

diff --git a/lib/projects.rb b/lib/projects.rb
index cca2db8..245d11e 100644
--- a/lib/projects.rb
+++ b/lib/projects.rb
@@ -7,108 +7,111 @@ require_relative 'debian/control'
 Scm = Struct.new(:type, :url, :branch)
 
 class Project
-    # Name of the thing (e.g. the repo name)
-    attr_reader :name
-    # Super component (e.g. plasma)
-    attr_reader :component
-    # Scm instance describing the upstream SCM associated with this project.
-    attr_reader :upstream_scm
-    # Array of binary packages (debs) provided by this project
-    attr_reader :provided_binaries
-
-    # Array of package dependencies, initialized by default from control file
-    attr_reader :dependencies
-    # Array of package dependees, empty Array by default
-    attr_reader :dependees
-
-    # Array of branch names that are series specific. May be empty if there are none.
-    attr_reader :series_branches
-
-    # Bool whether this project uses autopkgtest
-    attr_reader :autopkgtest
-    # String of the SCM uri
-    attr_reader :packaging_scm
-
-    # Init
-    # @param name name of the project (this is equal to the name of the packaging repo)
-    # @param component component within which the project resides (i.e. directory 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 type the type of integration project (unstable/stable..).
-    #   This indicates whether to look for kubuntu_unstable or kubuntu_stable branches
-    def initialize(name, component, url_base='git.debian.org:/git/pkg-kde', type:)
-        @name = name
-        @component = component
-        @upstream_scm = nil
-        @provided_binaries = []
-        @dependencies = []
-        @dependees = []
-        @series_branches = []
-        @autopkgtest = false
-        # Clean up path to remove useless slashes and colons.
-        @packaging_scm = Project.cleanup_uri("#{url_base}/#{component}/#{name}")
-
-        # FIXME: git dir needs to be set somewhere, somehow, somewhat, lol, kittens?
-        FileUtils.mkdir_p("git/#{component}") unless Dir.exist?("git/#{component}")
-        Dir.chdir("git/#{component}") do
-            unless File.exist?(name)
-                i = 0
-                while true and (i+=1) < 5
-                    break if system("git clone #{@packaging_scm}")
-                end
-            end
-            Dir.chdir(name) do
-                system("git clean -fd")
-                system("git reset --hard")
-
-                i = 0
-                while (i+=1) < 5
-                  break if system("git pull")
-                end
-                raise "Failed to pull" if i >= 5
-
-                unless system("git checkout kubuntu_#{type}")
-                  raise "No branch #{type}"
-                end
-
-                next unless File.exist?('debian/control')
-
-                c = DebianControl.new
-                # TODO: raise? return?
-                c.parse!
-                c.source['build-depends'].each do |dep|
-                    @dependencies << dep.name
-                end
-                c.binaries.each do |binary|
-                    @provided_binaries << binary['package']
-                end
-
-                branches = %x[git for-each-ref --format='%(refname)' refs/remotes/origin/kubuntu_#{type}_\*].strip.lines
-                branches.each do |branch|
-                    @series_branches << branch.gsub('refs/remotes/origin/', '')
-                end
-
-                upstream_scm = {}
-                if File.exist?('debian/meta/upstream_scm.json')
-                    upstream_scm = JSON::parse(File.read('debian/meta/upstream_scm.json'))
-
-                end
-
-                if component == 'qt'
-                    upstream_scm['url'] ||= "https://gitorious.org/qt/#{name}.git"
-                    upstream_scm['branch'] ||= '5.4'
-                end
-
-                default_repo_url = "git://anongit.kde.org/#{name.chomp('-qt4')}"
-                @upstream_scm = Scm.new(upstream_scm['type'] ||= 'git',
-                                        upstream_scm['url'] ||= default_repo_url,
-                                        upstream_scm['branch'] ||= 'master')
-
-                # FIXME: Probably should be converted to a symbol at a later point
-                #        since xs-testsuite could change to random other string in the future
-                @autopkgtest = c.source['xs-testsuite'] == 'autopkgtest'
-            end
+  # Name of the thing (e.g. the repo name)
+  attr_reader :name
+  # Super component (e.g. plasma)
+  attr_reader :component
+  # Scm instance describing the upstream SCM associated with this project.
+  attr_reader :upstream_scm
+  # Array of binary packages (debs) provided by this project
+  attr_reader :provided_binaries
+
+  # Array of package dependencies, initialized by default from control file
+  attr_reader :dependencies
+  # Array of package dependees, empty Array by default
+  attr_reader :dependees
+
+  # Array of branch names that are series specific. May be empty if there are
+  # none.
+  attr_reader :series_branches
+
+  # Bool whether this project uses autopkgtest
+  attr_reader :autopkgtest
+  # String of the SCM uri
+  attr_reader :packaging_scm
+
+  # Init
+  # @param name name of the project (this is equal to the name of the packaging
+  #   repo)
+  # @param component component within which the project resides (i.e. directory
+  #   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 type the type of integration project (unstable/stable..).
+  #   This indicates whether to look for kubuntu_unstable or kubuntu_stable
+  #   branches
+  def initialize(name, component, url_base = 'git.debian.org:/git/pkg-kde',
+                 type:)
+    @name = name
+    @component = component
+    @upstream_scm = nil
+    @provided_binaries = []
+    @dependencies = []
+    @dependees = []
+    @series_branches = []
+    @autopkgtest = false
+    # Clean up path to remove useless slashes and colons.
+    @packaging_scm = Project.cleanup_uri("#{url_base}/#{component}/#{name}")
+
+    # FIXME: git dir needs to be set somewhere, somehow, somewhat, lol, kittens?
+    FileUtils.mkdir_p("git/#{component}") unless Dir.exist?("git/#{component}")
+    Dir.chdir("git/#{component}") do
+      unless File.exist?(name)
+        5.times do
+          break if system("git clone #{@packaging_scm}")
+        end
+      end
+      Dir.chdir(name) do
+        system('git clean -fd')
+        system('git reset --hard')
+
+        i = 0
+        while (i += 1) < 5
+          break if system('git pull')
+        end
+        fail 'Failed to pull' if i >= 5
+
+        fail "No branch #{type}" unless system("git checkout kubuntu_#{type}")
+
+        next unless File.exist?('debian/control')
+
+        c = DebianControl.new
+        # TODO: raise? return?
+        c.parse!
+        c.source['build-depends'].each do |dep|
+          @dependencies << dep.name
+        end
+        c.binaries.each do |binary|
+          @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/', '')
+        end
+
+        upstream_scm = {}
+        if File.exist?('debian/meta/upstream_scm.json')
+          upstream_scm = JSON.parse(File.read('debian/meta/upstream_scm.json'))
+        end
+
+        if component == 'qt'
+          upstream_scm['url'] ||= "https://gitorious.org/qt/#{name}.git"
+          upstream_scm['branch'] ||= '5.4'
         end
+
+        default_repo_url = "git://anongit.kde.org/#{name.chomp('-qt4')}"
+        @upstream_scm = Scm.new(upstream_scm['type'] ||= 'git',
+                                upstream_scm['url'] ||= default_repo_url,
+                                upstream_scm['branch'] ||= 'master')
+
+        # FIXME: Probably should be converted to a symbol at a later point
+        #        since xs-testsuite could change to random other string in the
+        #        future
+        @autopkgtest = c.source['xs-testsuite'] == 'autopkgtest'
+      end
     end
+  end
 
   def self.cleanup_uri(uri)
     uri = URI(uri) unless uri.is_a?(URI)
@@ -120,13 +123,14 @@ end
 # @private
 class ProjectFactory
   def list_all_repos(component)
-    return %x[ssh git.debian.org ls /git/pkg-kde/#{component}].chop!.gsub!('.git', '').split(' ')
+    output = `ssh git.debian.org ls /git/pkg-kde/#{component}`
+    output.chop!.gsub!('.git', '').split(' ')
   end
 
   def factorize(key, value, type)
     ret = []
     case key
-    when "all_repos"
+    when 'all_repos'
       value.each do |component|
         repos = list_all_repos(component)
         repos.each do |name|
@@ -136,7 +140,7 @@ class ProjectFactory
           end
         end
       end
-    when "selective_repos"
+    when 'selective_repos'
       value.each do |component, names|
         names.each do |name|
           begin
@@ -145,17 +149,19 @@ class ProjectFactory
           end
         end
       end
-    when "selective_exlusion"
+    when 'selective_exlusion'
       value.each do |component, blacklist|
         repos = list_all_repos(component)
         repos.each do |name|
           begin
-            ret << Project.new(name, component, type: type) unless blacklist.include? name
+            unless blacklist.include?(name)
+              ret << Project.new(name, component, type: type)
+            end
           rescue
           end
         end
       end
-    when "custom_ci"
+    when 'custom_ci'
       value.each do |custom_ci|
         repos = []
         if custom_ci['type'] == 'github'
@@ -168,72 +174,66 @@ class ProjectFactory
             repos = custom_ci['repos']
           end
         elsif custom_ci['repos'] == ['all'] && custom_ci['type'] != 'github'
-          repos = %x[ssh #{custom_ci['git_host']} ls /].chop!.gsub!('.git', '').split(' ')
+          repos = `ssh #{custom_ci['git_host']} ls /`.chop!.gsub!('.git', '').split(' ')
         else
           repos = custom_ci['repos']
         end
 
         repos.each do |repo|
           begin
-            ret << Project.new(repo, custom_ci['org'], custom_ci['git_host'], type: type)
+            ret << Project.new(repo, custom_ci['org'], custom_ci['git_host'],
+                               type: type)
           rescue
           end
         end
       end
     else
-      raise "ProjectFactory encountered an unknown configuration key: #{key}"
+      fail "ProjectFactory encountered an unknown configuration key: #{key}"
     end
-    return ret
+    ret
   end
 end
 
 class Projects < Array
-    def initialize(type: "unstable",
-                   allow_custom_ci: false,
-                   projects_file: File.expand_path(File.dirname(File.dirname(__FILE__))) + '/data/projects.json')
-        super()
-        config = JSON::parse(File.read(projects_file))
-        config.delete("custom_ci") unless allow_custom_ci
-
-        config.each do |key, value|
-          self.concat(ProjectFactory.new.factorize(key, value, type))
-        end
+  def initialize(type: 'unstable',
+                 allow_custom_ci: false,
+                 projects_file: File.expand_path(File.dirname(File.dirname(__FILE__))) + '/data/projects.json')
+    super()
+    config = JSON.parse(File.read(projects_file))
+    config.delete('custom_ci') unless allow_custom_ci
+
+    config.each do |key, value|
+      concat(ProjectFactory.new.factorize(key, value, type))
+    end
 
-        # Build a hash for quick lookup of which source provides which binary.
-        provided_by = {}
-        self.each do |project|
-            project.provided_binaries.each do |binary|
-                provided_by[binary] = project.name
-            end
-        end
+    # Build a hash for quick lookup of which source provides which binary.
+    provided_by = {}
+    each do |project|
+      project.provided_binaries.each do |binary|
+        provided_by[binary] = project.name
+      end
+    end
 
-        # Random explanation of the day:
-        # Ruby blocks generally "return" with next or break (implicitly by default mind you)
-        # collect! considering this will use the "return" value of break/next and aggregates
-        # those into the array.
-        # Consequentially one must always 'break var' or 'next var' (or simply 'var' because
-        # of the implicit return paradigm) in order to have collect! get the modified value.
-        # If one does not implicitly or explicitly return a value nil will be collected instead.
-        self.collect! do |project|
-            project.dependencies.collect! do |dependency|
-                next unless provided_by.include?(dependency)
-                dependency = provided_by[dependency]
-                # Reverse insert us into the list of dependees of our dependency
-                self.collect! do |dep_project|
-                    next dep_project if dep_project.name != dependency
-                    dep_project.dependees << project.name
-                    dep_project.dependees.compact!
-                    break dep_project
-                end
-                next dependency
-            end
-            # Ditch nil and duplicates
-            project.dependencies.compact!
-            project
+    self.collect! do |project|
+      project.dependencies.collect! do |dependency|
+        next unless provided_by.include?(dependency)
+        dependency = provided_by[dependency]
+        # Reverse insert us into the list of dependees of our dependency
+        self.collect! do |dep_project|
+          next dep_project if dep_project.name != dependency
+          dep_project.dependees << project.name
+          dep_project.dependees.compact!
+          break dep_project
         end
-
-        require 'pp'
-        pp '---------------------------------------'
-        pp self
+        next dependency
+      end
+      # Ditch nil and duplicates
+      project.dependencies.compact!
+      project
     end
+
+    require 'pp'
+    pp '---------------------------------------'
+    pp self
+  end
 end

-- 
ci-tooling packaging



More information about the pkg-kde-commits mailing list