redcar 0.9.2 → 0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. data/CHANGES +34 -4
  2. data/Rakefile +2 -1
  3. data/lib/redcar.rb +3 -3
  4. data/lib/redcar/installer.rb +2 -3
  5. data/plugins/application/features/step_definitions/dialog_steps.rb +7 -0
  6. data/plugins/application/features/step_definitions/key_steps.rb +18 -0
  7. data/plugins/application/features/step_definitions/menu_steps.rb +5 -6
  8. data/plugins/application/features/step_definitions/speedbar_steps.rb +29 -9
  9. data/plugins/application/features/step_definitions/tree_steps.rb +13 -0
  10. data/plugins/application/features/support/env.rb +39 -5
  11. data/plugins/application/features/support/fake_event.rb +12 -0
  12. data/plugins/application/lib/application.rb +5 -6
  13. data/plugins/application/lib/application/dialog.rb +53 -10
  14. data/plugins/application/lib/application/dialogs/modeless_list_dialog.rb +85 -0
  15. data/plugins/application/lib/application/keymap.rb +10 -8
  16. data/plugins/application/lib/application/menu.rb +38 -16
  17. data/plugins/application/lib/application/treebook.rb +30 -0
  18. data/plugins/application/lib/application/window.rb +20 -2
  19. data/plugins/application/spec/application/command/executor_spec.rb +1 -0
  20. data/plugins/application/spec/application/menu_spec.rb +26 -26
  21. data/plugins/application/spec/application/treebook_spec.rb +6 -6
  22. data/plugins/application/spec/spec_helper.rb +10 -1
  23. data/plugins/application_swt/lib/application_swt.rb +25 -3
  24. data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +48 -27
  25. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +22 -11
  26. data/plugins/application_swt/lib/application_swt/dialogs/modeless_dialog.rb +113 -0
  27. data/plugins/application_swt/lib/application_swt/dialogs/modeless_html_dialog.rb +85 -0
  28. data/plugins/application_swt/lib/application_swt/dialogs/modeless_list_dialog_controller.rb +143 -0
  29. data/plugins/application_swt/lib/application_swt/gradient.rb +61 -0
  30. data/plugins/application_swt/lib/application_swt/menu/binding_translator.rb +4 -4
  31. data/plugins/application_swt/lib/application_swt/notebook.rb +5 -8
  32. data/plugins/application_swt/lib/application_swt/speedbar.rb +1 -0
  33. data/plugins/application_swt/lib/application_swt/treebook.rb +6 -8
  34. data/plugins/application_swt/lib/application_swt/window.rb +85 -57
  35. data/plugins/application_swt/lib/swt/graphics_utils.rb +23 -0
  36. data/plugins/application_swt/lib/swt/vtab_folder.rb +7 -0
  37. data/plugins/application_swt/lib/swt/vtab_label.rb +1 -1
  38. data/plugins/application_swt/spec/application_swt/gradient_spec.rb +142 -0
  39. data/plugins/auto_completer/lib/auto_completer.rb +10 -42
  40. data/plugins/auto_completer/lib/auto_completer/list_dialog.rb +21 -0
  41. data/plugins/clojure/lib/clojure.rb +33 -0
  42. data/plugins/{repl/lib/repl/clojure_mirror.rb → clojure/lib/clojure/repl_mirror.rb} +16 -20
  43. data/plugins/clojure/plugin.rb +9 -0
  44. data/plugins/{repl/spec/repl/clojure_mirror_spec.rb → clojure/spec/clojure/repl_mirror_spec.rb} +12 -13
  45. data/plugins/clojure/spec/spec_helper.rb +5 -0
  46. data/plugins/{repl → clojure}/vendor/Wrapper.clj +0 -0
  47. data/plugins/{repl → clojure}/vendor/dummy +0 -0
  48. data/plugins/{repl → clojure}/vendor/enclojure-wrapper.jar +0 -0
  49. data/plugins/connection_manager/lib/connection_manager.rb +13 -13
  50. data/plugins/declarations/lib/declarations.rb +17 -6
  51. data/plugins/document_search/features/find.feature +389 -0
  52. data/plugins/document_search/features/find_and_replace.feature +723 -0
  53. data/plugins/document_search/features/replace.feature +69 -62
  54. data/plugins/document_search/lib/document_search.rb +81 -64
  55. data/plugins/document_search/lib/document_search/commands.rb +258 -0
  56. data/plugins/document_search/lib/document_search/find_and_replace_speedbar.rb +142 -0
  57. data/plugins/document_search/lib/document_search/find_speedbar.rb +102 -0
  58. data/plugins/document_search/lib/document_search/query_options.rb +45 -0
  59. data/plugins/edit_view/features/case_change.feature +9 -5
  60. data/plugins/edit_view/features/step_definitions/editing_steps.rb +19 -0
  61. data/plugins/edit_view/lib/edit_view.rb +15 -12
  62. data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +12 -2
  63. data/plugins/edit_view/lib/edit_view/commands/text_conversion_commands.rb +1 -1
  64. data/plugins/edit_view/lib/edit_view/document.rb +129 -99
  65. data/plugins/edit_view_swt/lib/edit_view_swt.rb +33 -15
  66. data/plugins/encryption/encryption.rb +2 -0
  67. data/plugins/find-in-project/lib/find_in_project.rb +3 -5
  68. data/plugins/find-in-project/lib/find_in_project/views/index.html.erb +2 -0
  69. data/plugins/groovy/features/step_definitions/groovy_steps.rb +2 -2
  70. data/plugins/groovy/features/syntax_check_groovy.feature +3 -3
  71. data/plugins/groovy/lib/groovy.rb +38 -0
  72. data/plugins/groovy/lib/groovy/commands.rb +10 -0
  73. data/plugins/{repl/lib/repl/groovy_mirror.rb → groovy/lib/groovy/repl_mirror.rb} +33 -13
  74. data/plugins/groovy/lib/{syntax_check/groovy.rb → groovy/syntax_checker.rb} +13 -8
  75. data/plugins/groovy/plugin.rb +5 -4
  76. data/plugins/{repl/spec/repl/groovy_mirror_spec.rb → groovy/spec/groovy/repl_mirror_spec.rb} +14 -13
  77. data/plugins/groovy/spec/spec_helper.rb +5 -0
  78. data/plugins/html_view/assets/json2.js +476 -0
  79. data/plugins/html_view/lib/html_view.rb +1 -0
  80. data/plugins/java/features/fixtures/test.java +0 -0
  81. data/plugins/java/features/support/env.rb +27 -0
  82. data/plugins/java/features/syntax_check_java.feature +86 -0
  83. data/plugins/java/lib/syntax_check/java.rb +86 -0
  84. data/plugins/java/plugin.rb +7 -0
  85. data/plugins/javascript/features/fixtures/test2.js +5 -0
  86. data/plugins/javascript/features/step_definitions/javascript_steps.rb +16 -0
  87. data/plugins/javascript/features/support/env.rb +14 -0
  88. data/plugins/javascript/features/syntax_check_javascript.feature +46 -3
  89. data/plugins/javascript/lib/syntax_check/javascript.rb +15 -9
  90. data/plugins/line_tools/features/trim_line.feature +49 -0
  91. data/plugins/line_tools/lib/line_tools.rb +5 -1
  92. data/plugins/mirah/README +7 -0
  93. data/plugins/mirah/features/fixtures/test.mirah +2 -0
  94. data/plugins/mirah/features/syntax_check_mirah.feature +46 -0
  95. data/plugins/mirah/lib/mirah.rb +43 -0
  96. data/plugins/mirah/lib/mirah/my_error_handler.rb +22 -0
  97. data/plugins/mirah/lib/mirah/repl_mirror.rb +50 -0
  98. data/plugins/mirah/lib/mirah/syntax_checker.rb +38 -0
  99. data/plugins/mirah/plugin.rb +8 -0
  100. data/plugins/mirah/spec/mirah/repl_mirror_spec.rb +188 -0
  101. data/plugins/mirah/spec/spec_helper.rb +5 -0
  102. data/plugins/mirah/vendor/mirah-parser.jar +0 -0
  103. data/plugins/pair_highlighter/lib/pair_highlighter/document_controller.rb +24 -23
  104. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +10 -1
  105. data/plugins/plugin_manager_ui/views/index.html.erb +2 -0
  106. data/plugins/project/features/find_file.feature +40 -16
  107. data/plugins/project/features/highlight_focussed_tab.feature +16 -10
  108. data/plugins/project/features/step_definitions/find_file_steps.rb +11 -0
  109. data/plugins/project/features/step_definitions/project_tree_steps.rb +5 -1
  110. data/plugins/project/features/support/env.rb +5 -0
  111. data/plugins/project/lib/project/commands.rb +8 -1
  112. data/plugins/project/lib/project/dir_controller.rb +4 -1
  113. data/plugins/project/lib/project/find_file_dialog.rb +16 -12
  114. data/plugins/project/lib/project/manager.rb +30 -1
  115. data/plugins/project_search/vendor/lucene/CHANGELOG +147 -0
  116. data/plugins/project_search/vendor/lucene/CONTRIBUTORS +17 -0
  117. data/plugins/project_search/vendor/lucene/Gemfile +9 -0
  118. data/plugins/project_search/vendor/lucene/Gemfile.lock +33 -0
  119. data/plugins/project_search/vendor/lucene/LICENSE +19 -0
  120. data/plugins/project_search/vendor/lucene/README.rdoc +283 -0
  121. data/plugins/project_search/vendor/lucene/Rakefile +35 -0
  122. data/plugins/project_search/vendor/lucene/examples/active_model/serializers.rb +25 -0
  123. data/plugins/project_search/vendor/lucene/examples/active_model/validation.rb +26 -0
  124. data/plugins/project_search/vendor/lucene/examples/admin/Rakefile +4 -0
  125. data/plugins/project_search/vendor/lucene/examples/admin/admin.rb +29 -0
  126. data/plugins/project_search/vendor/lucene/examples/admin/public/jquery.js +4376 -0
  127. data/plugins/project_search/vendor/lucene/examples/admin/public/neo4j.css +153 -0
  128. data/plugins/project_search/vendor/lucene/examples/admin/public/neo_admin.js +18 -0
  129. data/plugins/project_search/vendor/lucene/examples/admin/spec/admin_spec.rb +26 -0
  130. data/plugins/project_search/vendor/lucene/examples/admin/views/index.erb +21 -0
  131. data/plugins/project_search/vendor/lucene/examples/filetree/README.rdoc +9 -0
  132. data/plugins/project_search/vendor/lucene/examples/filetree/app.rb +7 -0
  133. data/plugins/project_search/vendor/lucene/examples/filetree/batch.props +5 -0
  134. data/plugins/project_search/vendor/lucene/examples/filetree/features/step_definitions/add_steps.rb +121 -0
  135. data/plugins/project_search/vendor/lucene/examples/filetree/features/support/env.rb +30 -0
  136. data/plugins/project_search/vendor/lucene/examples/filetree/features/support/rspec_helper.rb +50 -0
  137. data/plugins/project_search/vendor/lucene/examples/filetree/features/treesizes.feature +19 -0
  138. data/plugins/project_search/vendor/lucene/examples/imdb/1_create_neo_db.rb +66 -0
  139. data/plugins/project_search/vendor/lucene/examples/imdb/2_index_db.rb +23 -0
  140. data/plugins/project_search/vendor/lucene/examples/imdb/README +12 -0
  141. data/plugins/project_search/vendor/lucene/examples/imdb/find_actors.rb +56 -0
  142. data/plugins/project_search/vendor/lucene/examples/imdb/install.sh +12 -0
  143. data/plugins/project_search/vendor/lucene/examples/imdb/model.rb +37 -0
  144. data/plugins/project_search/vendor/lucene/examples/railway/README +111 -0
  145. data/plugins/project_search/vendor/lucene/examples/railway/railnet-app.rb +31 -0
  146. data/plugins/project_search/vendor/lucene/examples/railway/railnet-data.rb +42 -0
  147. data/plugins/project_search/vendor/lucene/examples/rest/example.rb +41 -0
  148. data/plugins/project_search/vendor/lucene/examples/you_might_know/YouMightKnow.java +60 -0
  149. data/plugins/project_search/vendor/lucene/examples/you_might_know/all_simple_paths.rb +34 -0
  150. data/plugins/project_search/vendor/lucene/examples/you_might_know/nodes.rb +34 -0
  151. data/plugins/project_search/vendor/lucene/examples/you_might_know/you_might_know.rb +50 -0
  152. data/plugins/project_search/vendor/lucene/lib/lucene.rb +15 -0
  153. data/plugins/project_search/vendor/lucene/lib/lucene/config.rb +145 -0
  154. data/plugins/project_search/vendor/lucene/lib/lucene/document.rb +96 -0
  155. data/plugins/project_search/vendor/lucene/lib/lucene/field_info.rb +144 -0
  156. data/plugins/project_search/vendor/lucene/lib/lucene/hits.rb +54 -0
  157. data/plugins/project_search/vendor/lucene/lib/lucene/index.rb +267 -0
  158. data/plugins/project_search/vendor/lucene/lib/lucene/index_info.rb +146 -0
  159. data/plugins/project_search/vendor/lucene/lib/lucene/index_searcher.rb +157 -0
  160. data/plugins/project_search/vendor/lucene/lib/lucene/jars.rb +5 -0
  161. data/plugins/project_search/vendor/lucene/lib/lucene/query_dsl.rb +135 -0
  162. data/plugins/project_search/vendor/lucene/lib/lucene/transaction.rb +117 -0
  163. data/plugins/project_search/vendor/lucene/lib/lucene/version.rb +3 -0
  164. data/plugins/project_search/vendor/lucene/lucene.gemspec +23 -0
  165. data/plugins/project_search/vendor/lucene/spec/lucene/document_spec.rb +32 -0
  166. data/plugins/project_search/vendor/lucene/spec/lucene/field_info_spec.rb +70 -0
  167. data/plugins/project_search/vendor/lucene/spec/lucene/index_info_spec.rb +76 -0
  168. data/plugins/project_search/vendor/lucene/spec/lucene/index_spec.rb +643 -0
  169. data/plugins/project_search/vendor/lucene/spec/lucene/query_dsl_spec.rb +142 -0
  170. data/plugins/project_search/vendor/lucene/spec/lucene/sort_spec.rb +101 -0
  171. data/plugins/project_search/vendor/lucene/spec/lucene/spec_helper.rb +10 -0
  172. data/plugins/project_search/vendor/lucene/spec/lucene/transaction_spec.rb +118 -0
  173. data/plugins/redcar/features/alter_font_size.feature +25 -0
  174. data/plugins/redcar/features/step_definitions/font_steps.rb +34 -0
  175. data/plugins/redcar/redcar.rb +256 -43
  176. data/plugins/repl/features/command_editing.feature +55 -0
  177. data/plugins/repl/features/command_history.feature +75 -0
  178. data/plugins/repl/features/step_definitions/repl_steps.rb +17 -1
  179. data/plugins/repl/features/support/env.rb +24 -0
  180. data/plugins/repl/features/support/fake_repl.rb +16 -0
  181. data/plugins/repl/lib/repl.rb +17 -74
  182. data/plugins/repl/lib/repl/repl_command.rb +20 -0
  183. data/plugins/repl/lib/repl/repl_mirror.rb +168 -22
  184. data/plugins/repl/lib/repl/repl_tab.rb +131 -6
  185. data/plugins/repl/plugin.rb +1 -1
  186. data/plugins/repl/spec/repl/repl_mirror_spec.rb +72 -0
  187. data/plugins/repl/spec/spec_helper.rb +1 -1
  188. data/plugins/repl_swt/lib/repl_swt.rb +7 -0
  189. data/plugins/repl_swt/lib/repl_swt/key_listener.rb +43 -0
  190. data/plugins/repl_swt/plugin.rb +8 -0
  191. data/plugins/ruby/lib/ruby.rb +35 -0
  192. data/plugins/{repl/lib/repl/ruby_mirror.rb → ruby/lib/ruby/repl_mirror.rb} +12 -12
  193. data/plugins/ruby/lib/{syntax_check/ruby.rb → ruby/syntax_checker.rb} +3 -3
  194. data/plugins/ruby/plugin.rb +5 -4
  195. data/plugins/{repl/spec/repl/ruby_mirror_spec.rb → ruby/spec/ruby/repl_mirror_spec.rb} +38 -29
  196. data/plugins/ruby/spec/spec_helper.rb +5 -0
  197. data/plugins/runnables/lib/runnables.rb +2 -0
  198. data/plugins/runnables/lib/runnables/command_output_controller.rb +5 -0
  199. data/plugins/runnables/lib/runnables/output_processor.rb +14 -3
  200. data/plugins/runnables/views/command_output.html.erb +3 -2
  201. data/plugins/scm/lib/scm.rb +4 -2
  202. data/plugins/scm/lib/scm/diff_mirror.rb +6 -6
  203. data/plugins/scm_git/lib/scm_git.rb +136 -107
  204. data/plugins/scm_git/lib/scm_git/change.rb +28 -19
  205. data/plugins/snippets/lib/snippets/explorer.rb +2 -2
  206. data/plugins/swt/lib/swt/full_swt.rb +1 -0
  207. data/plugins/syntax_check/features/step_definitions/syntax_check_steps.rb +4 -0
  208. data/plugins/syntax_check/features/support/env.rb +3 -0
  209. data/plugins/syntax_check/lib/syntax_check.rb +71 -5
  210. data/plugins/syntax_check/lib/syntax_check/annotation.rb +61 -0
  211. data/plugins/test_runner/lib/test_runner.rb +39 -0
  212. data/plugins/test_runner/lib/test_runner/rspec_runner.rb +20 -0
  213. data/plugins/test_runner/lib/test_runner/run_test_command.rb +63 -0
  214. data/plugins/test_runner/lib/test_runner/runnable_test_runner.rb +26 -0
  215. data/plugins/test_runner/plugin.rb +8 -0
  216. data/plugins/test_runner/spec/run_test_command_spec.rb +51 -0
  217. data/plugins/test_runner/spec/spec_helper.rb +5 -0
  218. data/plugins/textmate/lib/textmate.rb +12 -2
  219. data/plugins/textmate/vendor/redcar-bundles/Bundles/HTML.tmbundle/Syntaxes/HTML.plist +0 -2
  220. data/plugins/textmate/vendor/redcar-bundles/Bundles/Mirah.tmbundle/Syntaxes/Mirah.plist +22 -0
  221. data/plugins/textmate/vendor/redcar-bundles/Bundles/Mirah.tmbundle/info.plist +12 -0
  222. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby.tmbundle/Syntaxes/Ruby.plist +2 -0
  223. data/plugins/todo_list/lib/todo_list.rb +7 -0
  224. data/plugins/todo_list/lib/todo_list/todo_controller.rb +3 -1
  225. data/plugins/tree/lib/tree.rb +4 -0
  226. data/plugins/tree_view_swt/lib/tree_view_swt.rb +5 -0
  227. data/plugins/web_bookmarks/lib/web_bookmarks.rb +10 -0
  228. metadata +137 -22
  229. data/plugins/document_search/features/search.feature +0 -163
  230. data/plugins/document_search/lib/document_search/replace_all_command.rb +0 -27
  231. data/plugins/document_search/lib/document_search/replace_command.rb +0 -38
  232. data/plugins/document_search/lib/document_search/replace_next_command.rb +0 -27
  233. data/plugins/document_search/lib/document_search/search_and_replace.rb +0 -81
  234. data/plugins/ruby/README +0 -6
@@ -0,0 +1,5 @@
1
+ $:.push File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
2
+
3
+ require 'redcar'
4
+ Redcar.environment = :test
5
+ Redcar.load_unthreaded
@@ -104,11 +104,13 @@ module Redcar
104
104
 
105
105
  def self.keymaps
106
106
  linwin = Keymap.build("main", [:linux, :windows]) do
107
+ link "Ctrl+Alt+Shift+R", Runnables::ShowRunnables
107
108
  link "Ctrl+R", Runnables::RunEditTabCommand
108
109
  link "Ctrl+Alt+R", Runnables::RunAlternateEditTabCommand
109
110
  end
110
111
 
111
112
  osx = Keymap.build("main", :osx) do
113
+ link "Cmd+Alt+Shift+R", Runnables::ShowRunnables
112
114
  link "Cmd+R", Runnables::RunEditTabCommand
113
115
  link "Cmd+Alt+R", Runnables::RunAlternateEditTabCommand
114
116
  end
@@ -162,6 +162,11 @@ module Redcar
162
162
  scroll_to_end(output_container)
163
163
  end
164
164
 
165
+ def open_file(file, line)
166
+ puts "i got called: #{file}"
167
+ Project::Manager.open_file(file)
168
+ end
169
+
165
170
  def index
166
171
  rhtml = ERB.new(File.read(File.join(File.dirname(__FILE__), "..", "..", "views", "command_output.html.erb")))
167
172
  command = @cmd
@@ -7,15 +7,26 @@ module Redcar
7
7
  def process(str, opts = {})
8
8
  str = str.to_s.gsub("&", "&amp;").gsub("<", "&lt;")
9
9
  str = process_ansi(str)
10
+ str = process_file_line_numbers(str)
10
11
  str = str.gsub(/\t+/, '<span style="white-space:pre;">\0</span>')
11
12
  str = str.reverse.gsub(/ (?= |$)/, ';psbn&').reverse
12
13
  if opts[:no_newline_after_br].nil?
13
- str.gsub("\n", "<br>\n")
14
+ str = str.gsub("\n", "<br>\n")
14
15
  else
15
- str.gsub("\n", "<br>")
16
- end
16
+ str = str.gsub("\n", "<br>")
17
+ end
17
18
  end
18
19
 
20
+ def process_file_line_numbers(str)
21
+ file_number_regex = /(\/\S+)\:(\d+)/
22
+ if str =~ file_number_regex
23
+ str.gsub(file_number_regex,
24
+ %{<a class="file_line_link" href="javascript:Controller.openFile('#{$1}', '#{$2}');">#{$1}:#{$2}</a>})
25
+ else
26
+ str
27
+ end
28
+ end
29
+
19
30
  def initialize
20
31
  @ansi_stack = []
21
32
  @ansi_colors = %w(black red green yellow blue purple cyan gray)
@@ -15,6 +15,7 @@
15
15
  </div>
16
16
  <form class="actions" action="javascript:return false;">
17
17
  <input type="submit" value="Run again" onclick="Controller.run();"/>
18
- </form>
19
- </body>
18
+ </form>
19
+ </body>
20
+
20
21
  </html>
@@ -32,9 +32,10 @@ module Redcar
32
32
  tab.is_a?(EditTab) and
33
33
  tab.edit_view.document.mirror.is_a?(Scm::CommitMirror)
34
34
  end,
35
- Sensitivity.new(:open_scm, Redcar.app, false, [:window_focussed]) do |window|
35
+ Sensitivity.new(:open_scm, Redcar.app, false,
36
+ [:window_focussed,:tree_removed,:tree_added]) do |window|
36
37
  project = Project::Manager.focussed_project
37
- not Scm::Manager.project_repositories[project].nil?
38
+ Scm::Manager.project_repositories[project]
38
39
  end
39
40
  ]
40
41
  end
@@ -42,6 +43,7 @@ module Redcar
42
43
  def self.keymaps
43
44
  osx = Keymap.build("main", :osx) do
44
45
  link "Cmd+Shift+C", Scm::CommitMirror::SaveCommand
46
+ link "Cmd+Shift+.", :command => Scm::CommitMirror::SaveCommand, :value => [:commit, [Scm::ScmChangesMirror, Scm::ScmChangesController]]
45
47
  end
46
48
 
47
49
  linwin = Keymap.build("main", [:linux, :windows]) do
@@ -3,26 +3,26 @@ module Redcar
3
3
  module Scm
4
4
  class DiffMirror
5
5
  include Redcar::Document::Mirror
6
-
6
+
7
7
  def initialize(change, diff)
8
8
  @change = change
9
9
  @diff = diff
10
10
  end
11
-
11
+
12
12
  def title
13
- "Diff: #{@change.path}"
13
+ "Diff: #{File.basename(@change.path)}"
14
14
  end
15
-
15
+
16
16
  def exists?
17
17
  true
18
18
  end
19
-
19
+
20
20
  # Diffs don't change. Each time the tree is refreshed, new Change
21
21
  # objects are created.
22
22
  def changed?
23
23
  false
24
24
  end
25
-
25
+
26
26
  def read
27
27
  @diff
28
28
  end
@@ -18,14 +18,14 @@ module Redcar
18
18
  module Git
19
19
  class Manager
20
20
  include Redcar::Scm::Model
21
-
21
+
22
22
  #######
23
23
  ## SCM plugin hooks
24
24
  #####
25
25
  def self.scm_module
26
26
  Redcar::Scm::Git::Manager
27
27
  end
28
-
28
+
29
29
  def self.supported?
30
30
  begin
31
31
  if ::Git::Lib.new.meets_required_version?
@@ -36,16 +36,16 @@ module Redcar
36
36
  end
37
37
  false
38
38
  end
39
-
39
+
40
40
  # Whether to print debugging messages. Default to whatever scm is using.
41
41
  def self.debug
42
42
  Redcar::Scm::Manager.debug
43
43
  end
44
-
44
+
45
45
  def debug
46
46
  Redcar::Scm::Git::Manager.debug
47
47
  end
48
-
48
+
49
49
  def from_data(data)
50
50
  data = data.split(':')
51
51
  file = ::Git::Status::StatusFile.new(nil, {
@@ -55,11 +55,11 @@ module Redcar
55
55
  repo = Scm::Git::Manager.new.load(data[2])
56
56
  Scm::Git::Change.new(file, repo, :file, data[4] == "true")
57
57
  end
58
-
58
+
59
59
  #######
60
60
  ## General stuff
61
61
  #####
62
-
62
+
63
63
  def inspect
64
64
  if @repo
65
65
  %Q{#<Scm::Git::Manager "#{@repo.dir.path}">}
@@ -67,17 +67,17 @@ module Redcar
67
67
  %Q{#<Scm::Git::Manager>}
68
68
  end
69
69
  end
70
-
70
+
71
71
  def cache
72
72
  @cache ||= begin
73
73
  c = ::BlockCache.new
74
-
74
+
75
75
  c.add('branches', 15) do
76
76
  ref_path = File.join(@repo.dir.path, '.git', 'refs', 'heads');
77
77
  head = File.read(File.join(@repo.dir.path, '.git', 'HEAD')).strip
78
78
  branch_globs = Dir.glob(File.join(ref_path, '*'))
79
79
  branches = []
80
-
80
+
81
81
  while branch = branch_globs.shift
82
82
  if File.directory?(branch)
83
83
  branch_globs.push(*Dir.glob(File.join(branch, '*')))
@@ -85,47 +85,47 @@ module Redcar
85
85
  branches.push branch
86
86
  end
87
87
  end
88
-
89
- branches.map {|b|
88
+
89
+ branches.map {|b|
90
90
  b[ref_path.length + 1, b.length - ref_path.length - 1]
91
- }.map {|b|
91
+ }.map {|b|
92
92
  [b, ('ref: refs/heads/' + b == head)]
93
93
  }
94
94
  end
95
-
95
+
96
96
  c.add('all branches', 15) do
97
97
  raise "not implemented"
98
98
  end
99
-
99
+
100
100
  c.add('status', 5) { @repo.status }
101
-
101
+
102
102
  c.add('full status', 5) { @repo.lib.full_status }
103
-
103
+
104
104
  c.add('config', 30) do
105
105
  config = Scm::Git::ConfigFile.parse(File.join(@repo.dir.path, '.git', 'config'))
106
106
  conf = {}
107
-
108
- config.each do |key, values|
107
+
108
+ config.each do |key, values|
109
109
  prefix = key.sub(/^([a-z]+) "(.+)"$/i, '\1.\2')
110
-
110
+
111
111
  values.each do |key2, value|
112
112
  conf[prefix + '.' + key2] = value
113
113
  end
114
114
  end
115
-
115
+
116
116
  conf
117
117
  end
118
-
119
- c.add('log', 60*60) do |start, finish|
118
+
119
+ c.add('log', 60*60) do |start, finish|
120
120
  @repo.lib.log_commits(:between => [start, finish]).reverse.map do |c|
121
121
  @repo.gcommit(c)
122
122
  end
123
123
  end
124
-
124
+
125
125
  c.add('submodules', 60*60) do
126
126
  begin
127
127
  modules = Scm::Git::ConfigFile.parse(File.join(@repo.dir.path, '.gitmodules'))
128
-
128
+
129
129
  mods = {}
130
130
  modules.each {|k, v|
131
131
  path = File.join(@repo.dir.path, v['path'])
@@ -140,69 +140,80 @@ module Redcar
140
140
  {}
141
141
  end
142
142
  end
143
-
143
+
144
144
  c
145
145
  end
146
146
  end
147
-
147
+
148
148
  #######
149
149
  ## SCM hooks
150
150
  #####
151
- attr_reader :repo
152
-
151
+ attr_reader :repo, :path
152
+
153
153
  def repository_type
154
154
  "git"
155
155
  end
156
-
156
+
157
157
  def repository?(path)
158
- File.exist?(File.join(path, %w{.git}))
158
+ return true if repository_path(path)
159
159
  end
160
-
160
+
161
+ def repository_path(path)
162
+ if File.exist?(File.join(path, %w{.git}))
163
+ return path
164
+ else
165
+ unless path == File.dirname(path)
166
+ repository_path(File.dirname(path))
167
+ end
168
+ end
169
+ end
170
+
161
171
  def supported_commands
162
172
  [:init, :commit, :index, :switch_branch, :push]
163
173
  end
164
-
174
+
165
175
  def refresh
166
176
  cache.refresh
167
177
  end
168
-
178
+
169
179
  def init!(path)
170
180
  # Be nice and don't blow away another repository accidentally.
171
181
  return nil if File.exist?(File.join(path, %w{.git}))
172
-
182
+
173
183
  ::Git.init(path)
174
184
  end
175
-
185
+
176
186
  def load(path)
177
187
  raise "Already loaded repository" if @repo
178
- @repo = ::Git.open(path)
188
+ @repo = ::Git.open(repository_path(path))
189
+ @path = path
179
190
  cache.refresh
180
191
  self
181
192
  end
182
-
193
+
183
194
  # Not used by scm, but we do use this internally.
184
195
  def uncommited_changes
185
196
  indexed_changes + unindexed_changes
186
197
  end
187
-
198
+
188
199
  # @return [Array<Redcar::Scm::ScmChangeMirror::Change>]
189
200
  def indexed_changes
190
201
  prepare_changes(true)
191
202
  end
192
-
203
+
193
204
  # @return [Array<Redcar::Scm::ScmChangeMirror::Change>]
194
205
  def unindexed_changes
195
206
  prepare_changes(false)
196
207
  end
197
-
198
- private
199
-
208
+
209
+ private
210
+
200
211
  CHANGE_PRIORITIES = {:sub_project => 0, :directory => 1, :file => 2}
201
-
212
+
202
213
  def prepare_changes(indexed)
203
- changes = cache['submodules'].find_all do |k,s|
214
+ changes = cache['submodules'].find_all do |k,s|
204
215
  s.uncommited_changes.length > 0
205
- end.map do |k,s|
216
+ end.map do |k,s|
206
217
  file = ::Git::Status::StatusFile.new(nil, {
207
218
  :path => k,
208
219
  :type => "M",
@@ -210,27 +221,30 @@ module Redcar
210
221
  })
211
222
  [k, file]
212
223
  end
213
-
224
+
214
225
  changes += cache['status'].all_changes.find_all {|c| not changes.find{|d| c[0] == d[0]}}
215
-
226
+
216
227
  # f[0] is the path, and f[1] is the actual StatusFile
217
- changes.find_all {|c| valid_change?(c[1].type_raw, indexed)}.map do |f|
228
+ changes.find_all {|c| valid_change?(c[1].type_raw, indexed)}.map do |f|
218
229
  full_path = File.join(@repo.dir.path, f[0])
219
230
  type = (((not File.exist?(full_path)) or File.file?(full_path)) ? :file : :directory)
220
-
231
+
221
232
  if type == :directory and cache['submodules'][f[0]]
222
233
  type = :sub_project
223
234
  end
224
-
235
+
225
236
  if type == :sub_project
226
237
  submodule = cache['submodules'][f[0]]
227
- Scm::Git::Change.new(f[1], self, type, indexed, indexed ? submodule.indexed_changes : submodule.unindexed_changes)
238
+ Scm::Git::Change.new(
239
+ f[1], self, type, indexed,
240
+ indexed ? submodule.indexed_changes : submodule.unindexed_changes
241
+ )
228
242
  else
229
243
  Scm::Git::Change.new(f[1], self, type, indexed)
230
244
  end
231
245
  end.sort_by {|m| m.path}.sort_by {|m| CHANGE_PRIORITIES[m.type]}
232
246
  end
233
-
247
+
234
248
  def valid_change?(type, indexed)
235
249
  if (not indexed) and type[1,1] != " "
236
250
  true
@@ -240,34 +254,34 @@ module Redcar
240
254
  false
241
255
  end
242
256
  end
243
-
257
+
244
258
  public
245
-
259
+
246
260
  # REQUIRED for :index. Adds a new file to the index.
247
261
  def index_add(change)
248
262
  # delegate to the proper submodule
249
263
  if self != change.repo
250
264
  return change.repo.index_add(change)
251
265
  end
252
-
266
+
253
267
  @repo.add(change.path)
254
268
  cache.refresh
255
269
  true # refresh trees
256
270
  end
257
-
271
+
258
272
  # REQUIRED for :index. Ignores a new file so it won't show in changes.
259
273
  def index_ignore(change)
260
274
  # delegate to the proper submodule
261
275
  if self != change.repo
262
276
  return change.repo.index_ignore(change)
263
277
  end
264
-
278
+
265
279
  add_to_gitignore(change.path)
266
-
280
+
267
281
  cache.refresh
268
282
  true # refresh trees
269
283
  end
270
-
284
+
271
285
  # REQUIRED for :index. Ignores all files with a certain extension so they
272
286
  # won't show in changes.
273
287
  def index_ignore_all(extension, change)
@@ -275,22 +289,22 @@ module Redcar
275
289
  if self != change.repo
276
290
  return change.repo.index_ignore(change)
277
291
  end
278
-
292
+
279
293
  add_to_gitignore("*." + extension)
280
-
294
+
281
295
  cache.refresh
282
296
  true # refresh trees
283
297
  end
284
-
298
+
285
299
  private
286
-
300
+
287
301
  def add_to_gitignore(line)
288
302
  gitignore = File.join(repo.dir.path, '.gitignore')
289
303
  if not File.exist? gitignore
290
304
  File.new(gitignore, "w").close
291
305
  end
292
306
  gitignore = File.new(gitignore, 'r+')
293
-
307
+
294
308
  # Make sure there's data in the file, otherwise we can't seek.
295
309
  if File.size(gitignore) > 0
296
310
  # Check the last byte of the file for a newline
@@ -299,20 +313,20 @@ module Redcar
299
313
  gitignore.syswrite("\n")
300
314
  end
301
315
  end
302
-
316
+
303
317
  gitignore.syswrite(line + "\n")
304
318
  gitignore.close
305
319
  end
306
-
320
+
307
321
  public
308
-
322
+
309
323
  # REQUIRED for :index. Reverts a file to its last commited state.
310
324
  def index_revert(change)
311
325
  # delegate to the proper submodule
312
326
  if self != change.repo
313
327
  return change.repo.index_revert(change)
314
328
  end
315
-
329
+
316
330
  if change.git_status[0,1] != ' '
317
331
  # Git requires us to unindex any changes before we can revert them.
318
332
  index_unsave(change)
@@ -327,33 +341,33 @@ module Redcar
327
341
  cache.refresh
328
342
  true # refresh trees
329
343
  end
330
-
331
- # REQUIRED for :index. Reverts a file in the index back to it's
344
+
345
+ # REQUIRED for :index. Reverts a file in the index back to it's
332
346
  # last commited state, but leaves the file intact.
333
347
  def index_unsave(change)
334
348
  # delegate to the proper submodule
335
349
  if self != change.repo
336
350
  return change.repo.index_unsave(change)
337
351
  end
338
-
352
+
339
353
  @repo.reset('HEAD', :file => change.path)
340
-
354
+
341
355
  cache.refresh
342
356
  true # refresh trees
343
357
  end
344
-
358
+
345
359
  # REQUIRED for :index. Saves changes made to a file in the index.
346
360
  def index_save(change)
347
361
  # delegate to the proper submodule
348
362
  if self != change.repo
349
363
  return change.repo.index_save(change)
350
364
  end
351
-
365
+
352
366
  @repo.add(change.path)
353
367
  cache.refresh
354
368
  true # refresh trees
355
369
  end
356
-
370
+
357
371
  # REQUIRED for :index. Restores a file to the last known state of
358
372
  # the file. This may be from the index, or the last commit.
359
373
  def index_restore(change)
@@ -361,19 +375,19 @@ module Redcar
361
375
  if self != change.repo
362
376
  return change.repo.index_restore(change)
363
377
  end
364
-
378
+
365
379
  @repo.checkout_file('HEAD', change.path)
366
380
  cache.refresh
367
381
  true # refresh trees
368
382
  end
369
-
383
+
370
384
  # REQUIRED for :index. Marks a file as deleted in the index.
371
385
  def index_delete(change)
372
386
  # delegate to the proper submodule
373
387
  if self != change.repo
374
388
  return change.repo.index_delete(change)
375
389
  end
376
-
390
+
377
391
  if change.git_status[1,1] == '?'
378
392
  FileUtils.rm(File.join(@repo.dir.path, change.path))
379
393
  else
@@ -382,8 +396,8 @@ module Redcar
382
396
  cache.refresh
383
397
  true # refresh trees
384
398
  end
385
-
386
- # REQUIRED for :commit. Commits the currently indexed changes
399
+
400
+ # REQUIRED for :commit. Commits the currently indexed changes
387
401
  # in the subproject.
388
402
  #
389
403
  # @param change Required for :commitable changes. Ignore if
@@ -394,7 +408,7 @@ module Redcar
394
408
  if self != change.repo
395
409
  return change.repo.commit!(change)
396
410
  end
397
-
411
+
398
412
  # redelegate the commit to the subproject to handle
399
413
  cache['submodules'][change.path].commit!(message)
400
414
  else
@@ -402,8 +416,8 @@ module Redcar
402
416
  cache.refresh
403
417
  end
404
418
  end
405
-
406
- # REQUIRED for :commit. Gets a default commit message for the
419
+
420
+ # REQUIRED for :commit. Gets a default commit message for the
407
421
  # currently indexed changes.
408
422
  #
409
423
  # @param change Required for :commitable changes. Ignore if
@@ -414,60 +428,75 @@ module Redcar
414
428
  if self != change.repo
415
429
  return change.repo.commit!(change)
416
430
  end
417
-
431
+
418
432
  # redelegate the call to the subproject to handle
419
433
  cache['submodules'][change.path].commit_message
420
434
  else
421
435
  "\n\n" + cache['full status']
422
436
  end
423
437
  end
424
-
438
+
425
439
  # REQUIRED for :switch_branch. Returns an array of branch names.
426
440
  #
427
441
  # @return [Array<String>]
428
442
  def branches
429
- cache['branches'].map {|b| b[0]}
443
+ branch_list = cache['branches'].map {|b| b[0]}
444
+ branch_list + ['New...']
430
445
  end
431
-
446
+
432
447
  # REQUIRED for :switch_branch. Returns the name of the current branch.
433
448
  def current_branch
434
449
  b = cache['branches'].select { |b| b[1] }.first
435
-
450
+
436
451
  b.nil? ? "" : b[0]
437
452
  end
438
-
453
+
439
454
  # REQUIRED for :switch_branch. Switches to the named branch.
440
455
  def switch!(branch)
441
- @repo.checkout(branch)
456
+ if branch == 'New...'
457
+ result = Application::Dialog.input("New Branch Name",
458
+ "Please enter a new branch name","")
459
+ if value = result[:value] and value != ""
460
+ newbranch = value
461
+ begin
462
+ @repo.branch(newbranch).checkout
463
+ rescue Object => e
464
+ Application::Dialog.message_box(e.to_s)
465
+ e.backtrace.each {|line| p line}
466
+ end
467
+ end
468
+ else
469
+ @repo.checkout(branch)
470
+ end
442
471
  cache.refresh
443
472
  end
444
-
473
+
445
474
  def push_targets
446
475
  targets = branches.map {|b| Scm::ScmCommitsMirror::CommitsNode.new(self, b)}
447
476
  modules = cache['submodules'].clone
448
-
477
+
449
478
  while m = modules.shift
450
479
  path = m[0]
451
480
  m[1].cache['submodules'].each {|k,v| modules[File.join(path, k)] = v}
452
-
481
+
453
482
  targets += m[1].branches.map {|b| Scm::ScmCommitsMirror::CommitsNode.new(m[1], b, "#{b} (#{path})")}
454
483
  end
455
-
484
+
456
485
  # only return targets we can actually push to
457
486
  targets.find_all do |t|
458
487
  remote = t.repo.cache['config']['branch.' + t.branch + '.remote']
459
-
488
+
460
489
  if remote
461
490
  push_target = t.repo.cache['config']['branch.' + t.branch + '.push'] || t.repo.cache['config']['branch.' + t.branch + '.merge']
462
-
491
+
463
492
  push_target.gsub!(/^refs\/heads\//, '')
464
493
  r_ref_file = File.join(t.repo.repo.dir.path, '.git', 'refs', 'remotes', remote, push_target)
465
-
494
+
466
495
  File.exist?(r_ref_file)
467
496
  end
468
497
  end
469
498
  end
470
-
499
+
471
500
  # REQUIRED for :push. Returns an array of unpushed changesets.
472
501
  #
473
502
  # @return [Array<Redcar::Scm::ScmMirror::Commit>]
@@ -475,19 +504,19 @@ module Redcar
475
504
  # Hit `git config -l` to figure out which remote/ref this branch uses for pushing.
476
505
  remote = cache['config']['branch.' + branch + '.remote']
477
506
  push_target = cache['config']['branch.' + branch + '.push'] || cache['config']['branch.' + branch + '.merge']
478
-
507
+
479
508
  # We don't have a remote setup for pushes, so we can't automatically push
480
509
  return [] if remote.nil?
481
-
510
+
482
511
  # Hit .git/remotes/$REMOTE/$REF to find out which revision that ref is at.
483
512
  push_target.gsub!(/^refs\/heads\//, '')
484
513
  r_ref_file = File.join(@repo.dir.path, '.git', 'refs', 'remotes', remote, push_target)
485
514
  return [] if not File.exist?(r_ref_file)
486
515
  r_ref = File.read(r_ref_file).strip
487
-
516
+
488
517
  # Hit .git/refs/heads/$BRANCH to figure out which revision we're at locally.
489
518
  l_ref = File.read(File.join(@repo.dir.path, '.git', 'refs', 'heads', branch)).strip
490
-
519
+
491
520
  # Hit `git log $R_REV..$L_REV` to get a list of commits that are unpushed.
492
521
  if r_ref != l_ref
493
522
  cache['log', r_ref, l_ref].map {|c| Scm::Git::Commit.new(c)}
@@ -495,20 +524,20 @@ module Redcar
495
524
  []
496
525
  end
497
526
  end
498
-
527
+
499
528
  # REQUIRED for :push. Pushes all current changesets to the remote
500
529
  # repository.
501
530
  def push!(branch=current_branch)
502
531
  remote = cache['config']['branch.' + branch + '.remote']
503
532
  push_target = cache['config']['branch.' + branch + '.push'] || cache['config']['branch.' + branch + '.merge']
504
-
533
+
505
534
  # don't block while trying to push changes
506
535
  Thread.new do
507
536
  repo.push(remote, '+refs/heads/' + branch + ':' + push_target)
508
-
537
+
509
538
  Redcar.update_gui { cache.refresh; Scm::Manager.refresh_trees }
510
539
  end
511
-
540
+
512
541
  false # don't refresh trees
513
542
  end
514
543
  end