tetra 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f1e5c1456138783ecb6759fa94e795e71c1b4bba
4
- data.tar.gz: c1a71c4a9802d350a7f08036a80d657b78675154
2
+ SHA256:
3
+ metadata.gz: 49390dd466afdc5488d1bf1443d3fe67a0932b0c76a59b30bc60a2372689f608
4
+ data.tar.gz: d65544049f50356123f81ecaa383c339a92269c597c098b071b80b3dc96b78e4
5
5
  SHA512:
6
- metadata.gz: b7c299c35196d1bed384db460b9fae82984de1cee142fd6643d762c4184a5f566ed2e5d8827ba5d1eb3f5c06d7c02cac7fc8075f0f424a44cae3667a7163b437
7
- data.tar.gz: 6a9ff3327df7db1e85dc14156acaef6588ecd19f8ad2791aa333b933a5aa44e7db1e3b66fb7284bd45994b9404dd3884230b5df44936a163c23a6db9c84f1290
6
+ metadata.gz: 93b0aa29b27648e3c5a3307ecd42b25bd7ae7492d6928ffb75926ea5d7937dbf68e89bf56fa199e1e54a7ffd651344cfdb429c15a046a9a9cbb3c775ab6ddfab
7
+ data.tar.gz: ad216938b93bd70455f1ee3ea62b509a6ffdc65742bc760b6fe20a65bd5a0c3a6dada151bdb5a2bfea43c0e44071e4cd5f80b705b96c894b464d6e8c6ac86500
@@ -12,7 +12,7 @@ module Tetra
12
12
 
13
13
  # runs bash in a subshell, returns list of
14
14
  # commands that were run in the session
15
- def bash
15
+ def bash(command = nil)
16
16
  Tempfile.open("tetra-history") do |history_file|
17
17
  Tempfile.open("tetra-bashrc") do |bashrc_file|
18
18
  kit = Tetra::Kit.new(@project)
@@ -31,12 +31,17 @@ module Tetra
31
31
  bashrc_file.write(bashrc_content)
32
32
  bashrc_file.flush
33
33
 
34
- run_interactive("bash --rcfile #{bashrc_file.path} -i")
35
- history = File.read(history_file)
36
- log.debug "history contents:"
37
- log.debug history
34
+ if command
35
+ run("bash --rcfile #{bashrc_file.path} -i -c '#{command}'")
36
+ [command]
37
+ else
38
+ run_interactive("bash --rcfile #{bashrc_file.path} -i")
39
+ history = File.read(history_file)
40
+ log.debug "history contents:"
41
+ log.debug history
38
42
 
39
- history.split("\n").map(&:strip)
43
+ history.split("\n").map(&:strip)
44
+ end
40
45
  end
41
46
  end
42
47
  end
@@ -161,7 +161,7 @@ module Tetra
161
161
  # since from_id
162
162
  def format_patch(directory, from_id, destination_path)
163
163
  Dir.chdir(@directory) do
164
- run("git format-patch -o #{destination_path} --numbered #{from_id} -- #{directory}").split
164
+ run("git format-patch -o #{destination_path} --no-numbered #{from_id} -- #{directory}").split
165
165
  end
166
166
  end
167
167
  end
@@ -11,7 +11,7 @@ module Tetra
11
11
  "set -xe",
12
12
  "PROJECT_PREFIX=`readlink -e .`",
13
13
  "cd #{project.latest_dry_run_directory}"
14
- ] + script_body(project)
14
+ ] + aliases(project) + project.build_script_lines
15
15
 
16
16
  new_content = script_lines.join("\n") + "\n"
17
17
 
@@ -25,27 +25,20 @@ module Tetra
25
25
  end
26
26
  end
27
27
 
28
- # returns the script body by taking the last dry-run's
29
- # build script lines and adjusting mvn and ant's paths
30
- def script_body(project)
31
- lines = project.build_script_lines
32
-
28
+ # setup aliases for adjusted versions of the packaging tools
29
+ def aliases(project)
33
30
  kit = Tetra::Kit.new(project)
31
+
32
+ aliases = []
34
33
  ant_path = kit.find_executable("ant")
35
34
  ant_commandline = Tetra::Ant.commandline("$PROJECT_PREFIX", ant_path)
35
+ aliases << "alias ant='#{ant_commandline}'"
36
36
 
37
37
  mvn_path = kit.find_executable("mvn")
38
38
  mvn_commandline = Tetra::Mvn.commandline("$PROJECT_PREFIX", mvn_path)
39
+ aliases << "alias mvn='#{mvn_commandline} -o'"
39
40
 
40
- lines.map do |line|
41
- if line =~ /^ant( .*)?$/
42
- line.gsub(/^ant/, ant_commandline)
43
- elsif line =~ /^mvn( .*)?$/
44
- line.gsub(/^mvn/, "#{mvn_commandline} -o")
45
- else
46
- line
47
- end
48
- end
41
+ aliases
49
42
  end
50
43
  end
51
44
  end
@@ -3,6 +3,7 @@
3
3
  module Tetra
4
4
  # tetra dry-run
5
5
  class DryRunSubcommand < Tetra::Subcommand
6
+ option ["-s", "--script"], "SCRIPT", "Run these commands to build the project instead of the interactive shell"
6
7
  def execute
7
8
  checking_exceptions do
8
9
  project = Tetra::Project.new(".")
@@ -14,13 +15,17 @@ module Tetra
14
15
  puts "Dry run not started."
15
16
  else
16
17
  project.dry_run
17
- puts "Dry-run started in a new bash shell."
18
- puts "Build your project now, \"mvn\" and \"ant\" are already bundled by tetra."
19
- puts "If the build succeedes end this dry run with ^D (Ctrl+D),"
20
- puts "if the build does not succeed use ^C^D to abort and undo any change"
18
+ if script
19
+ puts "Scripted dry-run started."
20
+ else
21
+ puts "Dry-run started in a new bash shell."
22
+ puts "Build your project now, \"mvn\" and \"ant\" are already bundled by tetra."
23
+ puts "If the build succeedes end this dry run with ^D (Ctrl+D),"
24
+ puts "if the build does not succeed use ^C^D to abort and undo any change"
25
+ end
21
26
 
22
27
  begin
23
- history = Tetra::Bash.new(project).bash
28
+ history = Tetra::Bash.new(project).bash(script)
24
29
  project.finish(history)
25
30
  puts "Dry-run finished"
26
31
  rescue ExecutionFailed
@@ -2,5 +2,5 @@
2
2
 
3
3
  # base module for tetra
4
4
  module Tetra
5
- VERSION = "2.0.4"
5
+ VERSION = "2.0.5"
6
6
  end
@@ -17,6 +17,7 @@ describe "`tetra dry-run`", type: :aruba do
17
17
  type("\u{0004}") # ^D (Ctrl+D), terminates bash with exit status 0
18
18
 
19
19
  expect(all_output).to include("Dry-run started")
20
+ expect(all_output).to include("bash shell")
20
21
  expect(all_output).to include("ciao")
21
22
  expect(all_output).to include("Dry-run finished")
22
23
 
@@ -28,4 +29,21 @@ describe "`tetra dry-run`", type: :aruba do
28
29
  expect(stdout_from("git rev-list --format=%B --max-count=1 HEAD")).to include("tetra: dry-run-finished")
29
30
  expect(stdout_from("git rev-list --format=%B --max-count=1 HEAD")).to include("tetra: build-script-line: echo ciao")
30
31
  end
32
+
33
+ it "does a scripted dry-run" do
34
+ run_simple("tetra init --no-archive mypackage")
35
+ cd("mypackage")
36
+
37
+ run_interactive("tetra dry-run -s 'echo ciao > ciao.jar'")
38
+
39
+ expect(all_output).to include("Scripted dry-run started")
40
+
41
+ # check that markers were written in git repo
42
+ run_simple("git rev-list --format=%B --max-count=1 HEAD~")
43
+ expect(stdout_from("git rev-list --format=%B --max-count=1 HEAD~")).to include("tetra: dry-run-started")
44
+
45
+ run_simple("git rev-list --format=%B --max-count=1 HEAD")
46
+ expect(stdout_from("git rev-list --format=%B --max-count=1 HEAD")).to include("tetra: dry-run-finished")
47
+ expect(stdout_from("git rev-list --format=%B --max-count=1 HEAD")).to include("tetra: build-script-line: echo ciao > ciao.jar")
48
+ end
31
49
  end
@@ -39,9 +39,10 @@ describe Tetra::Scriptable do
39
39
 
40
40
  expect(lines).to include("#!/bin/bash\n")
41
41
  expect(lines).to include("cd somewhere significant\n")
42
- expect(lines).to include("$PROJECT_PREFIX/kit/mvn/bin/mvn \
42
+ expect(lines).to include("mvn --options\n")
43
+ expect(lines).to include("alias mvn='$PROJECT_PREFIX/kit/mvn/bin/mvn \
43
44
  -Dmaven.repo.local=$PROJECT_PREFIX/kit/m2 --settings $PROJECT_PREFIX/kit/m2/settings.xml \
44
- --strict-checksums -o --options\n"
45
+ --strict-checksums -o'\n"
45
46
  )
46
47
 
47
48
  expect(lines).not_to include("some earlier command\n")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tetra
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Silvio Moioli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-19 00:00:00.000000000 Z
11
+ date: 2018-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -421,7 +421,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
421
421
  version: '0'
422
422
  requirements: []
423
423
  rubyforge_project: tetra
424
- rubygems_version: 2.5.2
424
+ rubygems_version: 2.7.6
425
425
  signing_key:
426
426
  specification_version: 4
427
427
  summary: A tool to package Java projects