class FossGit
Attributes
checkout_path[R]
fossil_repository[R]
project_name[RW]
Public Class Methods
new(checkout_path='')
click to toggle source
# File lib/fossgit.rb, line 8 def initialize checkout_path='' @checkout_path = checkout_path @checkout_path = get_element_matching :'local-root' @fossil_repository = get_repository_path @project_name = get_project_name end
version()
click to toggle source
# File lib/fossgit.rb, line 17 def self.version '1.2.1' end
Public Instance Methods
fossil_command()
click to toggle source
# File lib/fossgit.rb, line 29 def fossil_command cmd = ['fossil export --git'] cmd << "--import-marks #{fossil_marks}" if update_export? cmd << "--export-marks #{fossil_marks}" cmd << fossil_repository cmd.join ' ' end
fossil_marks()
click to toggle source
# File lib/fossgit.rb, line 21 def fossil_marks File.join checkout_path, 'fossil.marks' end
git_command()
click to toggle source
# File lib/fossgit.rb, line 43 def git_command cmd = ['git fast-import'] cmd << "--import-marks=#{git_marks}" if update_export? cmd << "--export-marks=#{git_marks}" cmd.join ' ' end
git_marks()
click to toggle source
# File lib/fossgit.rb, line 25 def git_marks File.join checkout_path, 'git.marks' end
git_remotes(gitpath)
click to toggle source
# File lib/fossgit.rb, line 80 def git_remotes gitpath Dir.chdir gitpath do `git remote`.split "\n" end end
mirror_command()
click to toggle source
# File lib/fossgit.rb, line 57 def mirror_command [fossil_command, sed_command, git_command].join '|' end
push_command(gitremote)
click to toggle source
# File lib/fossgit.rb, line 39 def push_command gitremote "; git checkout trunk; git push --all #{gitremote}" end
push_mirror_command(gitremote)
click to toggle source
# File lib/fossgit.rb, line 61 def push_mirror_command gitremote mirror_command + push_command(gitremote) end
push_remote_list!(remote_list)
click to toggle source
# File lib/fossgit.rb, line 65 def push_remote_list! remote_list remote_list.each do |gitremote| puts "PUSH TO: #{gitremote}" system push_mirror_command(gitremote) end end
sed_command()
click to toggle source
# File lib/fossgit.rb, line 52 def sed_command # legacy fix for a bug in an old Fossil version's Git-export %q{sed 's/^\(committer \+\)\([^ ]\+@[^ ]\+\)\( *<\)\(\w\+\)\(>.*\)$/\1\4\3\2\5/'} end
text_export_command()
click to toggle source
# File lib/fossgit.rb, line 72 def text_export_command [fossil_command, sed_command].join '|' end
update_export?()
click to toggle source
# File lib/fossgit.rb, line 76 def update_export? File.exist? git_marks and File.exist? fossil_marks end
Private Instance Methods
fossil_status()
click to toggle source
# File lib/fossgit.rb, line 103 def fossil_status Dir.chdir checkout_path stat = `fossil status` if stat.size > 0 stat.split "\n" else raise ArgumentError, "#{checkout_path} is not a valid checkout path" end end
get_element_matching(key)
click to toggle source
# File lib/fossgit.rb, line 98 def get_element_matching key key_regex = /^#{key}: +/ fossil_status.select {|line| line.match key_regex }.first.sub key_regex, '' end
get_project_name()
click to toggle source
# File lib/fossgit.rb, line 88 def get_project_name fossil_info = YAML.load `fossil info | head -n 1` name = fossil_info ? fossil_info['project-name'] : fossil_info name if not name.eql? '<unnamed>' end
get_repository_path()
click to toggle source
# File lib/fossgit.rb, line 94 def get_repository_path File.absolute_path get_element_matching :repository end