Skip to content

Rake task allows for a different commit message #408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,17 @@ AllCops:
TargetRubyVersion: '3.1'

# Disabled
Layout/LineLength:
Max: 200

Lint/RedundantCopDisableDirective:
Enabled: false

Metrics/BlockLength:
Enabled: false

Style/ClassAndModuleChildren:
Enabled: false

Layout/LineLength:
Max: 200
Style/SpecialGlobalVars:
Enabled: false
18 changes: 16 additions & 2 deletions lib/puppet-strings/tasks/gh_pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

Dir.chdir('doc') do
system 'git checkout gh-pages'
exit 1 unless $?.success?
system 'git pull --rebase origin gh-pages'
exit 1 unless $?.success?
end
else
git_uri = `git config --get remote.origin.url`.strip
Expand All @@ -20,9 +22,13 @@
Dir.mkdir('doc')
Dir.chdir('doc') do
system 'git init'
exit 1 unless $?.success?
system "git remote add origin #{git_uri}"
exit 1 unless $?.success?
system 'git pull origin gh-pages'
exit 1 unless $?.success?
system 'git checkout -b gh-pages'
exit 1 unless $?.success?
end
end
end
Expand All @@ -35,15 +41,23 @@
end
end

task :push do
# Task to push the gh-pages branch. Argument :msg_prefix is the beginning
# of the message and the actual commit will have "at Revision <git_sha>"
# appended.
task :push, [:msg_prefix] do |_t, args|
msg_prefix = args[:msg_prefix] || '[strings] Generated Documentation Update'

output = `git describe --long 2>/dev/null`
# If a project has never been tagged, fall back to latest SHA
git_sha = output.empty? ? `git log --pretty=format:'%H' -n 1` : output

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

Expand Down