[SCM] ci-tooling packaging branch, master, updated. b3e33a5ceab3e134db21ade37f6b44c5a8d841b3
Harald Sitter
apachelogger-guest at moszumanska.debian.org
Thu Mar 5 11:26:20 UTC 2015
Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=b3139a9
The following commit has been merged in the master branch:
commit b3139a9d5b4ff63cb659a5bd5632af991b77fe55
Author: Harald Sitter <sitter at kde.org>
Date: Thu Mar 5 12:25:49 2015 +0100
force project packaging scm paths to have a cleaned up path
---
lib/projects.rb | 13 +++++++++++--
test/test_projects.rb | 18 +++++++++++++++++-
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/lib/projects.rb b/lib/projects.rb
index c4be841..cca2db8 100644
--- a/lib/projects.rb
+++ b/lib/projects.rb
@@ -1,4 +1,7 @@
require 'json'
+require 'pathname'
+require 'uri'
+
require_relative 'debian/control'
Scm = Struct.new(:type, :url, :branch)
@@ -41,8 +44,8 @@ class Project
@dependees = []
@series_branches = []
@autopkgtest = false
- @packaging_scm = "#{url_base}/#{component}/#{name}"
- puts @packaging_scm
+ # 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}")
@@ -106,6 +109,12 @@ class Project
end
end
end
+
+ def self.cleanup_uri(uri)
+ uri = URI(uri) unless uri.is_a?(URI)
+ uri.path = Pathname.new(uri.path).cleanpath.to_s
+ uri.to_s
+ end
end
# @private
diff --git a/test/test_projects.rb b/test/test_projects.rb
index b43f491..ad3908b 100644
--- a/test/test_projects.rb
+++ b/test/test_projects.rb
@@ -59,7 +59,17 @@ class ProjectTest < Test::Unit::TestCase
tmpdir = Dir.mktmpdir(self.class.to_s)
Dir.chdir(tmpdir) do
- project = Project.new(name, component, gitrepo, type: stability)
+ # 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 we 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,
+ type: stability)
assert_equal(project.name, name)
assert_equal(project.component, component)
scm = project.upstream_scm
@@ -95,4 +105,10 @@ class ProjectTest < Test::Unit::TestCase
end
assert_equal(tmpref.size, 0)
end
+
+ def test_cleanup_uri
+ assert_equal('/a/b', Project.cleanup_uri('/a//b/'))
+ assert_equal('http://a.com/b', Project.cleanup_uri('http://a.com//b//'))
+ assert_equal('//host/b', Project.cleanup_uri('//host/b/'))
+ end
end
--
ci-tooling packaging
More information about the pkg-kde-commits
mailing list