Skip to content

Remove support for --password; implement password support with env var #305

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ChangeLog.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 2.4.1 - 2021-12-17

Since 'git-svn' does not support '--password' anymore, this release modifies the mechanism to supply a password when needed.

* Removed support for '--password' option (jesteves; PR merge pending).
* Added support for detecting and using the value of the environment variable 'SVN2GIT_PASSWORD' when `svn git` is invoked (jesteves; PR merge pending).
# 2.4.0 - 2016-10-30

This release introduces the ability to supply a password for SVN repositories that can't authenticate by other means.
Expand Down
4 changes: 2 additions & 2 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ one of them.

If this doesn't cooperate and you need to specify a password on the command-line:

$ svn2git http://svn.example.com/path/to/repo --username <<user_with_perms>> --password <<password>>
$ # define environment variable SVN2GIT_PASSWORD=<<password>> according to shell syntax
$ svn2git http://svn.example.com/path/to/repo --username <<user_with_perms>>

8. You need to migrate starting at a specific svn revision number.

Expand Down Expand Up @@ -206,7 +207,6 @@ Options Reference
Specific options:
--rebase Instead of cloning a new project, rebase an existing one against SVN
--username NAME Username for transports that needs it (http(s), svn)
--password PASS Password for transports that needs it (http(s), svn)
--trunk TRUNK_PATH Subpath to trunk from repository URL (default: trunk)
--branches BRANCHES_PATH Subpath to branches from repository URL (default: branches); can be used multiple times
--tags TAGS_PATH Subpath to tags from repository URL (default: tags); can be used multiple times
Expand Down
2 changes: 1 addition & 1 deletion VERSION.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
:major: 2
:minor: 4
:patch: 0
:patch: 1
:build:
19 changes: 10 additions & 9 deletions lib/svn2git/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def parse(args)
options[:exclude] = []
options[:revision] = nil
options[:username] = nil
options[:password] = nil
options[:rebasebranch] = false

if File.exists?(File.expand_path(DEFAULT_AUTHORS_FILE))
Expand All @@ -75,10 +74,6 @@ def parse(args)
options[:username] = username
end

opts.on('--password PASSWORD', 'Password for transports that need it (http(s), svn)') do |password|
options[:password] = password
end

opts.on('--trunk TRUNK_PATH', 'Subpath to trunk from repository URL (default: trunk)') do |trunk|
options[:trunk] = trunk
end
Expand Down Expand Up @@ -177,13 +172,11 @@ def clone!
exclude = @options[:exclude]
revision = @options[:revision]
username = @options[:username]
password = @options[:password]

if rootistrunk
# Non-standard repository layout. The repository root is effectively 'trunk.'
cmd = "git svn init --prefix=svn/ "
cmd += "--username='#{username}' " unless username.nil?
cmd += "--password='#{password}' " unless password.nil?
cmd += "--no-metadata " unless metadata
if nominimizeurl
cmd += "--no-minimize-url "
Expand All @@ -196,7 +189,6 @@ def clone!

# Add each component to the command that was passed as an argument.
cmd += "--username='#{username}' " unless username.nil?
cmd += "--password='#{password}' " unless password.nil?
cmd += "--no-metadata " unless metadata
if nominimizeurl
cmd += "--no-minimize-url "
Expand Down Expand Up @@ -393,6 +385,15 @@ def optimize_repos
end

def run_command(cmd, exit_on_error=true, printout_output=false)
if ( ( cmd =~ /^git[ ]svn/ ) and ( ENV.key?('SVN2GIT_PASSWORD') ) )
password = ENV['SVN2GIT_PASSWORD']
cmd = "echo #{password} | " + cmd
end

_run_command( cmd, exit_on_error, printout_output )
end

def _run_command(cmd, exit_on_error=true, printout_output=false)
log "Running command: #{cmd}\n"

ret = ''
Expand Down Expand Up @@ -434,7 +435,7 @@ def run_command(cmd, exit_on_error=true, printout_output=false)

# nil is our cue to stop looping (pun intended).
break if user_reply.nil?

stdin.puts user_reply
stdin.close
end
Expand Down