|
52 | 52 |
|
53 | 53 | desc "Publish to http://developer.github.com" |
54 | 54 | task :publish, [:no_commit_msg] => [:remove_tmp_dir, :remove_output_dir] do |t, args| |
55 | | - mesg = commit_message(args[:no_commit_msg]) |
56 | | - sh "nanoc compile" |
| 55 | + message = commit_message(args[:no_commit_msg]) |
57 | 56 |
|
58 | | - # save precious files |
59 | | - if ENV['IS_HEROKU'] |
60 | | - `git fetch origin gh-pages` |
61 | | - `git checkout origin/gh-pages` |
62 | | - else |
63 | | - `git checkout gh-pages` |
64 | | - end |
65 | | - tmpdir = Dir.mktmpdir |
66 | | - FileUtils.cp_r("enterprise", tmpdir) |
67 | | - FileUtils.cp("robots.txt", tmpdir) |
68 | | - `git checkout master` |
69 | | - |
70 | | - ENV['GIT_DIR'] = File.expand_path(`git rev-parse --git-dir`.chomp) |
71 | | - ENV['RUBYOPT'] = nil |
72 | | - old_sha = `git rev-parse refs/remotes/origin/gh-pages`.chomp |
73 | | - Dir.chdir('output') do |
74 | | - ENV['GIT_INDEX_FILE'] = gif = '/tmp/dev.gh.i' |
75 | | - ENV['GIT_WORK_TREE'] = Dir.pwd |
76 | | - File.unlink(gif) if File.file?(gif) |
77 | | - # restore precious files |
78 | | - FileUtils.cp_r("#{tmpdir}/enterprise", ".") |
79 | | - FileUtils.cp("#{tmpdir}/robots.txt", ".") |
80 | | - FileUtils.rm_rf(tmpdir) if File.exists?(tmpdir) |
81 | | - `git add -A` |
82 | | - tsha = `git write-tree`.strip |
83 | | - puts "Created tree #{tsha}" |
84 | | - # Heroku runs [email protected], we don't have the luxury of -m |
85 | | - if ENV['IS_HEROKU'] |
86 | | - `echo #{mesg} > changelog` |
87 | | - csha = `git commit-tree #{tsha} -p #{old_sha} < changelog`.strip |
88 | | - elsif old_sha.size == 40 |
89 | | - csha = `git commit-tree #{tsha} -p #{old_sha} -m '#{mesg}'`.strip |
90 | | - else |
91 | | - csha = `git commit-tree #{tsha} -m '#{mesg}'`.strip |
92 | | - end |
93 | | - puts "Created commit #{csha}" |
94 | | - puts `git show #{csha} --stat` |
95 | | - puts "Updating gh-pages from #{old_sha}" |
96 | | - `git update-ref refs/heads/gh-pages #{csha}` |
97 | | - `git push origin gh-pages` |
| 57 | + Dir.mktmpdir do |tmp| |
| 58 | + system "mv output/* #{tmp}" |
| 59 | + system 'git checkout not-gh-pages' |
| 60 | + system "rsync -av #{tmp}/ ." |
| 61 | + system 'git add .' |
| 62 | + system "git commit -am #{message.shellescape}" |
| 63 | + system 'git push origin not-gh-pages --force' |
| 64 | + system 'git checkout master' |
98 | 65 | end |
99 | 66 | end |
0 commit comments