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.
fixture hack gets pluginized, caboose plugin repository lunches!
Courtenay : November 1st, 2006
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 svn keychain support
Courtenay : October 13th, 2006
Cached SVN checkouts save bandwidth
Liquid error: undefined method `login' for nil:NilClass : June 29th, 2006
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
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
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'