tetra 0.48.0 → 0.49.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. data/README.md +1 -1
  2. data/SPECIAL_CASES.md +1 -1
  3. data/lib/template/{kit → bundled}/apache-ant-1.9.4/INSTALL +0 -0
  4. data/lib/template/{kit → bundled}/apache-ant-1.9.4/KEYS +0 -0
  5. data/lib/template/{kit → bundled}/apache-ant-1.9.4/LICENSE +0 -0
  6. data/lib/template/{kit → bundled}/apache-ant-1.9.4/NOTICE +0 -0
  7. data/lib/template/{kit → bundled}/apache-ant-1.9.4/README +0 -0
  8. data/lib/template/{kit → bundled}/apache-ant-1.9.4/WHATSNEW +0 -0
  9. data/lib/template/{kit → bundled}/apache-ant-1.9.4/bin/ant +0 -0
  10. data/lib/template/{kit → bundled}/apache-ant-1.9.4/bin/ant.bat +0 -0
  11. data/lib/template/{kit → bundled}/apache-ant-1.9.4/bin/ant.cmd +0 -0
  12. data/lib/template/{kit → bundled}/apache-ant-1.9.4/bin/antRun +0 -0
  13. data/lib/template/{kit → bundled}/apache-ant-1.9.4/bin/antRun.bat +0 -0
  14. data/lib/template/{kit → bundled}/apache-ant-1.9.4/bin/antRun.pl +0 -0
  15. data/lib/template/{kit → bundled}/apache-ant-1.9.4/bin/antenv.cmd +0 -0
  16. data/lib/template/{kit → bundled}/apache-ant-1.9.4/bin/complete-ant-cmd.pl +0 -0
  17. data/lib/template/{kit → bundled}/apache-ant-1.9.4/bin/envset.cmd +0 -0
  18. data/lib/template/{kit → bundled}/apache-ant-1.9.4/bin/lcp.bat +0 -0
  19. data/lib/template/{kit → bundled}/apache-ant-1.9.4/bin/runant.pl +0 -0
  20. data/lib/template/{kit → bundled}/apache-ant-1.9.4/bin/runant.py +0 -0
  21. data/lib/template/{kit → bundled}/apache-ant-1.9.4/bin/runrc.cmd +0 -0
  22. data/lib/template/{kit → bundled}/apache-ant-1.9.4/etc/ant-bootstrap.jar +0 -0
  23. data/lib/template/{kit → bundled}/apache-ant-1.9.4/etc/changelog.xsl +0 -0
  24. data/lib/template/{kit → bundled}/apache-ant-1.9.4/etc/checkstyle/checkstyle-frames.xsl +0 -0
  25. data/lib/template/{kit → bundled}/apache-ant-1.9.4/etc/checkstyle/checkstyle-text.xsl +0 -0
  26. data/lib/template/{kit → bundled}/apache-ant-1.9.4/etc/checkstyle/checkstyle-xdoc.xsl +0 -0
  27. data/lib/template/{kit → bundled}/apache-ant-1.9.4/etc/coverage-frames.xsl +0 -0
  28. data/lib/template/{kit → bundled}/apache-ant-1.9.4/etc/jdepend-frames.xsl +0 -0
  29. data/lib/template/{kit → bundled}/apache-ant-1.9.4/etc/jdepend.xsl +0 -0
  30. data/lib/template/{kit → bundled}/apache-ant-1.9.4/etc/junit-frames-xalan1.xsl +0 -0
  31. data/lib/template/{kit → bundled}/apache-ant-1.9.4/etc/junit-frames.xsl +0 -0
  32. data/lib/template/{kit → bundled}/apache-ant-1.9.4/etc/junit-noframes.xsl +0 -0
  33. data/lib/template/{kit → bundled}/apache-ant-1.9.4/etc/log.xsl +0 -0
  34. data/lib/template/{kit → bundled}/apache-ant-1.9.4/etc/maudit-frames.xsl +0 -0
  35. data/lib/template/{kit → bundled}/apache-ant-1.9.4/etc/mmetrics-frames.xsl +0 -0
  36. data/lib/template/{kit → bundled}/apache-ant-1.9.4/etc/tagdiff.xsl +0 -0
  37. data/lib/template/{kit → bundled}/apache-ant-1.9.4/fetch.xml +0 -0
  38. data/lib/template/{kit → bundled}/apache-ant-1.9.4/get-m2.xml +0 -0
  39. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/README +0 -0
  40. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-antlr.jar +0 -0
  41. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-antlr.pom +0 -0
  42. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-apache-bcel.jar +0 -0
  43. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-apache-bcel.pom +0 -0
  44. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-apache-bsf.jar +0 -0
  45. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-apache-bsf.pom +0 -0
  46. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-apache-log4j.jar +0 -0
  47. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-apache-log4j.pom +0 -0
  48. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-apache-oro.jar +0 -0
  49. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-apache-oro.pom +0 -0
  50. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-apache-regexp.jar +0 -0
  51. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-apache-regexp.pom +0 -0
  52. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-apache-resolver.jar +0 -0
  53. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-apache-resolver.pom +0 -0
  54. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-apache-xalan2.jar +0 -0
  55. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-apache-xalan2.pom +0 -0
  56. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-commons-logging.jar +0 -0
  57. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-commons-logging.pom +0 -0
  58. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-commons-net.jar +0 -0
  59. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-commons-net.pom +0 -0
  60. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-jai.jar +0 -0
  61. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-jai.pom +0 -0
  62. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-javamail.jar +0 -0
  63. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-javamail.pom +0 -0
  64. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-jdepend.jar +0 -0
  65. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-jdepend.pom +0 -0
  66. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-jmf.jar +0 -0
  67. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-jmf.pom +0 -0
  68. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-jsch.jar +0 -0
  69. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-jsch.pom +0 -0
  70. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-junit.jar +0 -0
  71. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-junit.pom +0 -0
  72. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-junit4.jar +0 -0
  73. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-junit4.pom +0 -0
  74. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-launcher.jar +0 -0
  75. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-launcher.pom +0 -0
  76. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-netrexx.jar +0 -0
  77. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-netrexx.pom +0 -0
  78. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-parent.pom +0 -0
  79. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-swing.jar +0 -0
  80. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-swing.pom +0 -0
  81. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-testutil.jar +0 -0
  82. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant-testutil.pom +0 -0
  83. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant.jar +0 -0
  84. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/ant.pom +0 -0
  85. data/lib/template/{kit → bundled}/apache-ant-1.9.4/lib/libraries.properties +0 -0
  86. data/lib/template/{kit → bundled}/apache-maven-3.2.5/LICENSE +0 -0
  87. data/lib/template/{kit → bundled}/apache-maven-3.2.5/NOTICE +0 -0
  88. data/lib/template/{kit → bundled}/apache-maven-3.2.5/README.txt +0 -0
  89. data/lib/template/{kit → bundled}/apache-maven-3.2.5/bin/m2.conf +0 -0
  90. data/lib/template/{kit → bundled}/apache-maven-3.2.5/bin/mvn +0 -0
  91. data/lib/template/{kit → bundled}/apache-maven-3.2.5/bin/mvn.bat +0 -0
  92. data/lib/template/{kit → bundled}/apache-maven-3.2.5/bin/mvnDebug +0 -0
  93. data/lib/template/{kit → bundled}/apache-maven-3.2.5/bin/mvnDebug.bat +0 -0
  94. data/lib/template/{kit → bundled}/apache-maven-3.2.5/bin/mvnyjp +0 -0
  95. data/lib/template/{kit → bundled}/apache-maven-3.2.5/boot/plexus-classworlds-2.5.2.jar +0 -0
  96. data/lib/template/{kit → bundled}/apache-maven-3.2.5/conf/logging/simplelogger.properties +0 -0
  97. data/lib/template/{kit → bundled}/apache-maven-3.2.5/conf/settings.xml +0 -0
  98. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/aether-api-1.0.0.v20140518.jar +0 -0
  99. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/aether-api.license +0 -0
  100. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/aether-connector-basic-1.0.0.v20140518.jar +0 -0
  101. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/aether-connector-basic.license +0 -0
  102. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/aether-impl-1.0.0.v20140518.jar +0 -0
  103. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/aether-impl.license +0 -0
  104. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/aether-spi-1.0.0.v20140518.jar +0 -0
  105. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/aether-spi.license +0 -0
  106. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/aether-transport-wagon-1.0.0.v20140518.jar +0 -0
  107. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/aether-transport-wagon.license +0 -0
  108. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/aether-util-1.0.0.v20140518.jar +0 -0
  109. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/aether-util.license +0 -0
  110. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/aopalliance-1.0.jar +0 -0
  111. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/cdi-api-1.0.jar +0 -0
  112. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/cdi-api.license +0 -0
  113. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/commons-cli-1.2.jar +0 -0
  114. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/commons-io-2.2.jar +0 -0
  115. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/commons-lang-2.6.jar +0 -0
  116. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/ext/README.txt +0 -0
  117. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/guava-18.0.jar +0 -0
  118. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/javax.inject-1.jar +0 -0
  119. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/jsoup-1.7.2.jar +0 -0
  120. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/jsoup.license +0 -0
  121. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/jsr250-api-1.0.jar +0 -0
  122. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/jsr250-api.license +0 -0
  123. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-aether-provider-3.2.5.jar +0 -0
  124. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-aether-provider.license +0 -0
  125. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-artifact-3.2.5.jar +0 -0
  126. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-artifact.license +0 -0
  127. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-compat-3.2.5.jar +0 -0
  128. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-compat.license +0 -0
  129. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-core-3.2.5.jar +0 -0
  130. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-core.license +0 -0
  131. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-embedder-3.2.5.jar +0 -0
  132. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-embedder.license +0 -0
  133. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-model-3.2.5.jar +0 -0
  134. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-model-builder-3.2.5.jar +0 -0
  135. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-model-builder.license +0 -0
  136. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-model.license +0 -0
  137. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-plugin-api-3.2.5.jar +0 -0
  138. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-plugin-api.license +0 -0
  139. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-repository-metadata-3.2.5.jar +0 -0
  140. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-repository-metadata.license +0 -0
  141. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-settings-3.2.5.jar +0 -0
  142. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-settings-builder-3.2.5.jar +0 -0
  143. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-settings-builder.license +0 -0
  144. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/maven-settings.license +0 -0
  145. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/org.eclipse.sisu.inject-0.3.0.M1.jar +0 -0
  146. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/org.eclipse.sisu.inject.license +0 -0
  147. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/org.eclipse.sisu.plexus-0.3.0.M1.jar +0 -0
  148. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/org.eclipse.sisu.plexus.license +0 -0
  149. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/plexus-cipher-1.7.jar +0 -0
  150. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/plexus-cipher.license +0 -0
  151. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/plexus-component-annotations-1.5.5.jar +0 -0
  152. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/plexus-interpolation-1.21.jar +0 -0
  153. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/plexus-sec-dispatcher-1.3.jar +0 -0
  154. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/plexus-sec-dispatcher.license +0 -0
  155. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/plexus-utils-3.0.20.jar +0 -0
  156. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/sisu-guice-3.2.3-no_aop.jar +0 -0
  157. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/slf4j-api-1.7.5.jar +0 -0
  158. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/slf4j-api.license +0 -0
  159. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/slf4j-simple-1.7.5.jar +0 -0
  160. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/slf4j-simple.license +0 -0
  161. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/wagon-file-2.8.jar +0 -0
  162. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/wagon-file.license +0 -0
  163. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/wagon-http-2.8-shaded.jar +0 -0
  164. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/wagon-http-shared-2.8.jar +0 -0
  165. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/wagon-http-shared.license +0 -0
  166. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/wagon-http.license +0 -0
  167. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/wagon-provider-api-2.8.jar +0 -0
  168. data/lib/template/{kit → bundled}/apache-maven-3.2.5/lib/wagon-provider-api.license +0 -0
  169. data/lib/tetra/facades/git.rb +59 -70
  170. data/lib/tetra/facades/process_runner.rb +10 -9
  171. data/lib/tetra/packages/kit_package.rb +1 -2
  172. data/lib/tetra/packages/package.rb +1 -1
  173. data/lib/tetra/packages/scriptable.rb +1 -1
  174. data/lib/tetra/packages/speccable.rb +1 -1
  175. data/lib/tetra/pom.rb +5 -1
  176. data/lib/tetra/project.rb +64 -65
  177. data/lib/tetra/version.rb +1 -1
  178. data/spec/lib/built_package_spec.rb +1 -1
  179. data/spec/lib/git_spec.rb +23 -28
  180. data/spec/lib/project_spec.rb +30 -12
  181. data/spec/lib/scriptable_spec.rb +1 -1
  182. data/spec/spec_helper.rb +1 -1
  183. metadata +168 -168
@@ -6,9 +6,9 @@ module Tetra
6
6
  include Logging
7
7
 
8
8
  # runs an external executable and returns its output as a string
9
- # raises ExecutionFailed if the exit status is not 0 (override with fail_on_error)
9
+ # raises ExecutionFailed if the exit status is not 0
10
10
  # optionally echoes the executable's output/error to standard output/error
11
- def run(commandline, echo = false, fail_on_error = true)
11
+ def run(commandline, echo = false)
12
12
  log.debug "running `#{commandline}`"
13
13
 
14
14
  out_recorder = echo ? RecordingIO.new(STDOUT) : RecordingIO.new
@@ -19,14 +19,15 @@ module Tetra
19
19
  log.debug "`#{commandline}` exited with status #{status}"
20
20
 
21
21
  if status != 0
22
- if fail_on_error
23
- log.warn("`#{commandline}` failed, status #{status}")
24
- log.warn("standard output follows")
25
- log.warn(out_recorder.record)
26
- log.warn("standard error follows")
27
- log.warn(err_recorder.record)
28
- fail ExecutionFailed.new(commandline, status)
22
+ log.warn("`#{commandline}` failed with status #{status}")
23
+ out = out_recorder.record
24
+ err = err_recorder.record
25
+ if out != "" || err != ""
26
+ log.warn("Output follows:")
27
+ log.warn(out) unless out == ""
28
+ log.warn(err) unless err == ""
29
29
  end
30
+ fail ExecutionFailed.new(commandline, status)
30
31
  end
31
32
 
32
33
  out_recorder.record
@@ -8,14 +8,13 @@ module Tetra
8
8
  include Speccable
9
9
 
10
10
  attr_reader :name
11
- attr_reader :version
11
+ def_delegator :@project, :version
12
12
  def_delegator :@project, :name, :project_name
13
13
 
14
14
  def initialize(project)
15
15
  @project = project
16
16
 
17
17
  @name = "#{project.name}-kit"
18
- @version = "#{project.version}"
19
18
  end
20
19
 
21
20
  def to_archive
@@ -21,7 +21,7 @@ module Tetra
21
21
  def initialize(project, pom_path = nil, filter = nil)
22
22
  @project = project
23
23
  @kit = Tetra::KitPackage.new(project)
24
- @pom = pom_path.nil? ? nil : Tetra::Pom.new(pom_path)
24
+ @pom = Tetra::Pom.new(pom_path)
25
25
  @filter = filter
26
26
  end
27
27
 
@@ -28,7 +28,7 @@ module Tetra
28
28
  FileUtils.mkdir_p(result_dir)
29
29
  result_path = File.join(result_dir, "build.sh")
30
30
  conflict_count = project.merge_new_content(new_content, result_path, "Build script generated",
31
- "generate_build_script")
31
+ "script")
32
32
 
33
33
  [result_path, conflict_count]
34
34
  end
@@ -18,7 +18,7 @@ module Tetra
18
18
  new_content = generate(template_spec_name, binding)
19
19
  label = "Spec for #{name} generated"
20
20
  conflict_count = project.merge_new_content(new_content, spec_path,
21
- label, "generate_#{name}_spec")
21
+ label, "#{name}-spec")
22
22
  [spec_path, conflict_count]
23
23
  end
24
24
  end
@@ -4,7 +4,11 @@ module Tetra
4
4
  # encapsulates a pom.xml file
5
5
  class Pom
6
6
  def initialize(filename)
7
- @doc = Nokogiri::XML(open(filename).read)
7
+ @doc = Nokogiri::XML(
8
+ if filename && File.file?(filename)
9
+ open(filename).read
10
+ end
11
+ )
8
12
  @doc.remove_namespaces!
9
13
  end
10
14
 
@@ -5,6 +5,9 @@ module Tetra
5
5
  class Project
6
6
  include Logging
7
7
 
8
+ # path of the project template files
9
+ TEMPLATE_PATH = File.join(File.dirname(__FILE__), "..", "template")
10
+
8
11
  attr_reader :full_path
9
12
 
10
13
  def initialize(path)
@@ -17,7 +20,7 @@ module Tetra
17
20
  end
18
21
 
19
22
  def version
20
- latest_tag_count(:dry_run_finished)
23
+ @git.latest_id("tetra: dry-run-finished")
21
24
  end
22
25
 
23
26
  def packages_dir
@@ -44,31 +47,43 @@ module Tetra
44
47
  end
45
48
 
46
49
  # inits a new project directory structure
47
- def self.init(dir)
50
+ def self.init(dir, include_bundled_software = true)
48
51
  Dir.chdir(dir) do
49
52
  Tetra::Git.new(".").init
50
53
 
51
54
  FileUtils.mkdir_p("src")
52
55
  FileUtils.mkdir_p("kit")
53
56
 
54
- # populate the project with templates and take a snapshot
57
+ # populate the project with templates and commit it
55
58
  project = Project.new(".")
56
59
 
57
- template_path = File.join(File.dirname(__FILE__), "..", "template")
60
+ project.template_files(include_bundled_software).each do |source, destination|
61
+ FileUtils.cp_r(File.join(TEMPLATE_PATH, source), destination)
62
+ end
58
63
 
59
- templates = {
60
- "kit" => ".",
61
- "packages" => ".",
62
- "src" => ".",
63
- "gitignore" => ".gitignore"
64
- }
64
+ project.commit_whole_project("Template files added")
65
+ end
66
+ end
65
67
 
66
- templates.each do |source, destination|
67
- FileUtils.cp_r(File.join(template_path, source), destination)
68
+ # returns a hash that maps filenames that should be copied from TEMPLATE_PATH
69
+ # to the value directory
70
+ def template_files(include_bundled_software)
71
+ result = {
72
+ "kit" => ".",
73
+ "packages" => ".",
74
+ "src" => ".",
75
+ "gitignore" => ".gitignore"
76
+ }
77
+
78
+ if include_bundled_software
79
+ Dir.chdir(TEMPLATE_PATH) do
80
+ Dir.glob(File.join("bundled", "*")).each do |file|
81
+ result[file] = "kit"
82
+ end
68
83
  end
69
-
70
- project.take_snapshot("Template files added", :init)
71
84
  end
85
+
86
+ result
72
87
  end
73
88
 
74
89
  # starts a dry running phase: files added to kit/ will be added
@@ -79,24 +94,25 @@ module Tetra
79
94
 
80
95
  current_directory = Pathname.new(Dir.pwd).relative_path_from(Pathname.new(@full_path))
81
96
 
82
- take_snapshot("Dry-run started", :dry_run_started, current_directory)
97
+ commit_whole_project("Dry-run started", "tetra: dry-run-started: #{current_directory}")
83
98
  true
84
99
  end
85
100
 
86
101
  # returns true iff we are currently dry-running
87
102
  def dry_running?
88
- latest_tag_count(:dry_run_started) > latest_tag_count(:dry_run_finished)
103
+ latest_comment = @git.latest_comment("tetra: dry-run-")
104
+ !latest_comment.nil? && !(latest_comment =~ /tetra: dry-run-finished/)
89
105
  end
90
106
 
91
107
  # ends a dry-run assuming a successful build
92
108
  # reverts sources and updates output file lists
93
109
  def finish
94
110
  if dry_running?
95
- take_snapshot("Changes during dry-run", :dry_run_changed)
111
+ commit_whole_project("Changes during dry-run", "tetra: dry-run-changed")
96
112
 
97
- @git.revert_whole_directory("src", latest_tag(:dry_run_started))
113
+ @git.revert_whole_directory("src", @git.latest_id("tetra: dry-run-started"))
98
114
 
99
- take_snapshot("Dry run finished", :dry_run_finished)
115
+ commit_whole_project("Dry run finished", "tetra: dry-run-finished")
100
116
  return true
101
117
  end
102
118
  false
@@ -106,17 +122,16 @@ module Tetra
106
122
  # reverts the whole project directory
107
123
  def abort
108
124
  if dry_running?
109
- @git.revert_whole_directory(".", latest_tag(:dry_run_started))
110
- @git.delete_tag(latest_tag(:dry_run_started))
125
+ @git.revert_whole_directory(".", @git.latest_id("tetra: dry-run-started"))
126
+ @git.undo_last_commit
111
127
  return true
112
128
  end
113
129
  false
114
130
  end
115
131
 
116
- # takes a revertable snapshot of this project
117
- def take_snapshot(message, tag_prefix, tag_message = nil)
118
- # rename all .gitignore files by default as
119
- # they prevent snapshotting
132
+ # commits all files in the project
133
+ def commit_whole_project(*comments)
134
+ # rename all .gitignore files that might have slipped in
120
135
  from_directory("src") do
121
136
  Find.find(".") do |file|
122
137
  next unless file =~ /\.gitignore$/
@@ -125,58 +140,46 @@ module Tetra
125
140
  end
126
141
  end
127
142
 
128
- @git.commit_whole_directory(message, next_tag(tag_prefix), tag_message)
143
+ @git.commit_whole_directory(comments.join("\n\n"))
129
144
  end
130
145
 
131
- # replaces content in path with new_content, takes a snapshot using
132
- # snapshot_message and tag_prefix and 3-way merges new and old content
133
- # with a previous snapshotted file same path tag_prefix, if it exists.
146
+ # replaces content in path with new_content, commits using
147
+ # comment and 3-way merges new and old content with the previous
148
+ # version of file of the same kind, if it exists.
134
149
  # returns the number of conflicts
135
- def merge_new_content(new_content, path, snapshot_message, tag_prefix)
150
+ def merge_new_content(new_content, path, comment, kind)
136
151
  from_directory do
137
- log.debug "merging new content to #{path} with prefix #{tag_prefix}"
152
+ log.debug "merging new content to #{path} of kind #{kind}"
138
153
  already_existing = File.exist?(path)
139
154
 
155
+ generated_comment = "tetra: generated-#{kind}"
156
+ whole_comment = [comment, generated_comment].join("\n\n")
157
+
140
158
  if already_existing
141
- if latest_tag_count(tag_prefix) == 0
142
- log.debug "saving untagged version"
143
- @git.commit_file(path, snapshot_message, next_tag(tag_prefix))
159
+ unless @git.latest_id(generated_comment)
160
+ log.debug "committing new file"
161
+ @git.commit_file(path, whole_comment)
144
162
  end
145
163
  log.debug "moving #{path} to #{path}.tetra_user_edited"
146
- File.rename path, "#{path}.tetra_user_edited"
164
+ File.rename(path, "#{path}.tetra_user_edited")
147
165
  end
148
166
 
149
- previous_tag = latest_tag(tag_prefix)
167
+ previous_id = @git.latest_id(generated_comment)
150
168
 
151
169
  File.open(path, "w") { |io| io.write(new_content) }
152
- log.debug "taking snapshot with new content: #{snapshot_message}"
153
- @git.commit_file(path, snapshot_message, next_tag(tag_prefix))
170
+ log.debug "committing new content: #{comment}"
171
+ @git.commit_file(path, whole_comment)
154
172
 
155
173
  if already_existing
156
174
  # 3-way merge
157
- conflict_count = @git.merge_with_tag("#{path}", "#{path}.tetra_user_edited", previous_tag)
158
- File.delete "#{path}.tetra_user_edited"
175
+ conflict_count = @git.merge_with_id("#{path}", "#{path}.tetra_user_edited", previous_id)
176
+ File.delete("#{path}.tetra_user_edited")
159
177
  return conflict_count
160
178
  end
161
179
  return 0
162
180
  end
163
181
  end
164
182
 
165
- # returns the tag with maximum count for a given tag prefix
166
- def latest_tag(prefix)
167
- "#{prefix}_#{latest_tag_count(prefix)}"
168
- end
169
-
170
- # returns the maximum tag count for a given tag prefix
171
- def latest_tag_count(prefix)
172
- @git.get_tag_maximum_suffix(prefix)
173
- end
174
-
175
- # returns the next tag for a given tag prefix
176
- def next_tag(prefix)
177
- "#{prefix}_#{latest_tag_count(prefix) + 1}"
178
- end
179
-
180
183
  # runs a block from the project directory or a subdirectory
181
184
  def from_directory(subdirectory = "")
182
185
  Dir.chdir(File.join(@full_path, subdirectory)) do
@@ -186,19 +189,15 @@ module Tetra
186
189
 
187
190
  # returns the latest dry run start directory
188
191
  def latest_dry_run_directory
189
- @git.get_message(latest_tag(:dry_run_started))
192
+ @git.latest_comment("tetra: dry-run-started")[/tetra: dry-run-started: (.*)$/, 1]
190
193
  end
191
194
 
192
- # returns a list of files produced during dry-runs
195
+ # returns a list of files produced during the last dry-run
193
196
  def produced_files
194
- dry_run_count = latest_tag_count(:dry_run_changed)
195
- log.debug "Getting produced files from #{dry_run_count} dry runs"
196
- if dry_run_count >= 1
197
- (1..dry_run_count).map do |i|
198
- @git.changed_files_between("dry_run_started_#{i}", "dry_run_changed_#{i}", "src")
199
- end
200
- .flatten
201
- .uniq
197
+ start_id = @git.latest_id("tetra: dry-run-started")
198
+ end_id = @git.latest_id("tetra: dry-run-changed")
199
+ if !start_id.nil? && !end_id.nil?
200
+ @git.changed_files_between(start_id, end_id, "src")
202
201
  .sort
203
202
  .map { |file| Pathname.new(file).relative_path_from(Pathname.new("src")).to_s }
204
203
  else
@@ -2,5 +2,5 @@
2
2
 
3
3
  # base module for tetra
4
4
  module Tetra
5
- VERSION = "0.48.0"
5
+ VERSION = "0.49.0"
6
6
  end
@@ -50,7 +50,7 @@ describe Tetra::Package do
50
50
  expect(spec_lines).to include("License: The Apache Software License, Version 2.0\n")
51
51
  expect(spec_lines).to include("Summary: Nailgun is a client, protocol, and server for running Java\n")
52
52
  expect(spec_lines).to include("Url: http://martiansoftware.com/nailgun\n")
53
- expect(spec_lines).to include("BuildRequires: test-project-kit == 2\n")
53
+ expect(spec_lines).to include("BuildRequires: test-project-kit == #{@project.version}\n")
54
54
  expect(spec_lines).to include("Provides: mvn(com.martiansoftware:nailgun-all) == 0.9.1\n")
55
55
  expect(spec_lines).to include("cp -a out/test3.jar %{buildroot}%{_javadir}/test3.jar\n")
56
56
  end
@@ -15,7 +15,7 @@ describe Tetra::Git do
15
15
  FileUtils.rm_rf(@git_path)
16
16
  end
17
17
 
18
- describe "#init" do
18
+ describe "#init" do
19
19
  it "complains if a double initialization is attempted" do
20
20
  expect do
21
21
  @git.init
@@ -23,41 +23,33 @@ describe Tetra::Git do
23
23
  end
24
24
  end
25
25
 
26
- describe "#commit_whole_directory" do
27
- it "commits all contents of a directory to git for later use" do
26
+ describe "#latest_id" do
27
+ it "does not find a commit with a non-existing comment" do
28
28
  Dir.chdir(@git_path) do
29
- File.open("file1", "w") do |file|
30
- file.write "test"
31
- end
32
-
33
- @git.commit_whole_directory("test", :test)
34
-
35
- files = `git ls-tree --name-only -r HEAD`.split("\n")
36
-
37
- expect(files).to include("file1")
29
+ @git.commit_file(".", "initial commit")
30
+ expect(@git.latest_id("tetra: test")).to be_nil
31
+ end
32
+ end
33
+ it "finds a commit with a certain comment" do
34
+ Dir.chdir(@git_path) do
35
+ @git.commit_file(".", "tetra: test")
36
+ expect(@git.latest_id("tetra: test")).to eq `git rev-parse HEAD`.strip
38
37
  end
39
38
  end
40
39
  end
41
40
 
42
- describe "#changed_files_since" do
43
- it "lists files changed since a tetra tag" do
41
+ describe "#commit_whole_directory" do
42
+ it "commits all contents of a directory to git for later use" do
44
43
  Dir.chdir(@git_path) do
45
44
  File.open("file1", "w") do |file|
46
45
  file.write "test"
47
46
  end
48
47
 
49
- @git.commit_whole_directory("test", :test_start)
50
-
51
- File.open("file2", "w") do |file|
52
- file.write "test"
53
- end
54
-
55
- @git.commit_whole_directory("test end", :test_end)
48
+ @git.commit_whole_directory("test")
56
49
 
57
- files = @git.changed_files_since(:test_start)
50
+ files = `git ls-tree --name-only -r HEAD`.split("\n")
58
51
 
59
- expect(files).not_to include("file1")
60
- expect(files).to include("file2")
52
+ expect(files).to include("file1")
61
53
  end
62
54
  end
63
55
  end
@@ -69,7 +61,7 @@ describe Tetra::Git do
69
61
  file.write "test"
70
62
  end
71
63
 
72
- @git.commit_whole_directory("test", :test_start)
64
+ @git.commit_whole_directory("test\ntetra: test_start")
73
65
 
74
66
  File.open("file2", "w") do |file|
75
67
  file.write "test"
@@ -79,15 +71,18 @@ describe Tetra::Git do
79
71
  file.write "test"
80
72
  end
81
73
 
82
- @git.commit_whole_directory("test", :test_end)
74
+ @git.commit_whole_directory("test\ntetra: test_end")
83
75
 
84
76
  File.open("file4", "w") do |file|
85
77
  file.write "test"
86
78
  end
87
79
 
88
- @git.commit_whole_directory("test", :test_after)
80
+ @git.commit_whole_directory("test\ntetra: test_after")
81
+
82
+ start_id = @git.latest_id("tetra: test_start")
83
+ end_id = @git.latest_id("tetra: test_end")
89
84
 
90
- files = @git.changed_files_between(:test_start, :test_end, "subdir")
85
+ files = @git.changed_files_between(start_id, end_id, "subdir")
91
86
 
92
87
  expect(files).not_to include("file1")
93
88
  expect(files).not_to include("file2")
@@ -3,16 +3,26 @@
3
3
  require "spec_helper"
4
4
 
5
5
  describe Tetra::Project do
6
- before(:each) do
7
- @project_path = File.join("spec", "data", "test-project")
8
- Dir.mkdir(@project_path)
6
+ include Tetra::Mockers
9
7
 
10
- Tetra::Project.init(@project_path)
11
- @project = Tetra::Project.new(@project_path)
8
+ before(:each) do
9
+ create_mock_project
12
10
  end
13
11
 
14
12
  after(:each) do
15
- FileUtils.rm_rf(@project_path)
13
+ delete_mock_project
14
+ end
15
+
16
+ describe "version" do
17
+ it "returns no project version in case no dry-run happened" do
18
+ expect(@project.version).to be_nil
19
+ end
20
+
21
+ it "returns a project version after dry-run" do
22
+ @project.dry_run
23
+ @project.finish
24
+ expect(@project.version).to be
25
+ end
16
26
  end
17
27
 
18
28
  describe "#project?" do
@@ -41,6 +51,16 @@ describe Tetra::Project do
41
51
  end
42
52
  end
43
53
 
54
+ describe "#template_files" do
55
+ it "returns the list of template files without bundles" do
56
+ expect(@project.template_files(false)).to include("kit" => ".")
57
+ end
58
+
59
+ it "returns the list of template files with bundles" do
60
+ expect(@project.template_files(true)).to include("bundled/apache-ant-1.9.4" => "kit")
61
+ end
62
+ end
63
+
44
64
  describe "#init" do
45
65
  it "inits a new project" do
46
66
  kit_path = File.join(@project_path, "kit")
@@ -63,7 +83,7 @@ describe Tetra::Project do
63
83
  end
64
84
  end
65
85
 
66
- describe "#take_snapshot" do
86
+ describe "#commit_whole_project" do
67
87
  it "commits the project contents to git for later use" do
68
88
  @project.from_directory do
69
89
  FileUtils.touch(File.join("kit", "test"))
@@ -73,13 +93,12 @@ describe Tetra::Project do
73
93
  file.write "file"
74
94
  end
75
95
 
76
- @project.take_snapshot("test", :revertable)
96
+ @project.commit_whole_project("test")
77
97
 
78
98
  files = `git ls-tree --name-only -r HEAD`.split("\n")
79
99
  expect(files).to include("src/.gitignore_disabled_by_tetra")
80
100
 
81
101
  expect(`git rev-list --all`.split("\n").length).to eq 2
82
- expect(@project.latest_tag(:revertable)).to eq "revertable_1"
83
102
  end
84
103
  end
85
104
  end
@@ -133,7 +152,7 @@ describe Tetra::Project do
133
152
  expect(@project.dry_running?).to be_falsey
134
153
 
135
154
  @project.from_directory do
136
- expect(`git rev-list --all`.split("\n").length).to eq 2
155
+ expect(`git rev-list --all`.split("\n").length).to eq 1
137
156
  expect(File.read("src/test")).to eq "A"
138
157
  expect(File.exist?("src/test2")).to be_falsey
139
158
 
@@ -159,7 +178,6 @@ describe Tetra::Project do
159
178
  expect(@project.dry_running?).to be_truthy
160
179
  expect(`git rev-list --all`.split("\n").length).to eq 2
161
180
  expect(`git diff-tree --no-commit-id --name-only -r HEAD`.split("\n")).to include("src/test")
162
- expect(`git cat-file tag tetra_dry_run_started_1 | tail -1`).to include("src")
163
181
  end
164
182
  end
165
183
  end
@@ -184,9 +202,9 @@ describe Tetra::Project do
184
202
  expect(@project.finish).to be_truthy
185
203
 
186
204
  list = @project.produced_files
187
- expect(list).to include("added_in_first_dry_run")
188
205
  expect(list).to include("added_in_second_dry_run")
189
206
 
207
+ expect(list).not_to include("added_in_first_dry_run")
190
208
  expect(list).not_to include("added_outside_dry_run")
191
209
  expect(list).not_to include("added_outside_directory")
192
210
  end