Class: FossGit
- Inherits:
-
Object
- Object
- FossGit
- Defined in:
- lib/fossgit.rb
Instance Attribute Summary collapse
-
#checkout_path ⇒ Object
readonly
Returns the value of attribute checkout_path.
-
#fossil_repository ⇒ Object
readonly
Returns the value of attribute fossil_repository.
Class Method Summary collapse
Instance Method Summary collapse
- #fossil_command ⇒ Object
- #fossil_marks ⇒ Object
- #git_command ⇒ Object
- #git_marks ⇒ Object
- #git_remotes(gitpath) ⇒ Object
-
#initialize(checkout_path = '') ⇒ FossGit
constructor
A new instance of FossGit.
- #mirror_command ⇒ Object
- #push_command(gitremote) ⇒ Object
- #push_mirror_command(gitremote) ⇒ Object
- #push_remote_list!(remote_list) ⇒ Object
- #sed_command ⇒ Object
- #text_export_command ⇒ Object
- #update_export? ⇒ Boolean
Constructor Details
#initialize(checkout_path = '') ⇒ FossGit
Returns a new instance of FossGit.
5 6 7 8 9 10 |
# File 'lib/fossgit.rb', line 5 def initialize checkout_path='' @checkout_path = checkout_path @checkout_path = get_element_matching :'local-root' @fossil_repository = get_repository_path end |
Instance Attribute Details
#checkout_path ⇒ Object (readonly)
Returns the value of attribute checkout_path.
2 3 4 |
# File 'lib/fossgit.rb', line 2 def checkout_path @checkout_path end |
#fossil_repository ⇒ Object (readonly)
Returns the value of attribute fossil_repository.
3 4 5 |
# File 'lib/fossgit.rb', line 3 def fossil_repository @fossil_repository end |
Class Method Details
.version ⇒ Object
12 13 14 |
# File 'lib/fossgit.rb', line 12 def self.version '1.1.0' end |
Instance Method Details
#fossil_command ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/fossgit.rb', line 24 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 ⇒ Object
16 17 18 |
# File 'lib/fossgit.rb', line 16 def fossil_marks File.join checkout_path, 'fossil.marks' end |
#git_command ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/fossgit.rb', line 38 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 ⇒ Object
20 21 22 |
# File 'lib/fossgit.rb', line 20 def git_marks File.join checkout_path, 'git.marks' end |
#git_remotes(gitpath) ⇒ Object
74 75 76 77 78 |
# File 'lib/fossgit.rb', line 74 def git_remotes gitpath Dir.chdir gitpath do `git remote`.split "\n" end end |
#mirror_command ⇒ Object
51 52 53 |
# File 'lib/fossgit.rb', line 51 def mirror_command [fossil_command, sed_command, git_command].join '|' end |
#push_command(gitremote) ⇒ Object
34 35 36 |
# File 'lib/fossgit.rb', line 34 def push_command gitremote "; git checkout trunk; git push #{gitremote} trunk" end |
#push_mirror_command(gitremote) ⇒ Object
55 56 57 |
# File 'lib/fossgit.rb', line 55 def push_mirror_command gitremote mirror_command + push_command(gitremote) end |
#push_remote_list!(remote_list) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/fossgit.rb', line 59 def push_remote_list! remote_list remote_list.each do |gitremote| puts "PUSH TO: #{gitremote}" system push_mirror_command(gitremote) end end |
#sed_command ⇒ Object
47 48 49 |
# File 'lib/fossgit.rb', line 47 def sed_command %q{sed 's/^\(committer \+\)\([^ ]\+@[^ ]\+\)\( *<\)\(\w\+\)\(>.*\)$/\1\4\3\2\5/'} end |
#text_export_command ⇒ Object
66 67 68 |
# File 'lib/fossgit.rb', line 66 def text_export_command [fossil_command, sed_command].join '|' end |
#update_export? ⇒ Boolean
70 71 72 |
# File 'lib/fossgit.rb', line 70 def update_export? File.exist? git_marks and File.exist? fossil_marks end |