Skip to content

Add support for --password option #190

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

Merged
merged 1 commit into from
Apr 17, 2015
Merged
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
5 changes: 5 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ one of them.

$ svn2git http://svn.example.com/path/to/repo --username <<user_with_perms>>

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>>

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

$ svn2git http://svn.example.com/path/to/repo --revision <<starting_revision_number>>
Expand Down Expand Up @@ -202,6 +206,7 @@ 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)
--tags TAGS_PATH Subpath to tags from repository URL (default: tags)
Expand Down
8 changes: 8 additions & 0 deletions lib/svn2git/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ 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 @@ -74,6 +75,10 @@ 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 @@ -172,11 +177,13 @@ 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 @@ -189,6 +196,7 @@ 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