Module: GitBackup

Defined in:
lib/git-backup.rb,
lib/git-backup/version.rb

Constant Summary collapse

VERSION =
"0.2.1"

Class Method Summary collapse

Class Method Details

.mainObject



5
6
7
8
9
10
11
12
13
# File 'lib/git-backup.rb', line 5

def self.main
  current_branch = `git rev-parse --abbrev-ref HEAD`.strip
  g = Git.open('.')
  number_of_existing_backups = g.branches.local.count { |b| !!(b.name =~ /backup\/#{Regexp.quote(current_branch)}-\d+/) }
  new_backup_name = "backup/#{current_branch}-#{number_of_existing_backups + 1}"

  `git branch #{new_backup_name}`
  puts "Created branch #{new_backup_name}."
end