Skip to content
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

Fix a few bugs with the changelog creation script #13020

Merged
merged 4 commits into from Feb 3, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions bin/create-release
Expand Up @@ -24,8 +24,9 @@ def git_generate_changelog
end

relevant_matches = matches.select do |match|
# ignore merges from our various server branches
!match.nil? && !['staging', 'test', 'levelbuilder'].include?(match['branch'])
# ignore merges from staging and test, which represent standard
# deploy operations
!match.nil? && !['staging', 'test'].include?(match['branch'])
end

items = relevant_matches.map do |match|
Expand Down
10 changes: 8 additions & 2 deletions bin/dotd
Expand Up @@ -68,13 +68,19 @@ def open_in_default_browser(url)
end
end

def run_on(server_name, command)
# escape any double quotes in the command string
command = %Q["#{command}"]
system "ssh -t gateway.code.org ssh -t #{server_name} \"#{command}\""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does ruby implicitly handle escaping pre-escaped quotes when it interpolates here? If not, I worry you'll get

def run_on(server_name, command) # command='my "command"'
  command = %Q["#{command}"] # command='my \"command\"'
  system "ssh -t gateway.code.org ssh -t #{server_name} \"#{command}\""
  # 'ssh -t gateway.code.org ssh -t server \"my \"command\"\"'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I thought it did, because the script worked despite the content push step having nested quotes, but upon closer inspection it looks like what you have above is exactly what we'd get.

In other words, I'm not actually sure what's going on here. I'll investigate more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, I forgot that we're going up through two levels of server, so we actually need that many levels of escaping; as it turns out, we weren't actually wrapping user_name in quotes in our original call to content-push; giving it a name with whitespace would cause it to blow up.

No longer!

end

def content_push(server_name, environment_name, user_name)
puts <<-EOS.unindent
Follow the prompts given by the content-push script.
If you need to do something fancier (or if the changed files do not
"look ok" when it asks you), log in to staging and hand-craft the commit.
EOS
success = system "ssh -t gateway.code.org ssh -t #{server_name} \"#{environment_name}/bin/content-push --name=\\\"#{user_name}\\\"\""
success = run_on(server_name, "#{environment_name}/bin/content-push --name=\"#{user_name}\"")

# Notice if the content push fails, and be helpful about fixing the problem.
unless success
Expand Down Expand Up @@ -167,7 +173,7 @@ should_i "DTP" do

should_i "create a new release of the code-dot-org repository on github" do
wait_for "the production server to fetch the latest changes"
system "ssh -t gateway.code.org ssh -t \"production-daemon \\\"cd production; ./bin/create-release\\\"\""
run_on("production-daemon", "cd production; ./bin/create-release")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

end

wait_for "DTP to finish"
Expand Down