Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11187 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

[PATCH] Capistrano's Mercurial module doesn't support prompting for SCM passwords

Reported by: ches Assigned to: minam
Priority: normal Milestone: 2.x
Component: Capistrano Version: edge
Severity: minor Keywords: capistrano
Cc: jamis@37signals.com

Description

This patch addresses a handful of issues with the Mercurial module, the largest being the one in subject line.

The current Hg module requires that :scm_password be set in recipes if you're using a repository with HTTP authentication or SSH without a public key. Actually, the latter doesn't work correctly anyway, because the password regex in #handle_data doesn't catch the 'user@host.com's password:' style of prompt for SSH. I'm currently using HTTP auth on a project, and I don't want to put the password in plaintext in the recipe file. I suspect many others feel the same way =)

Also, the module uses :scm_user instead of the now-preferred :scm_username variable, and it has no unit tests.

The affixed patch addresses these issues as follows:

  • password regex uses word boundary instead of start-of-line, like some other SCM modules. This catches an SSH prompt or Mercurial's prompt for HTTP auth.
  • supports :scm_username with backwards compatibility for those who have :scm_user in existing recipes
  • honors Cap 2.1's :scm_prefer_prompt variable and will prompt for passwords if :scm_password is not set. If neither variable is set, falls back on the current behavior of raising an exception with an informative message.
  • provides unit tests for the module, including the new functionality above.

The patch was built against revision [8916]. I don't believe the module has changed since the 2.1 release, so the attached diff should apply cleanly to mercurial.rb for users of the 2.1 gem. I'll try to contact Matthew Elder as well.

Attachments

add_hg_password_prompt_and_tests.patch (6.4 kB) - added by ches on 02/21/08 22:09:15.
add_hg_password_prompt.diff (1.1 kB) - added by ches on 02/21/08 22:10:16.

Change History

02/21/08 22:09:15 changed by ches

  • attachment add_hg_password_prompt_and_tests.patch added.

02/21/08 22:10:16 changed by ches

  • attachment add_hg_password_prompt.diff added.

02/22/08 04:46:40 changed by ches

For anyone trying / testing this, I should note that I've had to use

default_run_options[:pty] = true

for password prompting to work on my systems, otherwise hg tries to run non-interactively.

02/22/08 16:33:07 changed by minam

  • cc set to jamis@37signals.com.

02/22/08 18:20:06 changed by matt@jupiter-labs.com

  • owner changed from minam to matt@jupiter-labs.com.
  • status changed from new to assigned.
  • severity changed from normal to minor.

Looks good to me guys, I am not up on the latest capistrano stuff. Yay for progress ;-) +1

02/22/08 18:21:41 changed by matt@jupiter-labs.com

  • owner changed from matt@jupiter-labs.com to minam.
  • status changed from assigned to new.

02/23/08 04:04:31 changed by minam

  • status changed from new to closed.
  • resolution set to fixed.

(In [8925]) Add support for password prompts for Mercurial SCM (closes #11187)