def set_component project, config, opts, issue, maybe_component
puts "Changing the component of issue #{issue.name}: #{issue.title}."
if project.components.size == 1
raise Error, "this project does not use multiple components"
end
if maybe_component && maybe_component.name == issue.component
raise Error, "issue #{issue.name} already assigned to component #{issue.component}"
end
component = maybe_component || begin
components = project.components
components -= [components.find { |r| r.name == issue.component }] if issue.component
ask_for_selection(components, "component") { |r| r.name }
end
issue.assign_to_component component, config.user, get_comment(opts)
oldname = issue.name
project.assign_issue_names!
puts "Issue \#{oldname} is now \#{issue.name}. Note that the names of other issues may\nhave changed as well.\n"
end