Aug 28

Cleaning Up Peer Review Branches Made Easy with PowerShell

Maybe I’m in the minority, but whenever I start working on a peer review, the first thing I do is create a branch in git. That way if I have any comments or edits, I already have everything setup and I don’t have to lose my train of thought by closing the solution, create a branch, re-open the solution and hope I remember what I was going to say.

I’m not, however, very good at cleaning up those branches when I’m done. After our last sprint, I had 45 orphaned peer review branches. Because I use a consistent naming scheme (peer-StoryID), this could either be a lot of typing, or I could use PowerShell to make it easy.

git branch | sls "peer" | %{ git branch -d $_.Line.Trim() }

That will grab the list of all branches that contain the text “peer” and remove them. The extra Trim() is because I was getting branches names prefixed by 3-5 spaces from the output.

Can you think of a better way to do this? Post it in the comments below!

Aug 04

PowerShell, Dropbox, and Windows Live Writer

I think I have a problem. I cannot use just one computer. I have work computers, home computers, and computers I use exclusively on the couch while watching TV. I really like to keep all of these computers in sync so I have all of my files, programs and configuration no matter where I am. For the most part, Dropbox lets me do that. But every now and then, something like Windows Live Writer comes along that with a hard coded save path.

Fortunately, Gabriel Novo shows the solution using Junctions and third-party downloadable tool. That’s great, but surely there’s a PowerShell way to do this, right? Turns out the answer is yes, provided you have PowerShell Community Extensions installed. If you don’t, stop reading right now and get it installed.

The answer is as simple as PSCX’s New-Junction cmdlet. The parameters are named backward from what I initially interpreted them to be, but that’s not a problem. LiteralPath points to the “fake” folder you’re making, and TargetPath points to the folder to which you’re linking. So given that my Windows username is Nathan and I have everything installed to the default locations, I simply run:

New-Junction ` 
     -LiteralPath 'C:UsersNathanDocumentsMy Weblog Posts' ` 
     -TargetPath 'C:UsersNathanDropboxMy Weblog Posts'

Done. I now have Windows Live Writer unknowingly syncing local drafts to Dropbox. That’s on one system of course, so you’ll have to do that on each system you use. Or do you? Find out in the next post, where I continue blogging about blogging.

Jun 18

Slides from Codestock 2012 Talk

Thanks to everyone that came to my “Introductory PowerShell by (Real-World) Example” talk.  Here are my slides from that talk.

Edit: A friend noticed that I forgot to update the link to this file when I updated my blog engine. It should be working correctly now.

Introductory PowerShell by (Real-World) Example

 

May 11

Come learn about PowerShell

Come see me at CodeStock (June 15-16 2012) as I present my session “Introductory PowerShell by (Real-World) Example”.  This session is geared toward people that have no PowerShell experience, but I hope that even lightly-experienced users will get something out of it.  It’s a developer-focused session, so the theme is automating your work and finding problems.  I won’t be covering topics more suited to IT administration, such as Exchange or SharePoint administration.

» Newer posts