[SCM] patch-parser packaging branch, master, updated. 43474b21f016a6c6ceaa1bd528e34a0ab6b65fbb
Harald Sitter
apachelogger-guest at moszumanska.debian.org
Tue Apr 14 07:56:00 UTC 2015
Gitweb-URL: http://git.debian.org/?p=pkg-kde/patch-parser.git;a=commitdiff;h=ea0f741
The following commit has been merged in the master branch:
commit ea0f741e1399e407c02f9f58b0f5457710e7c28b
Author: Harald Sitter <sitter at kde.org>
Date: Mon Apr 13 15:27:33 2015 +0200
implement a replacement for the render script using controllers and views
---
Gemfile | 1 +
lib/dep3.rb | 10 ++++++++--
lib/patch.rb | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
lib/repo.rb | 11 +++++++++++
render.rb | 30 +++++++++++++++++++++++++++++
views/patches.html.haml | 31 ++++++++++++++++++++++++++++++
6 files changed, 131 insertions(+), 2 deletions(-)
diff --git a/Gemfile b/Gemfile
index dc3fb69..3189cad 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,4 +1,5 @@
source 'https://rubygems.org'
+gem 'git'
gem 'mail'
gem 'nokigori'
diff --git a/lib/dep3.rb b/lib/dep3.rb
index 8a86a31..827257f 100644
--- a/lib/dep3.rb
+++ b/lib/dep3.rb
@@ -24,7 +24,8 @@ class Dep3 < Hash
FREEFORM_STATE = 2
attr_reader :filepath
- attr_accessor :valid
+ attr_reader :valid
+ alias_method :valid?, :valid
def initialize(filepath)
@filepath = filepath
@@ -32,7 +33,8 @@ class Dep3 < Hash
@aliases = {
'Description' => 'Subject',
'Author' => 'From',
- 'Reviewed-by' => 'Acked-by'
+ 'Reviewed-by' => 'Acked-by',
+ 'Last-Update' => 'Date'
}
end
@@ -51,6 +53,10 @@ class Dep3 < Hash
super(get_alias(key), value)
end
+ def fetch(key, default = nil)
+ super(get_alias(key), default)
+ end
+
def parse!
state = NONE_STATE
current_header = nil
diff --git a/lib/patch.rb b/lib/patch.rb
new file mode 100644
index 0000000..c45367c
--- /dev/null
+++ b/lib/patch.rb
@@ -0,0 +1,50 @@
+require 'date'
+
+require_relative 'dep3'
+
+class Patch
+ # File name of the patch
+ attr_reader :name
+ # web url to look at the patch
+ attr_reader :url
+ # [String] Origin identifier
+ attr_reader :origin
+ # [Boolean] Whether or not the patch is dep3 compliant
+ attr_reader :dep3
+ # [String] Author of the patch
+ attr_reader :author
+ # [String] Date the patch was last updated
+ attr_reader :last_update
+
+ def initialize(file, repo)
+ @name = File.basename(file)
+ @url = self.class.url(file, repo)
+ @origin = 'other'
+ @origin = 'kubuntu' if @name.start_with?('kubuntu_')
+ @origin = 'upstream' if @name.start_with?('upstream_')
+ @dep3 = false
+ @author = 'Unknown'
+ @last_update = 'Unknown'
+ parse_dep3(file)
+ end
+
+ private
+
+ def self.url(file, repo)
+ format('%<base>s/%<repo>s.git/tree/%<file>s?h=%<branch>s',
+ base: 'http://anonscm.debian.org/cgit/pkg-kde',
+ repo: repo,
+ file: file.slice(%r{debian/patches/.+}),
+ branch: 'kubuntu_unstable')
+ end
+
+ def parse_dep3(file)
+ d = Dep3.new(file)
+ d.parse!
+ return unless d.valid?
+ @dep3 = true
+ @author = d.fetch('Author', 'Unknown')
+ @last_update = d.fetch('Last-Update', 'Unknown')
+ @last_update = Date.parse(@last_update).to_s if @last_update != 'Unknown'
+ end
+end
diff --git a/lib/repo.rb b/lib/repo.rb
new file mode 100644
index 0000000..32be869
--- /dev/null
+++ b/lib/repo.rb
@@ -0,0 +1,11 @@
+class Repo
+ attr_reader :id
+ attr_reader :name
+ attr_reader :patches
+
+ def initialize(id, patches)
+ @id = id
+ @name = File.basename(id)
+ @patches = patches
+ end
+end
diff --git a/render.rb b/render.rb
new file mode 100644
index 0000000..3bd1d65
--- /dev/null
+++ b/render.rb
@@ -0,0 +1,30 @@
+require 'git'
+require 'haml'
+
+require_relative 'lib/patch'
+require_relative 'lib/repo'
+
+repos = []
+
+Dir.mkdir('cache') unless Dir.exist?('cache')
+Dir.chdir('cache') do
+ ARGV.each do |repo|
+ repo_name = repo.split(':')[-1].split('/')[-1].split('.')[0]
+ Git::Base.clone(repo, repo_name) unless Dir.exist?(repo_name)
+ g = Git::Base.open(repo_name)
+ g.fetch
+ g.checkout('origin/kubuntu_unstable')
+ patches = []
+ patch_files = Dir.glob("#{repo_name}/debian/patches/**/**")
+ patch_files.each do |file|
+ # Filter out what's not a patch
+ next if File.directory?(file) || File.basename(file) == 'series'
+ patches << Patch.new(file, repo.split(':').last)
+ end
+ next if patches.empty?
+ repos << Repo.new(repo, patches)
+ end
+end
+
+a = Haml::Engine.new(File.read('views/patches.html.haml')).render(repos)
+File.write('patches.html', a)
diff --git a/views/patches.html.haml b/views/patches.html.haml
new file mode 100644
index 0000000..fd845d2
--- /dev/null
+++ b/views/patches.html.haml
@@ -0,0 +1,31 @@
+%html
+ %head
+ %meta{ 'http-equiv' => 'Content-Type',
+ content: 'text/html; charset=UTF-8' }
+ %meta{ charset: 'UTF-8' }
+ %link{ rel: 'stylesheet',
+ href: 'ubuntu-patch-status.css',
+ type: 'text/css' }
+ %body
+ %table.grid
+ %thead
+ %tr
+ %td Package
+ %td Patch Name
+ %td Dep 3
+ %td Author
+ %td Last-Update
+ %tbody
+ - each do |repo|
+ %tr
+ / Span +1, where 0 would be the header row and contain nothing but
+ / the header itself. This is a sneaky workaround for spanning being
+ / a bit crappy to programatically build.
+ %td{ class: repo.id, rowspan: repo.patches.size + 1 }= repo.name
+ - repo.patches.each do |patch|
+ %tr
+ %td{ class: "patch-#{patch.origin}" }
+ %a{ href: patch.url }= patch.name
+ %td{ class: "dep3-#{patch.dep3}" }= patch.dep3
+ %td&= patch.author
+ %td= patch.last_update
--
patch-parser packaging
More information about the pkg-kde-commits
mailing list