forked from Katello/katello
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_doc.rb
executable file
·45 lines (36 loc) · 970 Bytes
/
update_doc.rb
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
#!/usr/bin/env ruby
root = File.expand_path '..', File.dirname(__FILE__)
unless (ARGV & %w[-h --help]).empty?
print <<-USAGE
Usage: update_doc.rb [push]
add 'push' if you want to push changes to github Katello/katello gh-pages
USAGE
exit 0
end
push_to_github = (ARGV == %w(push))
def cmd(cmd)
puts ">> #{cmd}"
fail "#{cmd} failed" unless system(cmd)
end
unless File.exist? "#{root}/yardoc/.git"
Dir.chdir "#{root}/yardoc" do
cmd 'git clone --single-branch --branch gh-pages [email protected]:Katello/katello.git .'
end
end
Dir.chdir "#{root}/yardoc" do
cmd 'git checkout gh-pages'
cmd 'git fetch origin'
cmd 'git reset --hard origin/gh-pages'
end
message = nil
Dir.chdir(root) do
puts "commit message: #{message = `git log -n 1 --oneline`.strip}"
cmd 'yard doc --no-cache'
end
Dir.chdir "#{root}/yardoc" do
cmd 'git add --all'
cmd "git commit -m '#{message}'"
if push_to_github
cmd 'git push origin gh-pages'
end
end