Skip to content

Commit 86d3ea5

Browse files
Remove support for --password; implement password support with env var
nirvdrum#305
1 parent 6dac85a commit 86d3ea5

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

ChangeLog.markdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 2.4.1 - 2021-12-17
2+
3+
Since 'git-svn' does not support '--password' anymore, this release modifies the mechanism to supply a password when needed.
4+
5+
* Removed support for '--password' option (jesteves; PR merge pending).
6+
* Added support for detecting and using the value of the environment variable 'SVN2GIT_PASSWORD' when `svn git` is invoked (jesteves; PR merge pending).
17
# 2.4.0 - 2016-10-30
28

39
This release introduces the ability to supply a password for SVN repositories that can't authenticate by other means.

README.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ one of them.
120120

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

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

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

@@ -206,7 +207,6 @@ Options Reference
206207
Specific options:
207208
--rebase Instead of cloning a new project, rebase an existing one against SVN
208209
--username NAME Username for transports that needs it (http(s), svn)
209-
--password PASS Password for transports that needs it (http(s), svn)
210210
--trunk TRUNK_PATH Subpath to trunk from repository URL (default: trunk)
211211
--branches BRANCHES_PATH Subpath to branches from repository URL (default: branches); can be used multiple times
212212
--tags TAGS_PATH Subpath to tags from repository URL (default: tags); can be used multiple times

VERSION.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
:major: 2
33
:minor: 4
4-
:patch: 0
4+
:patch: 1
55
:build:

lib/svn2git/migration.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def parse(args)
5252
options[:exclude] = []
5353
options[:revision] = nil
5454
options[:username] = nil
55-
options[:password] = nil
5655
options[:rebasebranch] = false
5756

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

78-
opts.on('--password PASSWORD', 'Password for transports that need it (http(s), svn)') do |password|
79-
options[:password] = password
80-
end
81-
8277
opts.on('--trunk TRUNK_PATH', 'Subpath to trunk from repository URL (default: trunk)') do |trunk|
8378
options[:trunk] = trunk
8479
end
@@ -177,13 +172,11 @@ def clone!
177172
exclude = @options[:exclude]
178173
revision = @options[:revision]
179174
username = @options[:username]
180-
password = @options[:password]
181175

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

197190
# Add each component to the command that was passed as an argument.
198191
cmd += "--username='#{username}' " unless username.nil?
199-
cmd += "--password='#{password}' " unless password.nil?
200192
cmd += "--no-metadata " unless metadata
201193
if nominimizeurl
202194
cmd += "--no-minimize-url "
@@ -393,6 +385,15 @@ def optimize_repos
393385
end
394386

395387
def run_command(cmd, exit_on_error=true, printout_output=false)
388+
if ( ( cmd =~ /^git[ ]svn/ ) and ( ENV.key?('SVN2GIT_PASSWORD') ) )
389+
password = ENV['SVN2GIT_PASSWORD']
390+
cmd = "echo #{password} | " + cmd
391+
end
392+
393+
_run_command( cmd, exit_on_error, printout_output )
394+
end
395+
396+
def _run_command(cmd, exit_on_error=true, printout_output=false)
396397
log "Running command: #{cmd}\n"
397398

398399
ret = ''

0 commit comments

Comments
 (0)