assaf-buildr 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. data/CHANGELOG +887 -0
  2. data/DISCLAIMER +7 -0
  3. data/LICENSE +176 -0
  4. data/NOTICE +26 -0
  5. data/README.rdoc +146 -0
  6. data/Rakefile +62 -0
  7. data/_buildr +38 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/cobertura.rb +236 -0
  10. data/addon/buildr/emma.rb +238 -0
  11. data/addon/buildr/hibernate.rb +142 -0
  12. data/addon/buildr/javacc.rb +85 -0
  13. data/addon/buildr/jdepend.rb +60 -0
  14. data/addon/buildr/jetty.rb +248 -0
  15. data/addon/buildr/jibx.rb +86 -0
  16. data/addon/buildr/nailgun.rb +817 -0
  17. data/addon/buildr/openjpa.rb +90 -0
  18. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  19. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  20. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  21. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  22. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  23. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  25. data/addon/buildr/xmlbeans.rb +93 -0
  26. data/bin/buildr +28 -0
  27. data/buildr.buildfile +53 -0
  28. data/buildr.gemspec +58 -0
  29. data/doc/css/default.css +228 -0
  30. data/doc/css/print.css +100 -0
  31. data/doc/css/syntax.css +52 -0
  32. data/doc/images/apache-incubator-logo.png +0 -0
  33. data/doc/images/buildr-hires.png +0 -0
  34. data/doc/images/buildr.png +0 -0
  35. data/doc/images/favicon.png +0 -0
  36. data/doc/images/growl-icon.tiff +0 -0
  37. data/doc/images/note.png +0 -0
  38. data/doc/images/project-structure.png +0 -0
  39. data/doc/images/tip.png +0 -0
  40. data/doc/images/zbuildr.tif +0 -0
  41. data/doc/pages/artifacts.textile +207 -0
  42. data/doc/pages/building.textile +240 -0
  43. data/doc/pages/contributing.textile +208 -0
  44. data/doc/pages/download.textile +62 -0
  45. data/doc/pages/extending.textile +175 -0
  46. data/doc/pages/getting_started.textile +273 -0
  47. data/doc/pages/index.textile +42 -0
  48. data/doc/pages/languages.textile +407 -0
  49. data/doc/pages/mailing_lists.textile +17 -0
  50. data/doc/pages/more_stuff.textile +286 -0
  51. data/doc/pages/packaging.textile +427 -0
  52. data/doc/pages/projects.textile +274 -0
  53. data/doc/pages/recipes.textile +103 -0
  54. data/doc/pages/settings_profiles.textile +274 -0
  55. data/doc/pages/testing.textile +212 -0
  56. data/doc/pages/troubleshooting.textile +103 -0
  57. data/doc/pages/whats_new.textile +323 -0
  58. data/doc/print.haml +51 -0
  59. data/doc/print.toc.yaml +29 -0
  60. data/doc/scripts/buildr-git.rb +412 -0
  61. data/doc/scripts/install-jruby.sh +44 -0
  62. data/doc/scripts/install-linux.sh +64 -0
  63. data/doc/scripts/install-osx.sh +52 -0
  64. data/doc/site.haml +56 -0
  65. data/doc/site.toc.yaml +47 -0
  66. data/etc/KEYS +151 -0
  67. data/etc/git-svn-authors +16 -0
  68. data/lib/buildr.rb +35 -0
  69. data/lib/buildr/core.rb +27 -0
  70. data/lib/buildr/core/application.rb +489 -0
  71. data/lib/buildr/core/application_cli.rb +139 -0
  72. data/lib/buildr/core/build.rb +311 -0
  73. data/lib/buildr/core/checks.rb +382 -0
  74. data/lib/buildr/core/common.rb +154 -0
  75. data/lib/buildr/core/compile.rb +596 -0
  76. data/lib/buildr/core/environment.rb +120 -0
  77. data/lib/buildr/core/filter.rb +362 -0
  78. data/lib/buildr/core/generate.rb +195 -0
  79. data/lib/buildr/core/help.rb +118 -0
  80. data/lib/buildr/core/progressbar.rb +156 -0
  81. data/lib/buildr/core/project.rb +892 -0
  82. data/lib/buildr/core/test.rb +715 -0
  83. data/lib/buildr/core/transports.rb +558 -0
  84. data/lib/buildr/core/util.rb +289 -0
  85. data/lib/buildr/groovy.rb +18 -0
  86. data/lib/buildr/groovy/bdd.rb +105 -0
  87. data/lib/buildr/groovy/compiler.rb +138 -0
  88. data/lib/buildr/ide.rb +19 -0
  89. data/lib/buildr/ide/eclipse.rb +212 -0
  90. data/lib/buildr/ide/idea.ipr.template +300 -0
  91. data/lib/buildr/ide/idea.rb +189 -0
  92. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  93. data/lib/buildr/ide/idea7x.rb +210 -0
  94. data/lib/buildr/java.rb +23 -0
  95. data/lib/buildr/java/ant.rb +92 -0
  96. data/lib/buildr/java/bdd.rb +449 -0
  97. data/lib/buildr/java/commands.rb +211 -0
  98. data/lib/buildr/java/compiler.rb +348 -0
  99. data/lib/buildr/java/deprecated.rb +141 -0
  100. data/lib/buildr/java/jruby.rb +117 -0
  101. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  102. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  103. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +119 -0
  104. data/lib/buildr/java/packaging.rb +713 -0
  105. data/lib/buildr/java/pom.rb +178 -0
  106. data/lib/buildr/java/rjb.rb +155 -0
  107. data/lib/buildr/java/test_result.rb +308 -0
  108. data/lib/buildr/java/tests.rb +324 -0
  109. data/lib/buildr/java/version_requirement.rb +172 -0
  110. data/lib/buildr/packaging.rb +21 -0
  111. data/lib/buildr/packaging/artifact.rb +730 -0
  112. data/lib/buildr/packaging/artifact_namespace.rb +972 -0
  113. data/lib/buildr/packaging/artifact_search.rb +140 -0
  114. data/lib/buildr/packaging/gems.rb +102 -0
  115. data/lib/buildr/packaging/package.rb +233 -0
  116. data/lib/buildr/packaging/tar.rb +104 -0
  117. data/lib/buildr/packaging/zip.rb +722 -0
  118. data/lib/buildr/resources/buildr.icns +0 -0
  119. data/lib/buildr/scala.rb +19 -0
  120. data/lib/buildr/scala/compiler.rb +109 -0
  121. data/lib/buildr/scala/tests.rb +203 -0
  122. data/rakelib/apache.rake +191 -0
  123. data/rakelib/changelog.rake +57 -0
  124. data/rakelib/doc.rake +103 -0
  125. data/rakelib/package.rake +73 -0
  126. data/rakelib/release.rake +65 -0
  127. data/rakelib/rspec.rake +83 -0
  128. data/rakelib/rubyforge.rake +53 -0
  129. data/rakelib/scm.rake +49 -0
  130. data/rakelib/setup.rake +86 -0
  131. data/rakelib/stage.rake +48 -0
  132. data/spec/addon/cobertura_spec.rb +77 -0
  133. data/spec/addon/emma_spec.rb +120 -0
  134. data/spec/addon/test_coverage_spec.rb +255 -0
  135. data/spec/core/application_spec.rb +412 -0
  136. data/spec/core/artifact_namespace_spec.rb +646 -0
  137. data/spec/core/build_spec.rb +415 -0
  138. data/spec/core/checks_spec.rb +537 -0
  139. data/spec/core/common_spec.rb +664 -0
  140. data/spec/core/compile_spec.rb +566 -0
  141. data/spec/core/generate_spec.rb +33 -0
  142. data/spec/core/project_spec.rb +754 -0
  143. data/spec/core/test_spec.rb +1091 -0
  144. data/spec/core/transport_spec.rb +500 -0
  145. data/spec/groovy/bdd_spec.rb +80 -0
  146. data/spec/groovy/compiler_spec.rb +239 -0
  147. data/spec/ide/eclipse_spec.rb +243 -0
  148. data/spec/java/ant.rb +28 -0
  149. data/spec/java/bdd_spec.rb +358 -0
  150. data/spec/java/compiler_spec.rb +446 -0
  151. data/spec/java/java_spec.rb +88 -0
  152. data/spec/java/packaging_spec.rb +1103 -0
  153. data/spec/java/tests_spec.rb +466 -0
  154. data/spec/packaging/archive_spec.rb +503 -0
  155. data/spec/packaging/artifact_spec.rb +754 -0
  156. data/spec/packaging/packaging_helper.rb +63 -0
  157. data/spec/packaging/packaging_spec.rb +589 -0
  158. data/spec/sandbox.rb +137 -0
  159. data/spec/scala/compiler_spec.rb +228 -0
  160. data/spec/scala/tests_spec.rb +215 -0
  161. data/spec/spec_helpers.rb +304 -0
  162. data/spec/version_requirement_spec.rb +123 -0
  163. metadata +369 -0
@@ -0,0 +1,51 @@
1
+ -# Licensed to the Apache Software Foundation (ASF) under one or more
2
+ -# contributor license agreements. See the NOTICE file distributed with this
3
+ -# work for additional information regarding copyright ownership. The ASF
4
+ -# licenses this file to you under the Apache License, Version 2.0 (the
5
+ -# "License"); you may not use this file except in compliance with the License.
6
+ -# You may obtain a copy of the License at
7
+ -#
8
+ -# http://www.apache.org/licenses/LICENSE-2.0
9
+ -#
10
+ -# Unless required by applicable law or agreed to in writing, software
11
+ -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ -# License for the specific language governing permissions and limitations under
14
+ -# the License.
15
+
16
+ !!! 1.1
17
+ %html
18
+ %head
19
+ %meta{ 'http-equiv'=>'Content-Type', :content=>'text/html;charset=UTF-8' }/
20
+ %title= collection.title
21
+ %style{ :type=>'text/css' }
22
+ @import 'css/default.css';
23
+ @import 'css/syntax.css';
24
+ @import 'css/print.css' print;
25
+ %meta{ :name=>'subject', :content=>'Official Buildr documentation from the people in the know' }
26
+ %meta{ :name=>'author', :content=>'http://incubator.apache.org/buildr' }
27
+ %body
28
+ #wrap
29
+ #header
30
+ %img{ :src=>'images/buildr-hires.png', :alt=>collection.title, :style=>'width:20em' }
31
+ .tagline= ''
32
+ #content
33
+ = collection.toc.to_html(:nested, :class=>'toc')
34
+ #license
35
+ %p Copyright 2007-2008 Apache Buildr
36
+ %p
37
+ Licensed under the Apache License, Version 2.0 (the "License"); you
38
+ may not use this file except in compliance with the License. You
39
+ may obtain a copy of the License at
40
+ %p{ :style=>'margin-left: 2em' }
41
+ %a{ :href=>'http://www.apache.org/licenses/LICENSE-2.0' } http://www.apache.org/licenses/LICENSE-2.0
42
+ %p
43
+ Unless required by applicable law or agreed to in writing, software
44
+ distributed under the License is distributed on an "AS IS" BASIS,
45
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
46
+ implied. See the License for the specific language governing
47
+ permissions and limitations under the License.
48
+ - pages.each do |page|
49
+ %h1{ :id=>page.id }= page.title
50
+ = page.toc.to_html(:nested, :class=>'toc')
51
+ ~ collect_links(renumber_footnotes(page.content))
@@ -0,0 +1,29 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+ - Welcome: index.html
17
+ - Getting Started: getting_started.html
18
+ - Projects: projects.html
19
+ - Building: building.html
20
+ - Artifacts: artifacts.html
21
+ - Packaging: packaging.html
22
+ - Testing: testing.html
23
+ - Settings/Profiles: settings_profiles.html
24
+ - Languages: languages.html
25
+ - More Stuff: more_stuff.html
26
+ - Extending: extending.html
27
+ - Recipes: recipes.html
28
+ - Troubleshooting: troubleshooting.html
29
+ - Contributing: contributing.html
@@ -0,0 +1,412 @@
1
+ #!/usr/bin/env ruby
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with this
4
+ # work for additional information regarding copyright ownership. The ASF
5
+ # licenses this file to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ # License for the specific language governing permissions and limitations under
15
+ # the License.
16
+
17
+
18
+ # This script helps buildr developers to obtain their own git clone from
19
+ # github, having a set of pre-defined aliases to work with Apache's SVN.
20
+ #
21
+ # You dont need to have a buildr copy to use it, just execute the buildr-git balloon:
22
+ #
23
+ # ruby -ropen-uri -e 'eval(open("http://balloon.hobix.com/buildr-git").read)'
24
+
25
+ require 'yaml'
26
+ require 'optparse'
27
+ require 'ostruct'
28
+
29
+ # Pager from http://nex-3.com/posts/73-git-style-automatic-paging-in-ruby
30
+ def run_pager
31
+ return if RUBY_PLATFORM =~ /win32/
32
+ return unless STDOUT.tty?
33
+
34
+ read, write = IO.pipe
35
+
36
+ unless Kernel.fork # Child process
37
+ STDOUT.reopen(write)
38
+ STDERR.reopen(write) if STDERR.tty?
39
+ read.close
40
+ write.close
41
+ return
42
+ end
43
+
44
+ # Parent process, become pager
45
+ STDIN.reopen(read)
46
+ read.close
47
+ write.close
48
+
49
+ ENV['LESS'] = 'FSRX' # Don't page if the input is short enough
50
+
51
+ Kernel.select [STDIN] # Wait until we have input before we start the pager
52
+ pager = ENV['PAGER'] || 'less'
53
+ exec pager rescue exec "/bin/sh", "-c", pager
54
+ end
55
+
56
+ def header
57
+ <<HEADER
58
+
59
+ Buildr official commit channel is Apache's svn repository, however some
60
+ developers may prefer to use git while working on several features and
61
+ merging other's changes.
62
+
63
+ This script will configure a buildr-git copy on so you can commit to svn.
64
+
65
+ Enter <-h> to see options, <-H> to see notes about configured aliases
66
+ and recommended workflow, or any other option.
67
+
68
+ Ctrl+D or an invalid option to abort
69
+ HEADER
70
+ end
71
+
72
+ def notice
73
+ <<NOTICE
74
+ ALIASES:
75
+
76
+ Some git aliases have been created for developer convenience:
77
+
78
+ git apache-fetch # get changes from apache/trunk without merging them
79
+ # you can inspect what's happening on trunk without
80
+ # having to worry about merging conflicts.
81
+ # Inspect the remote branch with `git log apache/trunk`
82
+ # Or if you have a git-ui like `tig` you can use that.
83
+
84
+ git apache-merge # Merge already fetched changes on the current branch
85
+ # Use this command to get up to date with trunk changes
86
+ # you can always cherry-pick from the apache/trunk
87
+ # branch.
88
+
89
+ git apache-pull # get apache-fetch && git apache-merge
90
+
91
+ git apache-push # Push to Apache's SVN. Only staged changes (those
92
+ # recorded using `git commit`) will be sent to SVN.
93
+ # You need not to be on the master branch.
94
+ # Actually you can work on a tiny-feature branch and
95
+ # commit directly from it.
96
+ #
97
+ # VERY IMPORTANT:
98
+ #
99
+ # Missing commits on Apache's SVN will be sent using
100
+ # your apache svn account. This means that you can
101
+ # make some commits on behalf of others (like patches
102
+ # comming from JIRA issues or casual contributors)
103
+ # Review the apache-push alias on .git/config if you
104
+ # want to change login-name used for commit to SVN.
105
+ #
106
+ # See the recommended workflow to avoid commiting
107
+ # other developers' changes and the following section.
108
+
109
+ THE GITHUB MIRROR:
110
+
111
+ Buildr has an unofficial git mirror on github, maintained by Victor:
112
+
113
+ http://github.com/vic/buildr
114
+
115
+ Actually it's not Victor who manually updates it, he has a cron-job on his
116
+ server, that only runs
117
+
118
+ git synchronize
119
+
120
+ A command you also have configured on your .git/config file.
121
+
122
+ However there are some limitations due to the fact that git-svn cannot
123
+ commit as multiple authors (unless all of them provided their passwords
124
+ to Victor, yet he doesn't want to take over the world.)
125
+ This means that if a commit is pushed to vic/buildr/master and has not
126
+ already been pushed by YOU to Apache's SVN by using `git apache-push`
127
+ your change will be commited to apache/trunk having Victor as the author
128
+ (that's how he gains meritocratic points at Apache :P).
129
+
130
+ So, it's very important - if you care about meritocracy - to follow or at
131
+ least that you get an idea of the recommended workflow.
132
+
133
+ RECOMMENDED WORKFLOW:
134
+
135
+ So now that you have your local buildr copy you can create topic branches
136
+ to work on independent features, and still merge easily with head changes.
137
+
138
+ They may seem lots of things to consider, but it's all for Buildr's healt.
139
+ As all things git, you can always follow your own workflow and even create
140
+ aliases on you .git/config file to avoid typing much. So, here they are:
141
+
142
+ 1) get your buildr-git configured
143
+ (you have already do so, this was the most difficult part)
144
+
145
+ 2) create a topic branch to work on, say.. you want to add cool-feature:
146
+
147
+ git checkout -b cool-feature master
148
+ # now on branch cool-feature
149
+
150
+ 3) hack hack hack.. use the source luke.
151
+ every time you feel you have something important like added failing
152
+ spec, added part of feature, or resolved some conflict from merges,
153
+ you can commit your current progress. If you want to be selective, use:
154
+
155
+ git commit --interactive
156
+
157
+ 3) review your changes, get ALL specs passing, repeat step 3 as needed
158
+
159
+ 4) let's see what are they doing on trunk
160
+
161
+ git apache-fetch
162
+ # You can inspect the upstream changes without having to merge them
163
+ git log apache/trunk # what are they doing!!
164
+
165
+ 5) integrate mainstream changes to your cool-feature branch, you can always
166
+ use `git cherry-pick` to select only some commits.
167
+
168
+ git merge apache/trunk cool-feature
169
+
170
+ 6) Go to 3 unless ALL specs are passing.
171
+
172
+ 7.a) (Skip to 7.b you have commit bit on Apache's SVN)
173
+ Create a patch using `git format-patch`
174
+ Promote your changes, create a JIRA issue and upload it granting Apache
175
+ license to include your code:
176
+
177
+ https://issues.apache.org/jira/browse/BUILDR
178
+ buildr-dev@incubator.apache.org
179
+
180
+ 7.b) Now you have everyhing on staging area and merged important changes
181
+ from apache/trunk, it's time to commit them to Apache's SVN.
182
+
183
+ git apache-push
184
+
185
+ 8) Optional. If you can push to vic/buildr/master mirror, you can just
186
+ synchronize the mirror helping others to get changes without having to
187
+ wait on Victor's cronjob to run every hour (useful for urgent changes).
188
+
189
+ git synchronize
190
+
191
+ 9) Pull changes from origin frequently.
192
+
193
+ git fetch origin
194
+ git rebase --onto origin/master master master
195
+
196
+ 10) Unconditionally, Go to step 2 ;)
197
+ Share your buildr-git workflow, git tips, etc.
198
+
199
+ RESOURCES:
200
+
201
+ http://github.com/vic/buildr/tree/master
202
+ http://git.or.cz/gitwiki/GitCheatSheet
203
+ http://groups.google.com/group/git-users/web/git-references
204
+
205
+ NOTICE
206
+ end # notice method
207
+
208
+ def optparse(options = OpenStruct.new, argv = ARGV)
209
+ opt = OptionParser.new do |opt|
210
+
211
+ if `git status 2>/dev/null`.chomp.empty?
212
+ options.local = File.expand_path('buildr', Dir.pwd)
213
+ else
214
+ puts "Current directory is a git repo: #{Dir.pwd}"
215
+ options.local = Dir.pwd
216
+ end
217
+
218
+ options.svn_branch = "apache/trunk"
219
+ options.origin = "git://github.com/vic/buildr.git"
220
+ options.member = false
221
+
222
+ opt.banner = "Usage: buildr-git.rb [options]"
223
+ opt.separator ""
224
+ opt.separator "OPTIONS:"
225
+
226
+ opt.on('-a', "--anon", "Use git://github.com/vic/buildr.git as origin") do
227
+ options.origin = "git://github.com/vic/buildr.git"
228
+ end
229
+ opt.on('-A', "--auth", "Use git@github.com:vic/buildr.git as origin") do
230
+ options.origin = "git@github.com:vic/buildr.git"
231
+ end
232
+ opt.on("-o", "--origin GIT_URL", "Clone from GIT_URL origin") do |value|
233
+ options.origin = value
234
+ end
235
+ opt.on('-l', "--local DIRECTORY", "Create local git clone on DIRECTORY") do |value|
236
+ options.local = value
237
+ end
238
+ opt.on('-b', "--branch GIT_SVN_BRANCH",
239
+ "Set the name for svn branch instead of apache/trunk") do |value|
240
+ options.svn_branch = value
241
+ end
242
+ opt.on('-e', "--email EMAIL",
243
+ "Configure git to use EMAIL for commits") do |value|
244
+ options.email = value
245
+ end
246
+ opt.on('-n', "--name USER_NAME",
247
+ "Configure your USER_NAME for git commits") do |value|
248
+ options.user_name = value
249
+ end
250
+ opt.on('-h', "--help", "Show buildr-git help") do
251
+ puts opt
252
+ throw :exit
253
+ end
254
+ opt.on('-H', "--notice", "Show notice about aliases and git workflow") do
255
+ run_pager
256
+ puts notice
257
+ throw :exit
258
+ end
259
+ end
260
+ opt.parse!(argv)
261
+ options
262
+ end # optparse method
263
+
264
+
265
+ def main
266
+ catch :exit do
267
+ options = optparse
268
+ puts header
269
+ puts
270
+ print '> '
271
+ if input = gets
272
+ options = optparse(options, input.split)
273
+ end
274
+ if input.nil? || (input != "\n" && input.empty?)
275
+ puts "Aborting."
276
+ return
277
+ end
278
+ perform(options)
279
+ end
280
+ end
281
+
282
+ def perform(options)
283
+ origin = options.origin
284
+ member = origin =~ /@/
285
+ local = options.local
286
+ svn_branch = options.svn_branch
287
+ user_email = options.email
288
+ user_name = options.user_name
289
+
290
+ `git clone #{origin} #{local} 1>&2` unless File.directory?(File.join('.git', origin))
291
+
292
+ puts
293
+ puts "Entering #{local} directory"
294
+ puts
295
+ Dir.chdir(local) do
296
+
297
+ # Load the list of git-svn committers
298
+ svn_authors_file = File.expand_path('etc/git-svn-authors', Dir.pwd)
299
+ svn_authors = File.read(svn_authors_file)
300
+ svn_authors.gsub!(/\s+=\s+/, ': ')
301
+ svn_authors = YAML.load(svn_authors)
302
+
303
+ # set the git-svn-authors file
304
+ `git config svn.authorsfile "#{svn_authors_file}"`
305
+
306
+ # Check that git is configured for the developer
307
+ user_email ||= `git config --get user.email`.chomp
308
+ if user_email.empty?
309
+ if member
310
+ puts "Enter your email as listed on #{svn_authors_file}"
311
+ print "> "
312
+ user_email = gets.chomp
313
+ else
314
+ puts "Provide an email address for git usage:"
315
+ user_email = gets.chomp
316
+ end
317
+ end
318
+
319
+ # Check user is listed
320
+ unless user_email.empty?
321
+ svn_user, git_contact = *svn_authors.find { |entry| /#{user_email}/ === entry.join(' ') }
322
+ end
323
+
324
+ if member
325
+ if git_contact.nil? # if using the authenticated git, he must be listed
326
+ puts <<-NOTICE
327
+ You need to be a buildr commmitter listed on #{svn_authors_file}.
328
+ Perhaps you need to add yourself to it, commit it using SVN, and
329
+ and run this script again.
330
+ Also checks your git global values for user.email and user.name
331
+ NOTICE
332
+ return
333
+ elsif /\s*(.*?)\s+\<(.+)\>\s*/ === git_contact
334
+ user_name, user_email = $1, $2
335
+ else
336
+ puts "Invalid contact string for #{svn_user}: #{git_contact.inspect}"
337
+ return
338
+ end
339
+ elsif user_email =~ /^\s*$/
340
+ puts "User email shall not include spaces: #{user_email.inspect}"
341
+ return
342
+ end
343
+
344
+ user_name ||= `git config --get user.name`.chomp
345
+ if git_contact.nil? && user_name.empty?
346
+ puts "Provide a developer name for git usage:"
347
+ user_name = gets.chomp
348
+ end
349
+
350
+ # Start the pager
351
+ run_pager
352
+ puts
353
+
354
+
355
+ old_origin = `git config --get remote.origin.url`.chomp
356
+ if member && old_origin !~ /@/
357
+ puts "Switching to authenticated origin #{origin}", ""
358
+ `git config remote.origin.url "#{origin}"`
359
+ elsif !member && old_origin =~ /@/
360
+ puts "Switching to anonymous origin #{origin}", ""
361
+ `git config remote.origin.url "#{origin}"`
362
+ end
363
+
364
+ # Configure user name and email for git sake (and github's gravatar)
365
+ puts "You claim to be #{user_name.inspect} <#{user_email}> "
366
+ puts "with apache-svn user: #{svn_user}" if svn_user
367
+ puts
368
+ `git config user.name "#{user_name}"`
369
+ `git config user.email "#{user_email}"`
370
+
371
+ # Ok, now obtain the last svn commit from history
372
+ last_svn_log = `git log -n 10 | grep git-svn-id | head -n 1`
373
+ fail "No svn metadata on last 10 commits" unless last_svn_log =~ /git-svn-id/
374
+ svn_repo, svn_prev = last_svn_log.split[1].split("@")
375
+
376
+ # Tell git where the svn repository is.
377
+ `git config svn-remote.#{svn_branch}.url #{svn_repo}`
378
+ `git config svn-remote.#{svn_branch}.fetch :refs/remotes/#{svn_branch}`
379
+
380
+ # Create the svn branch, do this instead of pulling the full svn history
381
+ `git push --force . refs/remotes/origin/master:refs/remotes/#{svn_branch}`
382
+
383
+ # Create apache aliases for developers git-workflow.
384
+ `git config alias.apache-fetch "!git-svn fetch #{svn_branch}"`
385
+ `git config alias.apache-merge "!git merge #{svn_branch}"`
386
+ `git config alias.apache-pull "!git apache-fetch && git apache-merge"`
387
+ if svn_user
388
+ `git config alias.apache-push "!git-svn dcommit --username #{svn_user}"`
389
+ else
390
+ `git config alias.apache-push "!git-svn dcommit"`
391
+ end
392
+
393
+ # Create github origin aliases
394
+ `git config alias.get "!git apache-fetch && git fetch origin"`
395
+ `git config alias.mrg "!git apache-merge && git merge origin"`
396
+ `git config alias.rbs "!git rebase --onto #{svn_branch} origin/master master"`
397
+ `git config alias.put "!git apache-push && git push origin"`
398
+
399
+ # This is Victor's cronjob
400
+ `git config alias.synchronize "!git get && git rbs && git put"`
401
+
402
+ # Final notices.
403
+ puts <<-NOTICE + notice
404
+
405
+ Your git repo #{local} has been configured, please review the
406
+ #{File.join(local, '.git/config')} file.
407
+
408
+ NOTICE
409
+ end
410
+ end # perform method
411
+
412
+ main