Skip to content

Commit

Permalink
Remove support for --password; implement password support with env var
Browse files Browse the repository at this point in the history
  • Loading branch information
icedream2linxi committed Sep 6, 2022
1 parent 6dac85a commit 86d3ea5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
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:
17 changes: 9 additions & 8 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

0 comments on commit 86d3ea5

Please sign in to comment.