subversion tip

Courtenay : March 6th, 2007

If your project contains svn:ignores for files like *.tmproj or other junk files created by your IDE or editor, then you need to move those ignores to your global subversion configuration (non-windows only). This is because, on a project, you may have four different developers littering the project with their own project-file ignores, and the app’s repository really isn’t the place.

Since a bunch of people in #caboose hadn’t seen this file, I thought it prudent to mention here.

Open up ~/.subversion/config and marvel at the options, then scroll down to about line 54 where it starts, “global-ignores”. Mine looks like this. It includes some logs, the database.yml file, and some AFP junk files.

global-ignores = ._* *.log *.html-gzip-* mongrel_log database.yml *.rej .AppleDouble .DS_Store

Once a file is in here, svn st will never see it again.

Mmm.. lunch! They're not accepting new features into rails until after 1.2 is out, so I pluginized the awesome fixtures hack that lets you do

id: 1
  user: :joe
  name: stuff
in your fixtures. Give it a twirl and tell me if it works..! Remember you have to handle dependencies yourself, so fixtures :users, :products, :monkeys if they all rely on each other

script/plugin install svn://caboo.se/plugins/court3nay/awesome_fixtures
This is all viewable on the caboose svn repo ebola collaboa. If you're a facebook 'booser, login and it (should) give you ticketing access. It's a nasty hack that does the grunt work. Let me know if you have a plugin you want caboose svn hosted and I'll give you some authz.

svn keychain support

Courtenay : October 13th, 2006

Don't know if any of you saw this.. "http://www.friday.com/bbum/2006/09/12/subversion-14-adds-keychain-support/":http://www.friday.com/bbum/2006/09/12/subversion-14-adds-keychain-support/ from the page: "Quite easy, but not automatic. If you remember all of your repository passwords, simply delete the ~/.subversion/auth/svn.simple directory." woot. combined with ssh keychain, there's almost nowhere to type passwords any more. Now, if only I could get cap deploys working properly.. update: download the binary package from "http://www.codingmonkeys.de/mbo/articles/2006/09/13/subversion-1-4-0":http://www.codingmonkeys.de/mbo/articles/2006/09/13/subversion-1-4-0

Cached SVN checkouts save bandwidth

Liquid error: undefined method `login' for nil:NilClass : June 29th, 2006

In the past I've deployed apps by hand. Logging into a server, svn uping, and restarting didn't seem to be such a big deal most days. Recently I got my first "Rails Machine":http://www.railsmachine.com/ account and set about learning Capistrano. Now I'm sold on the Capistrano way of life, but man, full SVN checkouts of Rails apps over dial-up is a slow process. I was talking in channel one day and octopod shared "http://pastie.caboo.se/1738":http://pastie.caboo.se/1738 with me. I finally got around to using it and since I plan on using it for all my apps I broke it off into a separate file you can simply include and use like this:
require 'config/cache_svn'

set :repository, "svn://your.repository/path/here"
set :repository_cache, "#{shared_path}/svn_trunk/"
h2. Download the source *Updated:* Made changes to source to take "Blake Walter's fix":http://thatswhatimtalkingabout.org/news/2006/8/10/cached-svn-for-capistrano-upgrade into account. The magic that makes it work - "svn_cache.rb":http://pastie.caboo.se/2973

Meet Marshmallow, the campfire Bot

Courtenay : April 14th, 2006

With financial sponsorship by "CollectiveX":http://collectivex.com, I'm proud to announce the release of Marshmallow.

script/plugin install svn://collectivex.net/plugins/marshmallow
Please view the README for instructions. I except this won't work for many of you because it was kinda hacked out of our codebase.

bot = Marshmallow.new(:domain => 'yoursubdomain')
bot.login( :url => 'u2Dsa' )
bot.say("ponies!!")
bot.paste("your code\n here")
Once the bot is connected, you can keep using say or paste. You may like to wrap it all in a fork { } so it doesn't slow down your app while connecting. h2. adding deploy notifications Here are some pseudo-patches for y'all: Edit your capistrano deploy.rb and change these lines:

task :after_Deploy ....
+ snitch_campfire
end

task :snitch_campfire
  bot = Marshmallow.new(:domain => 'yourdomain')
  bot.login( :url => 'WDs3S' )
  bot.say("DEPLOY NOTICE: #{ENV['USER']} deployed rev #{revision} to #{ENV['DEPLOY_TYPE']}")
end
h2. add a post-commit hook Add this to your subversion repo's post-commit file

#!/usr/bin/env ruby
require '/path/to/marshmallow'

svnlook = "/usr/local/bin/svnlook"
bot = Marshmallow.new(:domain => 'yourdomain')
bot.login( :url => 'AsDf4' )
if ARGV.size > 1
  revision = ARGV[1]
  path = ARGV[0]
        
  author = `#{svnlook} author -r #{revision} #{path}`
  paths  = `#{svnlook} changed -r #{revision} #{path}`
  log    = `#{svnlook} log -r #{revision} #{path}`
  message = [log,paths].join.strip
  url = "Changeset \##{revision} by #{author} (http://www.your.scm.tracker.url/repository/changesets/#{revision})"       
  bot.say(url)
  bot.say(message, true)
else
  bot.say(ARGV[0])
end

We're welcoming contributions, so please send 'em our way!!

haxoring campfire: or, roll your own api

Courtenay : April 6th, 2006

wanna write your own api to a service that doesn't offer one (*cough* campfire) Here's how we went about writing a subversion post-commit bot for campfire.. Get out there and make some cool services!

step one:

set up a http request to grab some authentication.

#!/usr/bin/ruby
require 'net/http'
require 'open-uri'
require 'cgi'

domain = "yoursite.campfirenow.com"
sekrit_invite_link = "12345"

req = Net::HTTP::Post.new("#{domain}/#{sekrit_invite_link}")
req.set_form_data({'name' => 'my_bot', 'remember' => 'ON'})
res = Net::HTTP.new(domain, 80).start { |http| http.request(req) }

step two:

grab the cookie out of the response, as well as the room's location

room_id = res['location'].scan(/room\/(\d+)/).to_s
req2 = Net::HTTP::Get.new(res['location'])
req2.initialize_http_header({'Cookie'=>res['set-cookie']})
res2 = Net::HTTP.new(domain, 80).start { |http| http.request(req2) }

step three:

post a message to the room!

message = "Monkeys rule!"
req3 = Net::HTTP::Get.new("/room/#{room_id}/speak?message=#{CGI.escape(message)}")
req3.initialize_http_header({'Cookie'=>res2['set-cookie']})
res3 = Net::HTTP.new(domain, 80).start { |http| http.request(req3) }

Step four

customize your bot. For a subversion monkey, that last step starts something like

author = "Author: " + `#{svnlook} author -r #{ARGV[1]} #{ARGV[0]}`
paths  = `#{svnlook} changed -r #{ARGV[1]} #{ARGV[0]}`
log    = `#{svnlook} log -r #{ARGV[1]} #{ARGV[0]}`
message = [author, paths, log].join("\r\n")
req3 = Net::HTTP::Get.new("/room/#{room_id}/speak?paste=true&message=#{CGI.escape(message)}")
The paste=true is important because it tells campfire to display the message as a "paste".

The lesson

Give us an API, or we'll write our own! Oh yeah, and if the service requires ajax? Hah, we can fake it!

req.add_field 'X-Requested-With', 'XMLHttpRequest'
req.add_field 'X-Prototype-Version', '1.5.0_pre0'

svn mv dir/* ./

Liquid error: undefined method `login' for nil:NilClass : December 15th, 2005

That's not going to work as [Subversion](http://subversion.org/ "Subversion homepage") can only move one thing at a time, be it a folder or a file. The solution is to use your shell: for I in html/*; do svn mv $I ./; done