Skip to content

Instantly share code, notes, and snippets.

@tealtail
Forked from phlco/Rakefile
Last active December 25, 2015 05:09
Show Gist options
  • Save tealtail/6922656 to your computer and use it in GitHub Desktop.
Save tealtail/6922656 to your computer and use it in GitHub Desktop.
require 'git'
require 'date'
require 'logger'
START_DATE = Date.parse('23/09/2013')
namespace :hw do
desc "gets homework"
task :get do
puts "updating your fork with latest from the upstream homework repo..."
g = Git.open('./hw', :logger => STDOUT)
puts "checking out your master branch now..."
g.checkout('master')
puts "removing any untracked files..."
# maybe this isn't a good idea?
g.clean({:force => true})
g.reset('origin/master', {:hard => true})
g.pull('origin', 'master')
g.branch(make_branch).checkout
end
def make_branch
date = Date.today
week_number = ((date - START_DATE).to_i / 7.0).ceil
"week#{week_number}_day#{date.wday}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment