public
Description: Some more or less useful rake tasks. Includes tasks to work with git-cvs, convert an Atom collection to a blog, post to an AtomPub server and more.
Homepage:
Clone URL: git://github.com/sr/tasks.git
tasks / git.rake
100644 51 lines (46 sloc) 1.884 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
namespace :git do
  desc 'Set origin to git@SERVER:NAME/PWD'
  task :set_origin do
    ENV['SERVER'] ||= 'bearnaise.net'
    origin = "git@#{ENV['SERVER']}:#{ENV['NAME'] || File.basename(ENV['PWD'])}"
    puts "Adding origin #{origin}..."
    `git remote add origin #{origin}`
  end
 
  desc 'Do a `git push` and then try to push to github.com if LOGIN is specified.'
  task :push do
    ENV['NAME'] ||= File.basename(ENV['PWD'])
    `git push origin master:refs/heads/master`
    `git push`
    unless ENV['LOGIN'] && ENV['NAME']
      puts 'Not pushing to github'
      exit
    end
    push_url = "git@github.com:#{ENV['LOGIN']}/#{ENV['NAME']}"
    puts "Pushing to #{push_url}"
    `git push #{push_url} master`
  end
 
  namespace :cvs do
    desc 'Gitify a CVS repository. Specify CVS LOGIN, server ADDR, CVS_ROOT and MODULE.
It\'ll checkout the CVS repo into `MODULE`.cvs and then convert it to git into `MODULE`.git'
    task :gitify => :checkout_cvs do
      raise 'Missing LOGIN' unless ENV['LOGIN']
      raise 'Missing ADDR' unless ENV['ADDR']
      cvs_repo = ENV['MODULE']+'.cvs'
      FileUtils.cd File.join(ENV['PWD'], cvs_repo)
      git_repo = File.join(ENV['PWD'], cvs_repo.gsub('.cvs', '.git'))
      puts "Converting #{cvs_repo} to #{git_repo}..."
      `git-cvsimport -v -C ../#{git_repo} -a`
    end
 
    task :login do
      ENV['CVS_ROOT'] ||= 'cvs'
      puts "Signin in on #{ENV['ADDR']} as #{ENV['LOGIN']}..."
      `cvs -d :pserver:#{ENV['LOGIN']}@#{ENV['ADDR']}:/#{ENV['CVS_ROOT']} login`
    end
 
    task :checkout_cvs => :login do
      raise 'Missing MODULE' unless ENV['MODULE']
      puts "Checking out #{ENV['MODULE']} to #{File.join(ENV['PWD'], ENV['MODULE']+'.cvs')}..."
      `cvs -d :pserver:#{ENV['LOGIN']}@#{ENV['ADDR']}:/#{ENV['CVS_ROOT']} checkout #{ENV['MODULE']}`
      FileUtils.mv ENV['MODULE'], ENV['MODULE']+'.cvs'
    end
  end
end