-
-
Save darrend/442184 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/bin/ruby | |
# First stab at a svn log watcher for user ohnojoe. | |
# SvnRecord also allows you to easily extend the script to match on certain file names/package names | |
# that you want to watch. | |
SVN_CMD = 'svn log -l 30 -v https://my.svn.server.com/Project/branches/' | |
FILE_MATCH = '\/branches\/.*' | |
USERS_WATCHED = %w{ ohnojoe } | |
class SvnRecord | |
attr_accessor :rev, :user, :date, :files | |
def initialize( parms ) | |
@files = [] | |
parse_parms( parms ) | |
end | |
def parse_parms( parms ) | |
@rev, @user, @date = *parms.delete_at(0).split('|').collect { |l| l.strip } | |
parms.each do |l| | |
if l.match /(.*)(#{FILE_MATCH})/ | |
@files << l | |
end | |
end | |
end | |
def to_s | |
"#{@user}, #{@rev}, #{files.size} files changed." | |
end | |
end | |
def process_svn_log | |
res = %x{#{SVN_CMD}} | |
creating_rec = false | |
rec = [] | |
records = [] | |
res.each do |l| | |
if l.match /\A--------+/ | |
unless creating_rec | |
creating_rec = true | |
rec = [] | |
else | |
creating_rec = false | |
records << SvnRecord.new(rec) | |
end | |
elsif creating_rec | |
rec << l.chomp | |
end | |
end | |
records | |
end | |
records = process_svn_log | |
records.each do |x| | |
if USERS_WATCHED.include?(x.user) | |
puts x | |
puts x.files | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment