diff --git a/lib/dpl/providers/pages.rb b/lib/dpl/providers/pages.rb index a26c7d1d4..7e571b14a 100644 --- a/lib/dpl/providers/pages.rb +++ b/lib/dpl/providers/pages.rb @@ -16,6 +16,7 @@ class Pages < Provider opt '--repo SLUG', 'Repo slug', default: :repo_slug opt '--target_branch BRANCH', 'Branch to push force to', default: 'gh-pages' opt '--keep_history', 'Create incremental commit instead of doing push force', default: true + opt '--commit_message MSG', default: 'Deploy %{project_name} to %{url}:%{target_branch}' opt '--allow_empty_commit', 'Allow an empty commit to be created', requires: :keep_history opt '--committer_from_gh', 'Use the token\'s owner name and email for commit. Overrides the email and name options' opt '--verbose', 'Be verbose about the deploy process' @@ -24,12 +25,9 @@ class Pages < Provider opt '--project_name NAME', 'Used in the commit message only (defaults to fqdn or the current repo slug)' opt '--email EMAIL', 'Committer email', default: 'deploy@travis-ci.org' opt '--name NAME', 'Committer name', default: 'Deploy Bot' - # what is the purpose of this file in the first place? a file name with - # spaces seems highly irregular, but this has been there from the start - # https://github.com/travis-ci/dpl/commit/58f6c7dd4f0fd49df2e93a8495fd01c7784d4f58#diff-cc5438ae072229825b07abf38951a912R47 opt '--deployment_file', 'Enable creation of a deployment-info file' - # not mentioned in the readme opt '--github_url URL', default: 'github.com' + # how about the octokit options? needs :git @@ -59,7 +57,7 @@ class Pages < Provider deployment_file: 'touch "deployed at %{now} by %{committer_name}"', cname: 'echo "%{fqdn}" > CNAME', git_add: 'git add -A .', - git_commit: 'git commit%{git_commit_opts} -qm "Deploy %{project_name} to %{url}:%{target_branch}"', + git_commit: 'git commit%{git_commit_opts} -qm "%{commit_message}"', git_show: 'git show --stat-count=10 HEAD', git_push: 'git push%{git_push_opts} --quiet "%{url_with_token}" "%{target_branch}":"%{target_branch}" > /dev/null 2>&1' @@ -162,6 +160,10 @@ def committer_email committer_from_gh? ? user.email || email : email end + def commit_message + interpolate(super) + end + def project_name super || fqdn || repo_slug end diff --git a/spec/dpl/providers/pages_spec.rb b/spec/dpl/providers/pages_spec.rb index b238b143b..3b021264f 100644 --- a/spec/dpl/providers/pages_spec.rb +++ b/spec/dpl/providers/pages_spec.rb @@ -5,8 +5,9 @@ let!(:cwd) { File.expand_path('.') } let(:tmp) { File.expand_path('tmp') } - before { stub_request(:get, 'https://api.github.com/user').and_return(status: 200, body: user, headers: headers) } + env FOO: 'foo' + before { stub_request(:get, 'https://api.github.com/user').and_return(status: 200, body: user, headers: headers) } before { subject.run } describe 'by default', record: true do @@ -88,4 +89,8 @@ describe 'given --email other' do it { should have_run 'git config user.email "other"' } end + + describe 'given --commit_message "msg %{repo} %{$FOO}"' do + it { should have_run 'git commit -qm "msg travis-ci/dpl foo"' } + end end