Created
October 13, 2013 21:32
-
-
Save rob-mcgrail/6967664 to your computer and use it in GitHub Desktop.
eZPublish svn -> git conversion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $ ruby complete-build.rb ezp-manifest.txt ext-manifest.txt tki-pb4l 4.4-1.0.2 | |
require 'fileutils' | |
EXT_REPO_DIR = 'extension-repos' | |
EZP_REPO_DIR = 'ezpublish' | |
SVN2GIT = 'svn2git' | |
SVN2GIT_FLAGS="--exclude doc --exclude '.*~$' -v" | |
SVN_ROOT = "svn+ssh://user@svn" | |
SITES_PATH = "/vol/work/ezpublish/local/extension/sites" | |
ezp_manifest = ARGV[0] | |
ext_manifest = ARGV[1] | |
build_name = ARGV[2] | |
build_tag = ARGV[3] | |
def run_command(cmd, exit_on_error=true) | |
puts "Running command: #{cmd}" | |
ret = '' | |
cmd = "2>&1 #{cmd}" | |
IO.popen(cmd) do |stdout| | |
stdout.each do |line| | |
puts line | |
ret << line | |
end | |
end | |
if exit_on_error && ($?.exitstatus != 0) | |
$stderr.puts "command failed:\n#{cmd}" | |
exit -1 | |
end | |
ret | |
end | |
def rm_if_exists(path) | |
if File.directory? path | |
FileUtils.rm_rf path | |
end | |
end | |
def rm_mk_cd(path) | |
rm_if_exists(path) | |
Dir.mkdir path | |
Dir.chdir path | |
end | |
# Create eZPublish upstream. | |
File.open(ezp_manifest).each do |line| | |
attributes = line.split(',') | |
name = attributes[0] | |
tag = attributes[1] | |
path = attributes[2].chomp | |
rm_mk_cd(EZP_REPO_DIR) | |
# Convert to git. | |
run_command "#{SVN2GIT} #{SVN_ROOT}#{path}/#{name} #{SVN2GIT_FLAGS}" | |
# Turn tag into branch. | |
run_command "git checkout #{tag}" | |
run_command "git checkout -b prod-#{tag}" | |
@ezpublish_branch = 'prod-' + tag | |
Dir.chdir '..' | |
end | |
rm_if_exists(EXT_REPO_DIR) | |
Dir.mkdir(EXT_REPO_DIR) | |
# Create extension upstreams. | |
File.open(ext_manifest).each do |line| | |
attributes = line.split(',') | |
name = attributes[0] | |
tag = attributes[1] | |
path = attributes[2].chomp | |
extension_dir = EXT_REPO_DIR + '/' + name | |
rm_mk_cd(extension_dir) | |
# Convert extension to git. | |
run_command "#{SVN2GIT} #{SVN_ROOT}#{path}/#{name} #{SVN2GIT_FLAGS}" | |
# Convert tag to branch. | |
run_command "git checkout #{tag}" | |
run_command "git checkout -b prod-#{tag}" | |
Dir.chdir '../..' | |
end | |
rm_mk_cd(build_name) | |
# Create main site repository, adding eZPublish as upstream. | |
run_command "git init" | |
run_command "git remote add temp-upstream ../ezpublish" | |
run_command "git fetch temp-upstream" | |
run_command "git merge temp-upstream/#{@ezpublish_branch}" | |
# Add each extension as a remote and a subtree. | |
File.open('../' + ext_manifest).each do |line| | |
attributes = line.split(',') | |
name = attributes[0] | |
tag = attributes[1] | |
path = attributes[2].chomp | |
extension_dir = EXT_REPO_DIR + '/' + name | |
# Adding extension as a subtree. | |
run_command "git remote add #{name}-upstream ../#{extension_dir}" | |
run_command "git subtree add --prefix=extension/#{name} --squash #{name}-upstream prod-#{tag}" | |
end | |
Dir.chdir '..' | |
# Checkout site extension. | |
rm_mk_cd('tmp-' + build_name) | |
# Convert site extension to git. | |
run_command "#{SVN2GIT} #{SVN_ROOT}#{SITES_PATH}/#{build_name} #{SVN2GIT_FLAGS}" | |
# Convert tag to branch. | |
run_command "git checkout #{build_tag}" | |
run_command "git checkout -b prod-#{build_tag}" | |
# De-repo it. | |
FileUtils.rm_rf ".git" | |
Dir.chdir '..' | |
# Move into main site repo extensions folder. | |
FileUtils.mv 'tmp-' + build_name, build_name + '/extension/' + build_name | |
Dir.chdir build_name | |
# Check site extension in. | |
run_command "git add ." | |
run_command "git commit -a -m 'Adding site extension'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bcwebsitestatistics,201110071115,/vol/work/ezpublish/vendor/extension/community | |
ezfind,ezfind-2.3_fix_cron_error,/vol/work/ezpublish/vendor/extension/community | |
ezwebin,ezwebin-1.8,/vol/work/ezpublish/vendor/extension/community | |
ezwt,ezwt-1.4,/vol/work/ezpublish/vendor/extension/community | |
swark,201109271501,/vol/work/ezpublish/vendor/extension/community | |
wordCut,1.0,/vol/work/ezpublish/vendor/extension/community | |
wrap_operator,1.0.1,/vol/work/ezpublish/vendor/extension/community | |
recaptcha,201109271502,/vol/work/ezpublish/vendor/extension/community | |
simplecookies,4.4-1.0.0,/vol/work/ezpublish/vendor/extension/community | |
ezkeyword_autocomplete,4.4-1.0.0,/vol/work/ezpublish/vendor/extension/community | |
adbar,4.4-1.0.0,/vol/work/ezpublish/local/extension/common | |
ezboot,4.4-1.0.5,/vol/work/ezpublish/local/extension/common | |
cwa-multiobjectinsert,4.4-1.0,/vol/work/ezpublish/local/extension/common | |
cwa-lightbox,4.4-1.0.1,/vol/work/ezpublish/local/extension/common | |
tki-base,1.0.2,/vol/work/ezpublish/local/extension/common | |
tki,1.0,/vol/work/ezpublish/local/extension/common | |
cwa-flipbook,201202140120,/vol/work/ezpublish/local/extension/common | |
cwa-webbook,201207171719,/vol/work/ezpublish/local/extension/common | |
cwa-carousel,4.4-1.0.2,/vol/work/ezpublish/local/extension/common | |
cwa-events,201207251617,/vol/work/ezpublish/local/extension/common | |
cwa-news,4.4-1.0.1,/vol/work/ezpublish/local/extension/common | |
cwa-tre,201204032020,/vol/work/ezpublish/local/extension/common | |
cwa-rssfeed,201204041550,/vol/work/ezpublish/local/extension/common | |
imagemap,201112021157,/vol/work/ezpublish/local/extension/common | |
ezimagemap,4.4-1.0.2,/vol/work/ezpublish/local/extension/common | |
tki-admintab,201208281129,/vol/work/ezpublish/local/extension/common | |
cwa-imagegallery,4.4-1.0.1,/vol/work/ezpublish/local/extension/common | |
geoip_is_nz,201203081302,/vol/work/ezpublish/local/extension/common | |
cwa-templateoperators,201210171324,/vol/work/ezpublish/local/extension/common | |
tki-bar,201206120340,/vol/work/ezpublish/local/extension/common | |
cwa-content-manipulation-scripts,4.4-1.0.1,/vol/work/ezpublish/local/extension/common | |
cwa-tags,4.4-1.0.1,/vol/work/ezpublish/local/extension/common | |
lml-telemetry,4.4-1.0.0,/vol/work/ezpublish/local/extension/common | |
qctv,4.4-1.0.9,/vol/work/ezpublish/vendor/extension/cwamodified | |
ezoe,4.4_1.0.0,/vol/work/ezpublish/vendor/extension/cwamodified | |
glossary,4.4-1.1.3,/vol/work/ezpublish/vendor/extension/cwamodified | |
sqliimport,4.4-1.0,/vol/work/ezpublish/vendor/extension/cwamodified | |
mugo_varnish,4.4-1.0.1,/vol/work/ezpublish/vendor/extension/cwamodified | |
enhancedselection2,4.4-1.0.0,/vol/work/ezpublish/vendor/extension/cwamodified |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4.4-ezc,4.4-ezsendmailtransport-undisclosed-recipients-fix,/vol/work/ezpublish/vendor/ezpublish |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment