tetra 0.49.0 → 0.50.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/.rubocop.yml +2 -2
  2. data/SPECIAL_CASES.md +20 -8
  3. data/integration-tests/build-commons.sh +5 -10
  4. data/lib/template/kit.spec +1 -1
  5. data/lib/template/package.spec +7 -1
  6. data/lib/tetra.rb +1 -2
  7. data/lib/tetra/facades/git.rb +39 -18
  8. data/lib/tetra/facades/process_runner.rb +13 -4
  9. data/lib/tetra/main.rb +6 -0
  10. data/lib/tetra/packages/kit_package.rb +0 -6
  11. data/lib/tetra/packages/package.rb +4 -6
  12. data/lib/tetra/pom.rb +2 -5
  13. data/lib/tetra/project.rb +85 -30
  14. data/lib/tetra/ui/ant_subcommand.rb +1 -1
  15. data/lib/tetra/ui/dry_run_subcommand.rb +36 -22
  16. data/lib/tetra/ui/generate_all_subcommand.rb +1 -1
  17. data/lib/tetra/ui/generate_archive_subcommand.rb +2 -2
  18. data/lib/tetra/ui/generate_kit_subcommand.rb +2 -2
  19. data/lib/tetra/ui/generate_script_subcommand.rb +1 -1
  20. data/lib/tetra/ui/generate_spec_subcommand.rb +10 -3
  21. data/lib/tetra/ui/get_pom_subcommand.rb +18 -16
  22. data/lib/tetra/ui/move_jars_to_kit_subcommand.rb +1 -1
  23. data/lib/tetra/ui/mvn_subcommand.rb +1 -1
  24. data/lib/tetra/ui/patch_subcommand.rb +18 -0
  25. data/lib/tetra/ui/subcommand.rb +14 -5
  26. data/lib/tetra/version.rb +1 -1
  27. data/spec/lib/git_spec.rb +69 -30
  28. data/spec/lib/kit_package_spec.rb +0 -16
  29. data/spec/lib/{built_package_spec.rb → package_spec.rb} +2 -15
  30. data/spec/lib/project_spec.rb +56 -13
  31. data/spec/lib/{speccable.rb → speccable_spec.rb} +5 -5
  32. metadata +5 -9
  33. data/integration-tests/apache-maven-3.1.1-bin.zip +0 -0
  34. data/integration-tests/build-obs.sh +0 -19
  35. data/lib/tetra/facades/tar.rb +0 -20
  36. data/lib/tetra/packages/archivable.rb +0 -18
  37. data/spec/lib/archivable_spec.rb +0 -36
@@ -83,7 +83,20 @@ describe Tetra::Project do
83
83
  end
84
84
  end
85
85
 
86
- describe "#commit_whole_project" do
86
+ describe "#src_patched?" do
87
+ it "checks whether src is dirty" do
88
+ @project.from_directory do
89
+ @project.dry_run
90
+ @project.finish
91
+ expect(@project.src_patched?).to be_falsey
92
+
93
+ FileUtils.touch(File.join("src", "test"))
94
+ expect(@project.src_patched?).to be_truthy
95
+ end
96
+ end
97
+ end
98
+
99
+ describe "#commit_whole_directory" do
87
100
  it "commits the project contents to git for later use" do
88
101
  @project.from_directory do
89
102
  FileUtils.touch(File.join("kit", "test"))
@@ -93,7 +106,7 @@ describe Tetra::Project do
93
106
  file.write "file"
94
107
  end
95
108
 
96
- @project.commit_whole_project("test")
109
+ @project.commit_whole_directory(".", "test")
97
110
 
98
111
  files = `git ls-tree --name-only -r HEAD`.split("\n")
99
112
  expect(files).to include("src/.gitignore_disabled_by_tetra")
@@ -109,9 +122,6 @@ describe Tetra::Project do
109
122
  File.open(File.join("src", "test"), "w") { |f| f.write("A") }
110
123
  end
111
124
 
112
- expect(@project.abort).to be_falsey
113
- expect(@project.finish).to be_falsey
114
-
115
125
  expect(@project.dry_run).to be_truthy
116
126
 
117
127
  @project.from_directory do
@@ -123,11 +133,13 @@ describe Tetra::Project do
123
133
  expect(@project.dry_running?).to be_falsey
124
134
 
125
135
  @project.from_directory do
126
- expect(`git rev-list --all`.split("\n").length).to eq 4
136
+ expect(`git rev-list --all`.split("\n").length).to eq 3
127
137
  expect(File.read("src/test")).to eq "A"
128
138
 
129
- expect(`git diff-tree --no-commit-id --name-only -r HEAD~`.split("\n")).to include("src/test2")
139
+ expect(`git diff-tree --no-commit-id --name-only -r HEAD~`.split("\n")).to include("src/test")
130
140
  expect(File.exist?("src/test2")).to be_falsey
141
+
142
+ expect(`git show HEAD`.split("\n").map(&:strip)).to include("tetra: file-changed: src/test")
131
143
  end
132
144
  end
133
145
  it "ends the current dry-run phase after a failed build" do
@@ -136,9 +148,6 @@ describe Tetra::Project do
136
148
  File.open(File.join("kit", "test"), "w") { |f| f.write("A") }
137
149
  end
138
150
 
139
- expect(@project.abort).to be_falsey
140
- expect(@project.finish).to be_falsey
141
-
142
151
  expect(@project.dry_run).to be_truthy
143
152
 
144
153
  @project.from_directory do
@@ -164,8 +173,6 @@ describe Tetra::Project do
164
173
 
165
174
  describe "#dry_run" do
166
175
  it "starts a dry running phase" do
167
- expect(@project.finish).to be_falsey
168
-
169
176
  @project.from_directory do
170
177
  FileUtils.touch(File.join("src", "test"))
171
178
  end
@@ -210,12 +217,48 @@ describe Tetra::Project do
210
217
  end
211
218
  end
212
219
 
220
+ describe "#archive_source" do
221
+ it "archives the latest source version" do
222
+ @project.from_directory do
223
+ FileUtils.touch(File.join("src", "Included.java"))
224
+ @project.commit_sources("first version", true)
225
+
226
+ FileUtils.touch(File.join("src", "Excluded.java"))
227
+ @project.commit_sources("patched version")
228
+
229
+ @project.archive_sources
230
+
231
+ file_list = `tar --list -f packages/test-project/test-project.tar.xz`.split
232
+ expect(file_list).to include("src/Included.java")
233
+ expect(file_list).not_to include("src/Excluded.java")
234
+ end
235
+ end
236
+ end
237
+
238
+ describe "#write_source_patches" do
239
+ it "writes patches from the tarball generated by archive_source" do
240
+ @project.from_directory do
241
+ test_file = File.join("src", "Test.java")
242
+ FileUtils.touch(test_file)
243
+ @project.commit_sources("first version", true)
244
+
245
+ File.open(test_file, "w") { |f| f.write("A") }
246
+ @project.commit_sources("patched version")
247
+
248
+ patches = @project.write_source_patches.map { |f| File.basename(f) }
249
+ expect(patches).to include("0001-patched-version.patch")
250
+
251
+ patch_contents = File.readlines(File.join("packages", "test-project", "0001-patched-version.patch"))
252
+ expect(patch_contents).to include("--- a/#{test_file}\n")
253
+ end
254
+ end
255
+ end
256
+
213
257
  describe "#purge_jars" do
214
258
  it "moves jars in kit/jars" do
215
259
  @project.from_directory do
216
260
  File.open(File.join("src", "test.jar"), "w") { |f| f.write("jarring") }
217
261
  end
218
- expect(@project.finish).to be_falsey
219
262
 
220
263
  @project.purge_jars
221
264
 
@@ -34,7 +34,7 @@ describe Tetra::Speccable do
34
34
 
35
35
  describe "#to_spec" do
36
36
  it "generates a first version" do
37
- expect(instance._to_spec(@project, "test-package", "kit", "test.spec")).to be_truthy
37
+ expect(instance._to_spec(@project, "test-package", "test.spec", "output")).to be_truthy
38
38
 
39
39
  @project.from_directory do
40
40
  spec_lines = File.readlines(@destination_path)
@@ -43,7 +43,7 @@ describe Tetra::Speccable do
43
43
  end
44
44
 
45
45
  it "generates a second version" do
46
- expect(instance._to_spec(@project, "test-package", "kit", "test.spec")).to be_truthy
46
+ expect(instance._to_spec(@project, "test-package", "test.spec", "output")).to be_truthy
47
47
 
48
48
  @project.from_directory do
49
49
  File.open(@destination_path, "a") do |io|
@@ -53,7 +53,7 @@ describe Tetra::Speccable do
53
53
 
54
54
  instance.world_property = "Mario!"
55
55
 
56
- expect(instance._to_spec(@project, "test-package", "kit", "test.spec")).to be_truthy
56
+ expect(instance._to_spec(@project, "test-package", "test.spec", "output")).to be_truthy
57
57
 
58
58
  @project.from_directory do
59
59
  spec_lines = File.readlines(@destination_path)
@@ -64,7 +64,7 @@ describe Tetra::Speccable do
64
64
  end
65
65
 
66
66
  it "generates a conflicting version" do
67
- expect(instance._to_spec(@project, "test-package", "kit", "test.spec")).to be_truthy
67
+ expect(instance._to_spec(@project, "test-package", "test.spec", "output")).to be_truthy
68
68
 
69
69
  @project.from_directory do
70
70
  spec_contents = File.read(@destination_path)
@@ -77,7 +77,7 @@ describe Tetra::Speccable do
77
77
 
78
78
  instance.world_property = "Mario!"
79
79
 
80
- expect(instance._to_spec(@project, "test-package", "kit", "test.spec")).to be_truthy
80
+ expect(instance._to_spec(@project, "test-package", "test.spec", "output")).to be_truthy
81
81
 
82
82
  @project.from_directory do
83
83
  spec_lines = File.readlines(@destination_path)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tetra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.49.0
4
+ version: 0.50.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-04 00:00:00.000000000 Z
12
+ date: 2015-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -174,9 +174,7 @@ files:
174
174
  - Rakefile
175
175
  - SPECIAL_CASES.md
176
176
  - bin/tetra
177
- - integration-tests/apache-maven-3.1.1-bin.zip
178
177
  - integration-tests/build-commons.sh
179
- - integration-tests/build-obs.sh
180
178
  - integration-tests/commons-collections-3.2.1-src.zip
181
179
  - lib/template/bundled/apache-ant-1.9.4/INSTALL
182
180
  - lib/template/bundled/apache-ant-1.9.4/KEYS
@@ -357,12 +355,10 @@ files:
357
355
  - lib/tetra/facades/git.rb
358
356
  - lib/tetra/facades/mvn.rb
359
357
  - lib/tetra/facades/process_runner.rb
360
- - lib/tetra/facades/tar.rb
361
358
  - lib/tetra/kit.rb
362
359
  - lib/tetra/logger.rb
363
360
  - lib/tetra/main.rb
364
361
  - lib/tetra/maven_website.rb
365
- - lib/tetra/packages/archivable.rb
366
362
  - lib/tetra/packages/kit_package.rb
367
363
  - lib/tetra/packages/package.rb
368
364
  - lib/tetra/packages/scriptable.rb
@@ -381,6 +377,7 @@ files:
381
377
  - lib/tetra/ui/init_subcommand.rb
382
378
  - lib/tetra/ui/move_jars_to_kit_subcommand.rb
383
379
  - lib/tetra/ui/mvn_subcommand.rb
380
+ - lib/tetra/ui/patch_subcommand.rb
384
381
  - lib/tetra/ui/subcommand.rb
385
382
  - lib/tetra/version.rb
386
383
  - lib/tetra/version_matcher.rb
@@ -401,18 +398,17 @@ files:
401
398
  - spec/data/struts-apps/pom.xml
402
399
  - spec/data/tomcat/pom.xml
403
400
  - spec/lib/ant_spec.rb
404
- - spec/lib/archivable_spec.rb
405
- - spec/lib/built_package_spec.rb
406
401
  - spec/lib/git_spec.rb
407
402
  - spec/lib/kit_package_spec.rb
408
403
  - spec/lib/kit_spec.rb
409
404
  - spec/lib/maven_website_spec.rb
410
405
  - spec/lib/mvn_spec.rb
406
+ - spec/lib/package_spec.rb
411
407
  - spec/lib/pom_getter_spec.rb
412
408
  - spec/lib/pom_spec.rb
413
409
  - spec/lib/project_spec.rb
414
410
  - spec/lib/scriptable_spec.rb
415
- - spec/lib/speccable.rb
411
+ - spec/lib/speccable_spec.rb
416
412
  - spec/lib/version_matcher_spec.rb
417
413
  - spec/spec_helper.rb
418
414
  - tetra.gemspec
@@ -1,19 +0,0 @@
1
- #!/bin/bash
2
-
3
- # A crude integration test that tries OBS building
4
- # assumes an OpenSUSE host is set up with passwordless SSH access
5
- # assumes this host has osc installed and properly configured in sudoers
6
- # assumes that a project directory exists
7
-
8
- set -e
9
-
10
- OBS_HOST=obs-client
11
- OBS_PROJECT_DIR=/home/silvio/obs/home\:SilvioMoioli\:tetra-test
12
-
13
- scp -r commons-collections/packages/* $OBS_HOST:/$OBS_PROJECT_DIR
14
- ssh -t $OBS_HOST <<EOF
15
- cd $OBS_PROJECT_DIR/commons-collections-kit &&\
16
- osc build -k../../rpms -p../../rpms &&\
17
- cd $OBS_PROJECT_DIR/commons-collections &&\
18
- osc build -k../../rpms -p../../rpms
19
- EOF
@@ -1,20 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module Tetra
4
- # facade to tar
5
- class Tar
6
- include Logging
7
- include ProcessRunner
8
-
9
- def archive(name, source_dir, destination_dir)
10
- log.debug("creating #{destination_dir}")
11
- FileUtils.mkdir_p(destination_dir)
12
-
13
- destination_path = File.join(destination_dir, "#{name}.tar.xz")
14
-
15
- run("tar -cJf #{destination_path} -C #{source_dir} .")
16
-
17
- destination_path
18
- end
19
- end
20
- end
@@ -1,18 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module Tetra
4
- # adds methods to generate a tarball from a package object
5
- module Archivable
6
- include Logging
7
-
8
- # generates an archive and returns its name
9
- # this will archive files in source_dir in
10
- # destination_dir/name/name.tar.xz
11
- def _to_archive(project, name, source_dir, destination_dir)
12
- project.from_directory do
13
- full_destination_dir = File.join(destination_dir, name)
14
- Tetra::Tar.new.archive(name, source_dir, full_destination_dir)
15
- end
16
- end
17
- end
18
- end
@@ -1,36 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require "spec_helper"
4
-
5
- describe Tetra::Archivable do
6
- include Tetra::Mockers
7
-
8
- # mock
9
- class TestArchivableClass
10
- include Tetra::Archivable
11
- end
12
-
13
- before(:each) do
14
- create_mock_project
15
- end
16
-
17
- let(:instance) { TestArchivableClass.new }
18
-
19
- after(:each) do
20
- delete_mock_project
21
- end
22
-
23
- describe "#to_archive" do
24
- it "generates an archive" do
25
- @project.from_directory("kit") do
26
- FileUtils.touch("kit_test")
27
- end
28
-
29
- instance._to_archive(@project, "test-package", "kit", @project.packages_dir)
30
-
31
- @project.from_directory do
32
- expect(`tar -Jtf packages/test-package/test-package.tar.xz`.split).to include("./kit_test")
33
- end
34
- end
35
- end
36
- end