Skip to content

Commit f37cb25

Browse files
committed
Rake task allows for a different commit message
Without this commit, you cannot inform the rake task to push gh-pages to accept a different commit message. This is necessary in environment where commit messages have to be in specific formats. None of the system calls were checking the exit status of their respective commands. Not stopping on error means that the rake take can fail and you and your pipelines would not know.
1 parent 4a49f54 commit f37cb25

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

.rubocop.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,17 @@ AllCops:
1515
TargetRubyVersion: '3.1'
1616

1717
# Disabled
18+
Layout/LineLength:
19+
Max: 200
20+
21+
Lint/RedundantCopDisableDirective:
22+
Enabled: false
23+
24+
Metrics/BlockLength:
25+
Enabled: false
26+
1827
Style/ClassAndModuleChildren:
1928
Enabled: false
2029

21-
Layout/LineLength:
22-
Max: 200
30+
Style/SpecialGlobalVars:
31+
Enabled: false

lib/puppet-strings/tasks/gh_pages.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
Dir.chdir('doc') do
1313
system 'git checkout gh-pages'
14+
exit 1 unless $?.success?
1415
system 'git pull --rebase origin gh-pages'
16+
exit 1 unless $?.success?
1517
end
1618
else
1719
git_uri = `git config --get remote.origin.url`.strip
@@ -20,9 +22,13 @@
2022
Dir.mkdir('doc')
2123
Dir.chdir('doc') do
2224
system 'git init'
25+
exit 1 unless $?.success?
2326
system "git remote add origin #{git_uri}"
27+
exit 1 unless $?.success?
2428
system 'git pull origin gh-pages'
29+
exit 1 unless $?.success?
2530
system 'git checkout -b gh-pages'
31+
exit 1 unless $?.success?
2632
end
2733
end
2834
end
@@ -35,15 +41,23 @@
3541
end
3642
end
3743

38-
task :push do
44+
# Task to push the gh-pages branch. Argument :msg_prefix is the beginning
45+
# of the message and the actual commit will have "at Revision <git_sha>"
46+
# appended.
47+
task :push, [:msg_prefix] do |_t, args|
48+
msg_prefix = args[:msg_prefix] || '[strings] Generated Documentation Update'
49+
3950
output = `git describe --long 2>/dev/null`
4051
# If a project has never been tagged, fall back to latest SHA
4152
git_sha = output.empty? ? `git log --pretty=format:'%H' -n 1` : output
4253

4354
Dir.chdir('doc') do
4455
system 'git add .'
45-
system "git commit -m '[strings] Generated Documentation Update at Revision #{git_sha}'"
56+
exit 1 unless $?.success?
57+
system "git commit -m '#{msg_prefix} at Revision #{git_sha}'"
58+
# Do not check status of commit, as it will error if there are no changes.
4659
system 'git push origin gh-pages -f'
60+
exit 1 unless $?.success?
4761
end
4862
end
4963

0 commit comments

Comments
 (0)