tetra 0.49.0 → 0.50.0
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.
- data/.rubocop.yml +2 -2
- data/SPECIAL_CASES.md +20 -8
- data/integration-tests/build-commons.sh +5 -10
- data/lib/template/kit.spec +1 -1
- data/lib/template/package.spec +7 -1
- data/lib/tetra.rb +1 -2
- data/lib/tetra/facades/git.rb +39 -18
- data/lib/tetra/facades/process_runner.rb +13 -4
- data/lib/tetra/main.rb +6 -0
- data/lib/tetra/packages/kit_package.rb +0 -6
- data/lib/tetra/packages/package.rb +4 -6
- data/lib/tetra/pom.rb +2 -5
- data/lib/tetra/project.rb +85 -30
- data/lib/tetra/ui/ant_subcommand.rb +1 -1
- data/lib/tetra/ui/dry_run_subcommand.rb +36 -22
- data/lib/tetra/ui/generate_all_subcommand.rb +1 -1
- data/lib/tetra/ui/generate_archive_subcommand.rb +2 -2
- data/lib/tetra/ui/generate_kit_subcommand.rb +2 -2
- data/lib/tetra/ui/generate_script_subcommand.rb +1 -1
- data/lib/tetra/ui/generate_spec_subcommand.rb +10 -3
- data/lib/tetra/ui/get_pom_subcommand.rb +18 -16
- data/lib/tetra/ui/move_jars_to_kit_subcommand.rb +1 -1
- data/lib/tetra/ui/mvn_subcommand.rb +1 -1
- data/lib/tetra/ui/patch_subcommand.rb +18 -0
- data/lib/tetra/ui/subcommand.rb +14 -5
- data/lib/tetra/version.rb +1 -1
- data/spec/lib/git_spec.rb +69 -30
- data/spec/lib/kit_package_spec.rb +0 -16
- data/spec/lib/{built_package_spec.rb → package_spec.rb} +2 -15
- data/spec/lib/project_spec.rb +56 -13
- data/spec/lib/{speccable.rb → speccable_spec.rb} +5 -5
- metadata +5 -9
- data/integration-tests/apache-maven-3.1.1-bin.zip +0 -0
- data/integration-tests/build-obs.sh +0 -19
- data/lib/tetra/facades/tar.rb +0 -20
- data/lib/tetra/packages/archivable.rb +0 -18
- data/spec/lib/archivable_spec.rb +0 -36
@@ -13,7 +13,7 @@ module Tetra
|
|
13
13
|
def execute
|
14
14
|
checking_exceptions do
|
15
15
|
project = Tetra::Project.new(".")
|
16
|
-
ensure_dry_running(
|
16
|
+
ensure_dry_running(:is_in_progress, project) do
|
17
17
|
path = Tetra::Kit.new(project).find_executable("ant")
|
18
18
|
Tetra::Ant.new(project.full_path, path).ant(@options)
|
19
19
|
end
|
@@ -14,30 +14,44 @@ module Tetra
|
|
14
14
|
def execute
|
15
15
|
checking_exceptions do
|
16
16
|
project = Tetra::Project.new(".")
|
17
|
+
send(command, project)
|
18
|
+
end
|
19
|
+
end
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
puts "Dry-run finished."
|
31
|
-
else
|
32
|
-
puts "No dry-run is in progress."
|
33
|
-
end
|
34
|
-
elsif command == "abort"
|
35
|
-
if project.abort
|
36
|
-
puts "Project reverted as before dry-run."
|
37
|
-
else
|
38
|
-
puts "No dry-run is in progress."
|
39
|
-
end
|
21
|
+
def start(project)
|
22
|
+
if !project.dry_running?
|
23
|
+
if project.src_patched?
|
24
|
+
puts "Some files in src/ were changed since last dry-run."
|
25
|
+
puts "Use \"tetra patch message\" to include changes in a patch before dry-running."
|
26
|
+
puts "Dry run not started."
|
27
|
+
else
|
28
|
+
project.dry_run
|
29
|
+
puts "Now dry-running, please start your build."
|
30
|
+
puts "To run a Maven installation from the kit, use \"tetra mvn\"."
|
31
|
+
puts "If the build succeedes end this dry run with \"tetra dry-run finish\"."
|
32
|
+
puts "If the build does not succeed use \"tetra dry-run abort\" to undo any change."
|
40
33
|
end
|
34
|
+
else
|
35
|
+
puts "Dry-run already in progress."
|
36
|
+
puts "Use \"tetra dry-run finish\" to end it or \"tetra dry-run abort\" to undo changes."
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def finish(project)
|
41
|
+
if project.dry_running?
|
42
|
+
project.finish
|
43
|
+
puts "Dry-run finished."
|
44
|
+
else
|
45
|
+
puts "No dry-run is in progress."
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def abort(project)
|
50
|
+
if project.dry_running?
|
51
|
+
project.abort
|
52
|
+
puts "Project reverted as before dry-run."
|
53
|
+
else
|
54
|
+
puts "No dry-run is in progress."
|
41
55
|
end
|
42
56
|
end
|
43
57
|
end
|
@@ -9,7 +9,7 @@ module Tetra
|
|
9
9
|
def execute
|
10
10
|
checking_exceptions do
|
11
11
|
project = Tetra::Project.new(".")
|
12
|
-
ensure_dry_running(
|
12
|
+
ensure_dry_running(:has_finished, project) do
|
13
13
|
GenerateKitSubcommand.new(@invocation_path).execute
|
14
14
|
|
15
15
|
GenerateScriptSubcommand.new(@invocation_path).execute
|
@@ -6,8 +6,8 @@ module Tetra
|
|
6
6
|
def execute
|
7
7
|
checking_exceptions do
|
8
8
|
project = Tetra::Project.new(".")
|
9
|
-
ensure_dry_running(
|
10
|
-
result_path =
|
9
|
+
ensure_dry_running(:has_finished, project) do
|
10
|
+
result_path = project.archive_sources
|
11
11
|
print_generation_result(project, result_path)
|
12
12
|
end
|
13
13
|
end
|
@@ -6,12 +6,12 @@ module Tetra
|
|
6
6
|
def execute
|
7
7
|
checking_exceptions do
|
8
8
|
project = Tetra::Project.new(".")
|
9
|
-
ensure_dry_running(
|
9
|
+
ensure_dry_running(:has_finished, project) do
|
10
10
|
kit = Tetra::KitPackage.new(project)
|
11
11
|
result_path, conflict_count = kit.to_spec
|
12
12
|
print_generation_result(project, result_path, conflict_count)
|
13
13
|
|
14
|
-
result_path =
|
14
|
+
result_path = project.archive_kit
|
15
15
|
print_generation_result(project, result_path)
|
16
16
|
end
|
17
17
|
end
|
@@ -6,7 +6,7 @@ module Tetra
|
|
6
6
|
def execute
|
7
7
|
checking_exceptions do
|
8
8
|
project = Tetra::Project.new(".")
|
9
|
-
ensure_dry_running(
|
9
|
+
ensure_dry_running(:has_finished, project) do
|
10
10
|
history = File.join(Dir.home, ".bash_history")
|
11
11
|
result_path, conflict_count =
|
12
12
|
Tetra::Package.new(project).to_script(history)
|
@@ -9,10 +9,17 @@ module Tetra
|
|
9
9
|
def execute
|
10
10
|
checking_exceptions do
|
11
11
|
project = Tetra::Project.new(".")
|
12
|
-
ensure_dry_running(
|
13
|
-
|
14
|
-
|
12
|
+
ensure_dry_running(:has_finished, project) do
|
13
|
+
patches = project.write_source_patches
|
14
|
+
package = Tetra::Package.new(project, pom, filter, patches)
|
15
|
+
|
16
|
+
patches.each do |patch|
|
17
|
+
print_generation_result(project, patch)
|
18
|
+
end
|
19
|
+
|
20
|
+
result_path, conflict_count = package.to_spec
|
15
21
|
print_generation_result(project, result_path, conflict_count)
|
22
|
+
puts "Warning: #{pom} not found, some spec fields will be left blank" unless File.file?(pom)
|
16
23
|
end
|
17
24
|
end
|
18
25
|
end
|
@@ -8,24 +8,26 @@ module Tetra
|
|
8
8
|
def execute
|
9
9
|
checking_exceptions do
|
10
10
|
project = Tetra::Project.new(".")
|
11
|
-
|
11
|
+
ensure_dry_running(:is_not_in_progress, project) do
|
12
|
+
pom_getter = Tetra::PomGetter.new
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
14
|
+
path, status = pom_getter.get_pom(name)
|
15
|
+
if path
|
16
|
+
text_status = (
|
17
|
+
if status == :found_in_jar
|
18
|
+
"was inside the jar"
|
19
|
+
elsif status == :found_via_sha1
|
20
|
+
"found by sha1 search from search.maven.org"
|
21
|
+
elsif status == :found_via_heuristic
|
22
|
+
"found by heuristic search from search.maven.org"
|
23
|
+
end
|
24
|
+
)
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
puts "#{format_path(path, project)} written, #{text_status}"
|
27
|
+
else
|
28
|
+
puts "#{name}'s pom not found. Try:"
|
29
|
+
puts "http://google.com/#q=#{URI.encode(pom_getter.cleanup_name(name) + ' pom')}"
|
30
|
+
end
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
@@ -7,7 +7,7 @@ module Tetra
|
|
7
7
|
checking_exceptions do
|
8
8
|
project = Tetra::Project.new(".")
|
9
9
|
|
10
|
-
ensure_dry_running(
|
10
|
+
ensure_dry_running(:is_not_in_progress, project) do
|
11
11
|
project.purge_jars.each do |original, final|
|
12
12
|
puts "Replaced #{original} with symlink pointing to to #{final}"
|
13
13
|
end
|
@@ -13,7 +13,7 @@ module Tetra
|
|
13
13
|
def execute
|
14
14
|
checking_exceptions do
|
15
15
|
project = Tetra::Project.new(".")
|
16
|
-
ensure_dry_running(
|
16
|
+
ensure_dry_running(:is_in_progress, project) do
|
17
17
|
path = Tetra::Kit.new(project).find_executable("mvn")
|
18
18
|
Tetra::Mvn.new(project.full_path, path).mvn(@options)
|
19
19
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Tetra
|
4
|
+
# tetra patch
|
5
|
+
class PatchSubcommand < Tetra::Subcommand
|
6
|
+
option %w(-n --new-tarball), :flag, "suppress patch creation, roll all changes so far in the tarball"
|
7
|
+
parameter "[MESSAGE]", "a short patch description", default: "Sources updated"
|
8
|
+
|
9
|
+
def execute
|
10
|
+
checking_exceptions do
|
11
|
+
project = Tetra::Project.new(".")
|
12
|
+
ensure_dry_running(:is_not_in_progress, project) do
|
13
|
+
project.commit_sources(message, new_tarball?)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/tetra/ui/subcommand.rb
CHANGED
@@ -45,14 +45,23 @@ module Tetra
|
|
45
45
|
@options = args
|
46
46
|
end
|
47
47
|
|
48
|
-
# prints an error message and exits unless
|
48
|
+
# prints an error message and exits unless a dry-running
|
49
|
+
# condition is met. Conditions can be: :is_in_progress, :is_not_in_progress
|
50
|
+
# or :has_finished
|
49
51
|
def ensure_dry_running(state, project)
|
50
|
-
|
52
|
+
dry_running = project.dry_running?
|
53
|
+
has_finished = !project.version.nil?
|
54
|
+
|
55
|
+
if (state == :is_in_progress && dry_running) ||
|
56
|
+
(state == :is_not_in_progress && !dry_running) ||
|
57
|
+
(state == :has_finished && !dry_running && has_finished)
|
51
58
|
yield
|
52
59
|
else
|
53
|
-
if state ==
|
60
|
+
if (state == :is_in_progress) ||
|
61
|
+
(state == :has_finished && !dry_running && !has_finished)
|
54
62
|
puts "Please start a dry-run first, use \"tetra dry-run start\""
|
55
|
-
|
63
|
+
elsif (state == :is_not_in_progress) ||
|
64
|
+
(state == :has_finished && dry_running)
|
56
65
|
puts "Please finish or abort this dry-run first, use \"tetra dry-run finish\" or \"tetra dry-run abort\""
|
57
66
|
end
|
58
67
|
end
|
@@ -61,7 +70,7 @@ module Tetra
|
|
61
70
|
# outputs output of a file generation
|
62
71
|
def print_generation_result(project, result_path, conflict_count = 0)
|
63
72
|
puts "#{format_path(result_path, project)} generated"
|
64
|
-
puts "Warning: #{conflict_count} unresolved conflicts" if conflict_count > 0
|
73
|
+
puts "Warning: #{conflict_count} unresolved conflicts, please review and commit" if conflict_count > 0
|
65
74
|
end
|
66
75
|
|
67
76
|
# generates a version of path relative to the current directory
|
data/lib/tetra/version.rb
CHANGED
data/spec/lib/git_spec.rb
CHANGED
@@ -41,53 +41,92 @@ describe Tetra::Git do
|
|
41
41
|
describe "#commit_whole_directory" do
|
42
42
|
it "commits all contents of a directory to git for later use" do
|
43
43
|
Dir.chdir(@git_path) do
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
FileUtils.touch("file1")
|
45
|
+
Dir.mkdir("subdir")
|
46
|
+
FileUtils.touch(File.join("subdir", "file2"))
|
47
47
|
|
48
|
-
@git.commit_whole_directory("test")
|
48
|
+
@git.commit_whole_directory("subdir", "test")
|
49
49
|
|
50
50
|
files = `git ls-tree --name-only -r HEAD`.split("\n")
|
51
51
|
|
52
|
-
expect(files).
|
52
|
+
expect(files).not_to include("file1")
|
53
|
+
expect(files).to include("subdir/file2")
|
53
54
|
end
|
54
55
|
end
|
55
56
|
end
|
56
57
|
|
57
|
-
describe "#
|
58
|
-
it "
|
58
|
+
describe "#changed_files" do
|
59
|
+
it "checks if a directory is clean from changes" do
|
59
60
|
Dir.chdir(@git_path) do
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
@git.commit_file(".", "initial commit")
|
62
|
+
Dir.mkdir("directory")
|
63
|
+
FileUtils.touch(File.join("directory", "file"))
|
64
|
+
expect(@git.changed_files("directory", "HEAD")).to include("directory/file")
|
63
65
|
|
64
|
-
|
66
|
+
`git add directory/file`
|
67
|
+
expect(@git.changed_files("directory", "HEAD")).to include("directory/file")
|
65
68
|
|
66
|
-
File.
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
@git.commit_file(File.join("directory", "file"), "test")
|
70
|
+
expect(@git.changed_files("directory", "HEAD")).to be_empty
|
71
|
+
|
72
|
+
expect(@git.changed_files("directory", "HEAD~")).to include("directory/file")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
73
76
|
|
74
|
-
|
77
|
+
describe "#archive" do
|
78
|
+
it "archives a version of a directory" do
|
79
|
+
Dir.chdir(@git_path) do
|
80
|
+
@git.commit_file(".", "initial commit")
|
75
81
|
|
76
|
-
File.
|
77
|
-
|
78
|
-
|
82
|
+
FileUtils.touch(File.join("outside_not_archived"))
|
83
|
+
Dir.mkdir("directory")
|
84
|
+
FileUtils.touch(File.join("directory", "file"))
|
85
|
+
@git.commit_file("directory", "test")
|
79
86
|
|
80
|
-
|
87
|
+
FileUtils.touch(File.join("directory", "later_not_archived"))
|
81
88
|
|
82
|
-
|
83
|
-
end_id = @git.latest_id("tetra: test_end")
|
89
|
+
@git.commit_file("directory", "later")
|
84
90
|
|
85
|
-
|
91
|
+
destination_path = @git.archive("directory", @git.latest_id("test"), "archive.tar.xz")
|
92
|
+
expect(destination_path).to match(/archive.tar.xz$/)
|
86
93
|
|
87
|
-
|
88
|
-
expect(
|
89
|
-
expect(
|
90
|
-
expect(
|
94
|
+
file_list = `tar --list -f archive.tar.xz`.split
|
95
|
+
expect(file_list).not_to include("outside_not_archived")
|
96
|
+
expect(file_list).to include("directory/file")
|
97
|
+
expect(file_list).not_to include("directory/later_not_archived")
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "#format_patch" do
|
103
|
+
it "creates patch files from commits" do
|
104
|
+
Dir.chdir(@git_path) do
|
105
|
+
outside_dir_file = File.join("outside_dir")
|
106
|
+
inside_dir_not_patched_file = File.join("directory", "inside_dir_not_patched")
|
107
|
+
inside_dir_patched_file = File.join("directory", "inside_dir_patched")
|
108
|
+
|
109
|
+
Dir.mkdir("directory")
|
110
|
+
FileUtils.touch(outside_dir_file)
|
111
|
+
FileUtils.touch(inside_dir_not_patched_file)
|
112
|
+
FileUtils.touch(inside_dir_patched_file)
|
113
|
+
@git.commit_file(".", "initial")
|
114
|
+
|
115
|
+
File.open(outside_dir_file, "w") { |f| f.write("A") }
|
116
|
+
File.open(inside_dir_patched_file, "w") { |f| f.write("A") }
|
117
|
+
@git.commit_file(".", "patch")
|
118
|
+
|
119
|
+
Dir.mkdir("patches")
|
120
|
+
patch_names = @git.format_patch("directory", "HEAD~", "patches")
|
121
|
+
|
122
|
+
expect(patch_names).to include("patches/0001-patch.patch")
|
123
|
+
|
124
|
+
patch_contents = File.readlines(File.join("patches", "0001-patch.patch"))
|
125
|
+
expect(patch_contents).to include("--- a/#{inside_dir_patched_file}\n")
|
126
|
+
expect(patch_contents).not_to include("--- a/#{outside_dir_file}\n")
|
127
|
+
expect(patch_contents).not_to include("--- a/#{inside_dir_not_patched_file}\n")
|
128
|
+
expect(patch_contents).to include("@@ -0,0 +1 @@\n")
|
129
|
+
expect(patch_contents).to include("+A\n")
|
91
130
|
end
|
92
131
|
end
|
93
132
|
end
|
@@ -28,20 +28,4 @@ describe Tetra::KitPackage do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
32
|
-
describe "#to_archive" do
|
33
|
-
it "generates an archive" do
|
34
|
-
@project.from_directory(File.join("kit", "m2")) do
|
35
|
-
FileUtils.touch("kit.content")
|
36
|
-
end
|
37
|
-
|
38
|
-
expected_filename = File::SEPARATOR + "#{package_name}.tar.xz"
|
39
|
-
expect(instance.to_archive).to end_with(expected_filename)
|
40
|
-
|
41
|
-
@project.from_directory do
|
42
|
-
contents = `tar --list -f packages/#{package_name}/#{package_name}.tar.xz`.split
|
43
|
-
expect(contents).to include("./m2/kit.content")
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
31
|
end
|
@@ -33,7 +33,8 @@ describe Tetra::Package do
|
|
33
33
|
|
34
34
|
FileUtils.copy(File.join("spec", "data", "nailgun", "pom.xml"), @project_path)
|
35
35
|
|
36
|
-
|
36
|
+
patches = @project.write_source_patches
|
37
|
+
@package = Tetra::Package.new(@project, File.join(@project_path, "pom.xml"), "*.jar", patches)
|
37
38
|
end
|
38
39
|
|
39
40
|
after(:each) do
|
@@ -56,18 +57,4 @@ describe Tetra::Package do
|
|
56
57
|
end
|
57
58
|
end
|
58
59
|
end
|
59
|
-
|
60
|
-
describe "#to_archive" do
|
61
|
-
it "generates an archive" do
|
62
|
-
@project.from_directory("src") do
|
63
|
-
FileUtils.touch("src_test")
|
64
|
-
end
|
65
|
-
@project.finish
|
66
|
-
|
67
|
-
@package.to_archive
|
68
|
-
@project.from_directory do
|
69
|
-
expect(`tar -Jtf packages/test-project/test-project.tar.xz`.split).to include("./src_test")
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
60
|
end
|