Uh oh!
There was an error while loading. Please reload this page.
forked from github/developer.github.com
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
Latest commit
83 lines (73 loc) · 2.5 KB
/
Copy pathRakefile
File metadata and controls
83 lines (73 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
require'nanoc3/tasks'
require'tmpdir'
task:default=>[:test]
desc"Compile the site"
task:compiledo
`nanoc compile`
end
desc"Test the output"
task:test=>[:clean,:remove_output_dir,:compile]do
require'html/proofer'
HTML::Proofer.new("./output").run
end
desc"Remove the output dir"
task:remove_output_dirdo
FileUtils.rm_r('output')ifFile.exist?('output')
end
# Prompt user for a commit message; default: P U B L I S H :emoji:
defcommit_message(no_commit_msg=false)
publish_emojis=[':boom:',':rocket:',':metal:',':bulb:',':zap:',
':sailboat:',':gift:',':ship:',':shipit:',':sparkles:',':rainbow:']
default_message="P U B L I S H #{publish_emojis.sample}"
unlessno_commit_msg
print"Enter a commit message (default: '#{default_message}'): "
STDOUT.flush
mesg=STDIN.gets.chomp.strip
end
mesg=default_messageifmesg.nil? || mesg == ''
mesg.gsub(/'/,'')# Allow this to be handed off via -m '#{message}'
end
desc"Publish to http://developer.github.com"
task:publish,[:no_commit_msg]=>[:clean,:remove_output_dir]do |t,args|
mesg=commit_message(args[:no_commit_msg])
sh"nanoc compile"
# save precious files
ifENV['IS_HEROKU']
`git checkout origin/gh-pages`
else
`git checkout gh-pages`
end
tmpdir=Dir.mktmpdir
FileUtils.cp_r("enterprise",tmpdir)
FileUtils.cp("robots.txt",tmpdir)
`git checkout master`
ENV['GIT_DIR']=File.expand_path(`git rev-parse --git-dir`.chomp)
ENV['RUBYOPT']=nil
old_sha=`git rev-parse refs/remotes/origin/gh-pages`.chomp
Dir.chdir('output')do
ENV['GIT_INDEX_FILE']=gif='/tmp/dev.gh.i'
ENV['GIT_WORK_TREE']=Dir.pwd
File.unlink(gif)ifFile.file?(gif)
# restore precious files
FileUtils.cp_r("#{tmpdir}/enterprise",".")
FileUtils.cp("#{tmpdir}/robots.txt",".")
FileUtils.rm_rf(tmpdir)ifFile.exists?(tmpdir)
`git add -A`
tsha=`git write-tree`.strip
puts"Created tree #{tsha}"
# Heroku runs git@1.7, we don't have the luxury of -m
ifENV['IS_HEROKU']
`echo #{mesg} > changelog`
csha=`git commit-tree #{tsha} -p #{old_sha} < changelog`.strip
elsifold_sha.size == 40
csha=`git commit-tree #{tsha} -p #{old_sha} -m '#{mesg}'`.strip
else
csha=`git commit-tree #{tsha} -m '#{mesg}'`.strip
end
puts"Created commit #{csha}"
puts`git show #{csha} --stat`
puts"Updating gh-pages from #{old_sha}"
`git update-ref refs/heads/gh-pages #{csha}`
`git push origin gh-pages`
end
end