Extract last_known_revision logic to Deployment class

This should fix the Rubocop errors as well.