[SCM] ci-tooling packaging branch, master, updated. fb37a28cfea18c912cdc54050918ce5d4a74bbed
Harald Sitter
apachelogger-guest at moszumanska.debian.org
Wed Aug 19 08:11:40 UTC 2015
Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=26fd29d
The following commit has been merged in the master branch:
commit 26fd29d6c655e45e11133eccb71878ca605387a8
Author: Harald Sitter <sitter at kde.org>
Date: Wed Aug 19 10:02:51 2015 +0200
change projects listing to use find and refactor it to have tighter testing
when a kde repo changes release bundle, the packaging repo also does so.
this either happens through a copy (which means the old repo has its CI
branches retracted) or through a move&ln-s (which means we must go to
greater lengths to pick only the moved version and not the symlinked one.
to handle latter correctly as to associate things with their right
component we now use a find on directories instead of a simple ls.
while practically we do not bind context to the pointless components repos
reside in we do bind context to the repo url which becomes duplicated if
a symlink is involved (e.g. frameworks/bluez is the same as plasma/bluez).
this has the obvious downside that mapping becomes a chore since any one
physical repo might have numerous URIs mapping to it as per the dir list.
so, to handle this we now ignore files and symlinks as per the find type.
to test this accurately the previvious ProjectFactory.list_all_repos is
now backed by two class methods doing the host of work here.
1. execute the find against a given hostcmd (e.g. ssh foo) and a specific
search path (returns array of paths)
2. strip down the array of paths into an array of repo names (i.e. strip
full path from find and strip .git suffix)
---
lib/projects.rb | 18 ++++++++++++++++--
.../test_init => test_projects/test_git_listing/file1} | 0
test/data/test_projects/test_git_listing/link1.git | 1 +
test/data/test_projects/test_git_listing/link2 | 1 +
.../test_git_listing/real1.git/file} | 0
.../test_git_listing/real2.git/file} | 0
test/test_projects.rb | 13 +++++++++++++
7 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/lib/projects.rb b/lib/projects.rb
index dd216ef..6f69787 100644
--- a/lib/projects.rb
+++ b/lib/projects.rb
@@ -121,9 +121,23 @@ end
# @private
class ProjectFactory
+ def self.find_all_repos(searchpath, hostcmd: 'ssh git.debian.org')
+ output = `#{hostcmd} find #{searchpath} -maxdepth 1 -type d`
+ fail 'Failed to find repo list on host' unless $? == 0
+ output.chop.split(' ')
+ end
+
+ def self.split_find_output(output)
+ output.collect! { |path| File.basename(path).gsub!('.git', '') }
+ output.uniq!
+ output.compact!
+ output
+ end
+
def list_all_repos(component)
- output = `ssh git.debian.org ls /git/pkg-kde/#{component}`
- output.chop!.gsub!('.git', '').split(' ')
+ searchpath = "/git/pkg-kde/#{component}/"
+ output = self.class.find_all_repos(searchpath)
+ self.class.split_find_output(output)
end
def factorize(key, value, type)
diff --git a/test/data/test_cmake_parser/test_init b/test/data/test_projects/test_git_listing/file1
similarity index 100%
copy from test/data/test_cmake_parser/test_init
copy to test/data/test_projects/test_git_listing/file1
diff --git a/test/data/test_projects/test_git_listing/link1.git b/test/data/test_projects/test_git_listing/link1.git
new file mode 120000
index 0000000..c363af7
--- /dev/null
+++ b/test/data/test_projects/test_git_listing/link1.git
@@ -0,0 +1 @@
+real2
\ No newline at end of file
diff --git a/test/data/test_projects/test_git_listing/link2 b/test/data/test_projects/test_git_listing/link2
new file mode 120000
index 0000000..c363af7
--- /dev/null
+++ b/test/data/test_projects/test_git_listing/link2
@@ -0,0 +1 @@
+real2
\ No newline at end of file
diff --git a/test/data/test_lint_series/test_complete/debian/patches/a.patch b/test/data/test_projects/test_git_listing/real1.git/file
similarity index 100%
copy from test/data/test_lint_series/test_complete/debian/patches/a.patch
copy to test/data/test_projects/test_git_listing/real1.git/file
diff --git a/test/data/test_lint_series/test_complete/debian/patches/a.patch b/test/data/test_projects/test_git_listing/real2.git/file
similarity index 100%
copy from test/data/test_lint_series/test_complete/debian/patches/a.patch
copy to test/data/test_projects/test_git_listing/real2.git/file
diff --git a/test/test_projects.rb b/test/test_projects.rb
index a002b7b..5493059 100644
--- a/test/test_projects.rb
+++ b/test/test_projects.rb
@@ -122,4 +122,17 @@ class ProjectTest < TestCase
assert_equal('http://a.com/b', Project.cleanup_uri('http://a.com//b//'))
assert_equal('//host/b', Project.cleanup_uri('//host/b/'))
end
+
+ def test_git_listing
+ output = ProjectFactory.find_all_repos(data, hostcmd: '')
+ assert_not_empty(output)
+ output = ProjectFactory.split_find_output(output)
+ assert_include(output, 'real1')
+ assert_include(output, 'real2')
+ # find includes path itself by default (since it is a dir...)
+ assert_not_include(output, File.basename(data))
+ assert_not_include(output, 'link1')
+ assert_not_include(output, 'link2')
+ assert_not_include(output, 'file1')
+ end
end
--
ci-tooling packaging
More information about the pkg-kde-commits
mailing list