Tonight, I was too lazy to set up CVS or Git, so I somehow deduced that writing my own Powershell script to do basic source control made more sense. Just in case anyone else is looking for something similar, here it is.
The script works as follows: You pass in a list of folders you wish to "check-in", and it copies them, excluding bin and obj directories, to .\.es\yyyyMMddHHmmss\(Names). Optionally, if you want to mark something as "stable", you can include the "-stable" flag. If you want to give the folder a more descriptive name, you can include the "-tag" flag, and the script will ask for a name.
$checkinfolder = get-date -format "yyyyMMddHHmmss"
$currentloc = get-location
$promoteAsStable = $FALSE
foreach($arg in $args)
{
if($arg.ToLower().Equals("-tag"))
{
$checkinfolder = read-host "Check-in as tagged revision path"
}
}
new-item $currentloc\.es\$checkinfolder -type Directory | out-null
foreach($arg in $args)
{
if($arg.ToLower().Equals("-stable"))
{
$promoteAsStable = $TRUE
}
else
{
echo "Checking in $arg..."
get-childitem .\$arg -Exclude "Bin","Obj" | copy-item -Destination .es\$checkinfolder\$arg
}
}
$comment = read-host "Check-in Comment for $checkinfolder"
if($promoteAsStable -eq $TRUE)
{
$checkinfolder | out-file -filepath ".\.es\STABLE" -append
}
$comment | out-file -filepath ".\.es\$checkinfolder.txt"
$checkinfolder | out-file -filepath ".\.es\CHECKINS" –append
Hopefully you’ll find it useful.