Code tagged with svn

Ruby script for creating new rails project and initial SVN import

require 'fileutils'

puts  "########################################"
puts  "This script creates a new rails project and do the initial svn import with ignoring/deleting files from subversion"
puts  "Please send your feedback to Akhil Bansal"
puts  "I have tested this script and it works great on my system."
puts  ""
puts  ""
puts  "                    ###### ATTENTION #######"
puts  ""
puts  ""
puts  "Use this script at your own risk, if your computer explodes its not my fault :-) "
puts  "#######################################"

puts  "Enter svn username: "
username = gets.strip
puts  "Enter the svn url: "
svn_url =gets.strip

puts  "Enter Rails Application Path:(eg: /home/akhil/ror): "
app_path = gets.strip
puts  "Enter Application Name: "
app_name = gets.strip

puts  "######################################"


puts  "Please verify the following variables: "
puts  "Svn Username: #{username}"
puts  "Svn URL: #{svn_url}"
puts  "Application Path: #{app_path}"
puts  "Application name: #{app_name}"

puts  "Proceed (y/n)"
proceed = gets
proceed = proceed.strip.upcase
if proceed == 'N' 
    puts  "Terminating..."
    exit 0
elsif proceed == 'Y' 
    if system("rails -v")
      s="/"
    elsif   system("rails.cmd -v")
      s="\\"
    else
        puts "Cannot find rails. Terminating..."
        exit 0
    end    
    app_root=app_path+s+ app_name
    
    puts  "Generating rails project: (#{app_root})"
    if system("rails #{app_root}")
      s="/"
    elsif   system("rails.cmd #{app_root}")
      s="\\"
    else
        puts "Cannot create rails project. Terminating..."
        exit 0
    end    
    
    puts  "SVNinitial import: "
    system("svn import #{app_root} #{svn_url} -m \"Initial Import\" --username #{username}")
   
    FileUtils.remove_dir(app_root, true)
   
    puts  "Checking out from svn: "

    system("svn checkout #{svn_url} #{app_root}")
    FileUtils.cd(app_root, :verbose => true)
    
    puts  "Removing all log files from SVN"
    system("svn remove log"+s+"*")
    puts  "commiting..."
    system("svn commit -m \"removing all log files from subversion \" ")
    puts  "Ignoring all log files under log dir"
    system("svn propset svn:ignore \"*.log\" log"+s)
    puts  "Updating and commiting..."
    system("svn update log"+s)
    system("svn commit -m \"Ignoring all files in "+s+"log"+s+" ending in .log \" ")
    puts  "Removing tmp directory from SVN"
    system("svn remove tmp"+s)
    puts  "commiting..."
    system("svn commit -m \"removing the temp directory from subversion \" ")
    puts  "Ignoring tmp dir"
    system("svn propset svn:ignore \"*\" tmp"+s)
    puts  "Updating and commiting again...."

    system("svn update tmp"+s)
    system("svn commit -m \"Ignore the whole tmp"+s+" directory, might not work on subdirectories? \" ")
    puts  "Moving database.yml to database.example"
    system("svn move config"+s+"database.yml config"+s+"database.example")
    puts  "commiting..."
    system("svn commit -m \"Moving database.yml to database.example to provide a template for anyone who checks out the code \" ")
    puts  "Ignoring database.yml , updating and commiting..."
    system("svn propset svn:ignore 'database.yml' config"+s)
    system("svn update config"+s)
    system("svn commit -m \"Ignoring database.yml\" ")
    puts  "Finished."

else
    puts  "Unknown Input. Terminating..."
	exit 0
end
Language Ruby / Tagged with ruby, rails, svn, subversion

Using a different username with SVN+SSH

Posted by Chad Humphries about 1 year ago
To get around this problem, you can setup per host SSH settings. To do this, open ~/.ssh/config and at the end add the lines 
Host svn.yourserver.com 
User jdoe 
This makes it so that everytime I connect to svn.yourserver.com with SSH, it will automatically use the username jdoe instead of my unix username. 

If you are prompted for a private key password 

This will look something like: 
Enter passphrase for key '/home/jdoe/.ssh/id_dsa': 
To get around this you can either setup ssh-agent to cache this password or you can simply turn off the password on your private key. To do the latter, simply type: 
ssh-keygen -t dsa -p 
and follow the prompts, and when it prompts for a new passphrase, simply hit enter.
Language Unknown / Tagged with svn, ssh