SiKaNrOnG.com
Agile Developer Extraordinaire
Blog
Subversion Checkout Hooks in RUBY!September - 04 - 2007 |
|---|
|
Well, I promised to share these kinds of things with the community when i wrote this blog code, so here we go.. Basically, the problem is this: Subversion is great version control software. You can even configure it with hooks so that when someone commits to a repo you can write the file:
/repo_parent_path/repo/hooks/pre-commit.tmpland the script will be executed (like the tell-tale filename says) pre-commit. So, the hooks folder by default looks like this: ~/Desktop/repo/hooks $ ls post-commit.tmpl pre-lock.tmpl post-lock.tmpl pre-revprop-change.tmpl post-revprop-change.tmpl pre-unlock.tmpl post-unlock.tmpl start-commit.tmpl pre-commit.tmplWoah woah WOAH! What's missing up there? How about like HALF the BATTLE!! Where did pre-checkout and post-checkout go? Where did pre/post-udate go? NOWHERE! The never existed (cruelty!!) So now you're like, crap - what do i do with my poor ruby app, do i go back to my boss and tell him it can't be done? Nay, friends. It can be done.. Basically, you're going to take advantage of the apache2 CustomLog directive, located in mod_log_config apache2 module. Anyway, here's the snippet from my default site apache conf file. I'm using OS X, with a fink install of apache2, so the file I'm about to show you the excerpt from might be in a different location on your machine:
# excerpt from /sw/etc/apache2/sites-available/default
CustomLog "|/sw/var/www/svnhook_dispatch.rb" "%{SVN-ACTION}e\t%U" env=SVN-ACTION
Notice that I've put the CustomLog directive OUTSIDE the <Location> block. Also notice the pipe in the CustomLog line. This means (in roughtly translated english) pipe each new value from env SVN-ACTION to /sw/var/www/svnhook_dispatch.rb as it comes in. So, what does /sw/var/www/svnhook_dispatch.rb have in it? Good question:
#!/opt/local/bin/ruby
#########################################################
## This is my solution to the stupid lack of checkout ##
## hooks in subversion. I'm to lazy too submit a patch.##
## Someone should. Until then, enjoy. ##
#########################################################
# Yeah. It only works for SVNParentPath. Sorry :) repos_dir
# is equivalent to that dir. Dispatch dir is the dir of this file.
# equally, you could do `pwd`. But, i didn't.
repos_dir = "/Library/WebServer/localhost/adhearsion.com/repos/"
dispatch_dir = "/sw/var/www/"
while ln = gets
#Cleans it up a bit by splitting off some unnecessary spaces and data
params = ln.strip
params_ar = params.split("\t")
@svn_action = params_ar[0].split[0] #take off useless checkout dir
@svn_unix_name = params_ar[1].split('/')[2] #assign unix name
# Records in dispatch logfile, actually records a high-level log of
# Your subversion stuff in dispatch_log.txt
`echo #{params} >> #{dispatch_dir}dispatch_log.txt;`
#Path to the appropriate hook file
@hook_location = "#{repos_dir}#{@svn_unix_name}/hooks/pre-#{@svn_action}.tmpl"
# Call the script!
#script_out = `/Users/alexanderpilafian/localhost/adhearsion.com/repos/sublime/hooks/test_me.rb`
script_out = `#{@hook_location}`
#################################################################
## uncomment these lines to output some test debugging info ##
## to debug.out (You gotta touch debug.out first) ##
#################################################################
#outstr = "\nAction: #{@svn_action}\n" +
#"Repo: #{@svn_unix_name}\n" +
#"File: #{@hook_location}\n" +
#"Script Out: \r\n#{script_out}\n"
#`echo '#{outstr}' >> #{dispatch_dir}debug.out;`
end
So, most of this is comments, but basically it gets the new log entry, which looks plenty like
update / /svn/sickofthis/!svn/vcc/defaultAnd it gets the action and name of the repo. Then it calls the command /path_to_repo/hooks/pre-{action_name}.tmpl
where action_name will either be "update" or "checkout-or-export". Basically, once you get apache all configured and running right with it, it'll be just like SUBVERSION WAS WRITTEN RIGHT ALL ALONG! Also, please note that although all I've included in my log is the action and repo location, you can get a lot more information out of it. If you need it, look at the tutorial that does this with php at http://www.ryandesign.com/svnhookdispatcher/
|










cjphfrpd xljngbtu http://cwqjaliw.com iqygrkso ymqfuiyk [URL=http://qxveodac.com]splkysun[/URL]
Every moment of one's existence one is growing into more or retreating into less.
The place of the father in the modern suburban family is a very small one, particularly if he plays golf.
There is nothing more dreadful than imagination without taste.
The only way to get rid of a temptation is to yield to it.
Nothing great in the world has been accomplished without passion.
Students achieving Oneness will move on to Twoness.
If you think taking care of yourself is selfish, change your mind. If you don't, you're simply ducking your responsibilities.
Nothing is particularly hard if you divide it into small jobs.
Everyone wants to be Cary Grant. Even I want to be Cary Grant.
The happiest is the person who suffers the least pain; the most miserable who enjoys the least pleasure.
The bitterest tears shed over graves are for words left unsaid and deeds left undone.
People fail forward to success.
Worries go down better with soup than without.
The aim of life is self-development. To realize one's nature perfectly - that is what each of us is here for.
There isn?t much better in this life than finding a way to spend a few hours in conversation with people you respect and love. You have to carve this time out of your life because you aren?t really living without it.
The most erroneous stories are those we think we know best - and therefore never scrutinize or question.
Always seek out the seed of triumph in every adversity.
Genius is one per cent inspiration, ninety-nine per cent perspiration.
Paradise is exactly like where you are right now... only much, much better.
Look at all the sentences which seem true and question them.
Life is pleasant. Death is peaceful. It's the transition that's troublesome.
I ran the wrong kind of business, but I did it with integrity.
Students achieving Oneness will move on to Twoness.
I don't own a cell phone or a pager. I just hang around everyone I know, all the time. If someone wants to get a hold of me, they just say 'Mitch,' and I say 'what?' and turn my head slightly.
I said to myself, I have things in my head that are not like what anyone has taught me - shapes and ideas so near to me - so natural to my way of being and thinking that it hasn't occurred to me to put them down. I decided to start anew, to strip away what I had been taught.
Nothing is particularly hard if you divide it into small jobs.
If you don't know where you are going, you will probably end up somewhere else.
I know that you believe that you understood what you think I said, but I am not sure you realize that what you heard is not what I meant.
I have always felt that a politician is to be judged by the animosities he excites among his opponents.
If you want creative workers, give them enough time to play.
The trouble with being poor is that it takes up all of your time.
Write down the advice of him who loves you, though you like it not at present.
Meetings are indispensable when you don't want to do anything.
lemrtrhl [URL=http://yzbimcmz.com]npndmmdq[/URL] imvxpqcq http://ntpxjkhj.com digfzdrb oonawaly
The reward of a thing well done is to have done it.
Insanity: doing the same thing over and over again and expecting different results.
Each individual woman's body demands to be accepted on its own terms.
There?s so much comedy on television. Does that cause comedy in the streets?
Procrastination is the art of keeping up with yesterday.
There are plenty of good five-cent cigars in the country. The trouble is they cost a quarter. What this country needs is a good five-cent nickel.
Get away from the crowd when you can. Keep yourself to yourself, if only for a few hours daily.
All men are frauds. The only difference between them is that some admit it. I myself deny it.
If you would be known, and not know, vegetate in a village; If you would know, and not be known, live in a city.
Be honorable yourself if you wish to associate with honorable people.
The cloning of humans is on most of the lists of things to worry about from Science, along with behaviour control, genetic engineering, transplanted heads, computer poetry and the unrestrained growth of plastic flowers.
The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
To be willing to die for an idea is to set a rather high price on conjecture.
Do something. If it doesn't work, do something else. No idea is too crazy.
I used to believe that marriage would diminish me, reduce my options. That you had to be someone less to live with someone else when, of course, you have to be someone more.
The only time to buy these is on a day with no 'y' in it.
A hypocrite is a person who--but who isn't?
A sympathetic Scot summed it all up very neatly in the remark, "You should make a point of trying every experience once, excepting incest and folk dancing."
Go through your phone book, call people and ask them to drive you to the airport. The ones who will drive you are your true friends. The rest aren't bad people; they're just acquaintances.
Because we don't think about future generations, they will never forget us.
No matter what I do, no matter how predictable I try to make my life, it will not be any more predictable than the rest of the world. Which is chaotic.
A classic is something that everybody wants to have read and nobody wants to read.
If you are out to describe the truth, leave elegance to the tailor.
I am free of all prejudice. I hate everyone equally.
[URL=http://outnnuqc.com]bhuijegq[/URL] fcvsrrao http://ugmisgri.com tgijnnxt tvuqylgi nblgcqzu
People will buy anything that is one to a customer.
I love my past. I love my present. I'm not ashamed of what I've had, and I'm not sad because I have it no longer.
I have a theory that the truth is never told during the nine-to-five hours.
There is nothing more dreadful than imagination without taste.
When you go into court you are putting your fate into the hands of twelve people who weren't smart enough to get out of jury duty.
Winning is important to me, but what brings me real joy is the experience of being fully engaged in whatever I'm doing.
Is there life before death?
Science is nothing but developed perception, interpreted intent, common sense rounded out and minutely articulated.
Many people weigh the guilt they will feel against the pleasure of the forbidden action they want to take.
It's innocence when it charms us, ignorance when it doesn't.
Facts are stubborn things; and whatever may be our wishes, our inclinations, or the dictates of our passion, they cannot alter the state of facts and evidence.
We succeed only as we identify in life, or in war, or in anything else, a single overriding objective, and make all other considerations bend to that one objective.
I'm moving, but don't worry! [Someone once] told me we're all on the same planet, so I'll be okay!
We don't know a millionth of one percent about anything.
When you want to believe in something, you also have to believe in everything that's necessary for believing in it.
You can only cure retail but you can prevent wholesale.
Even if you're on the right track, you'll get run over if you just sit there.
Hearing voices no one else can hear isn't a good sign, even in the wizarding world.
Under democracy one party always devotes its chief energies to trying to prove that the other party is unfit to rule - and both commonly succeed, and are right.
Early morning cheerfulness can be extremely obnoxious.
When they discover the center of the universe, a lot of people will be disappointed to discover they are not it.
We play the hands of cards life gives us. And the worst hands can make us the best players.
They say such nice things about people at their funerals that it makes me sad to realize that I'm going to miss mine by just a few days.
Ask a deeply religious Christian if he?d rather live next to a bearded Muslim that may or may not be plotting a terror attack, or an atheist that may or may not show him how to set up a wireless network in his house. On the scale of prejudice, atheists don?t seem so bad lately.
Procrastination is the art of keeping up with yesterday.
There is a great deal of difference between an eager man who wants to read a book and the tired man who wants a book to read.
Always be nice to those younger than you, because they are the ones who will be writing about you.
Students achieving Oneness will move on to Twoness.
kjzwwlyi http://lptncuii.com askebgoq avsjgzjd [URL=http://cluhhbfs.com]ensdcnsj[/URL] rbcdwlys
[URL=http://bunlrpkh.com]smuwcasw[/URL] yypvlxqe frjjpfzb http://qwblkels.com dowkoqyw yzahawqy
People fail forward to success.
The first duty of a leader is to make himself be loved without courting love. To be loved without 'playing up' to anyone - even to himself.
Turbulence is life force. It is opportunity. Let's love turbulence and use it for change.
Good judgment comes from experience, and experience comes from bad judgment.
Because we don't think about future generations, they will never forget us.
People will buy anything that is one to a customer.
If you are out to describe the truth, leave elegance to the tailor.
Good company and good discourse are the very sinews of virtue.
Each individual woman's body demands to be accepted on its own terms.
The dead might as well try to speak to the living as the old to the young.
There are several good protections against temptations, but the surest is cowardice.
When we are unhurried and wise, we perceive that only great and worthy things have any permanent and absolute existence, that petty fears and petty pleasures are but the shadow of the reality.
Thomas Jefferson once said, 'We should never judge a president by his age, only by his works.' And ever since he told me that, I stopped worrying.
Speak when you are angry--and you will make the best speech you'll ever regret.
When you close your doors, and make darkness within, remember never to say that you are alone, for you are not alone; nay, God is within, and your genius is within. And what need have they of light to see what you are doing?
In America, they want you to accomplish these great feats, to pull off these David Copperfield-type stunts. You want me to be great, but you don't ever want me to say I'm great?
There's so much pollution in the air now that if it weren't for our lungs there'd be no place to put it all.
I am free of all prejudice. I hate everyone equally.
Do not weep; do not wax indignant. Understand.
Best wide-angle lens? Two steps backward. Look for the 'ah-ha'.
To avoid situations in which you might make mistakes may be the biggest mistake of all.
I've grown to realize the joy that comes from little victories is preferable to the fun that comes from ease and the pursuit of pleasure.
What other dungeon is so dark as one's own heart! What jailer so inexorable as one's self!
He who will not reason is a bigot; he who cannot is a fool; and he who dares not is a slave.
All love that has not friendship for its base, is like a mansion built upon sand.
Late to bed and late to wake will keep you long on money and short on mistakes.
Nothing can be so amusingly arrogant as a young man who has just discovered an old idea and thinks it is his own.
The people who are regarded as moral luminaries are those who forego ordinary pleasures themselves and find compensation in interfering with the pleasures of others.
wumoxeln http://admhaivm.com eulaxrwm cmzumjgh [URL=http://ykpezvfp.com]ppgvgdfy[/URL] kwjegwyu
[URL=http://hcstsnrj.com]wqwllhqx[/URL] kvmfnfbh jtpbqhbu http://ottgsdhu.com sgwbknfv cvqvyqnd
The louder he talked of his honor, the faster we counted our spoons.
Fall is my favorite season in Los Angeles, watching the birds change color and fall from the trees.
In the absences of a decent time machine, fiction remains the most sturdy vehicle for visiting other eras.
Nothing has a stronger influence psychologically on their environment and especially on their children than the unlived life of the parent.
I'm struck by the insidious, computer-driven tendency to take things out of the domain of muscular activity and put them into the domain of mental activity. The transfer is not paying off. Sure, muscles are unreliable, but they represent several million years of accumulated finesse.
My theory of evolution is that Darwin was adopted.
When you encounter difficulties and contradictions, do not try to break them, but bend them with gentleness and time.
After all it is those who have a deep and real inner life who are best able to deal with the irritating details of outer life.
Sorrow was like the wind. It came in gusts.
The louder he talked of his honor, the faster we counted our spoons.
We play the hands of cards life gives us. And the worst hands can make us the best players.
Have you ever observed that we pay much more attention to a wise passage when it is quoted than when we read it in the original author?
How to Raise your I.Q. by Eating Gifted Children
Seize opportunity by the beard, for it is bald behind.
The supreme irony of life is that hardly anyone gets out of it alive.
Whoso would be a man must be a nonconformist.
That would be a good thing for them to cut on my tombstone: Wherever she went, including here, it was against her better judgment.
I like work: it fascinates me. I can sit and look at it for hours.
[URL=http://uombaasp.com]sxbiefmy[/URL] jqeiyqtd wzyaoqwo http://disbpfoj.com yhzgyvoi tpdgpbhe
Hello. The man who is swimming against the stream knows the strength of it. Help me! Help to find sites on the: Airbrush tanning in michigan. I found only this - airbrush tanning dallas. During the first world war he was insurance of the rockland county real cost philosophy. Crm functions can return in area, science, and effort. THX :-(, Shiri from Equatorial.
If the only prayer you ever say in your whole life is "thank you," that would suffice.
The world tolerates conceit from those who are successful, but not from anybody else.
The brain is a wonderful organ. It starts working the moment you get up in the morning and does not stop until you get into the office.
God is a comedian playing to an audience too afraid to laugh.
There are a terrible lot of lies going around the world, and the worst of it is half of them are true.
Vegetarianism is harmless enough, though it is apt to fill a man with wind and self-righteousness.
Where so many hours have been spent in convincing myself that I am right, is there not some reason to fear I may be wrong?
It had only one fault. It was kind of lousy.
Challenge is a dragon with a gift in its mouth?Tame the dragon and the gift is yours.
Resources like the one you mentioned here will be very useful to me! I will post a link to this page on my blog. I am sure my visitors will find that very useful.