test_ids 0.5.0 → 0.5.1
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.
- checksums.yaml +4 -4
- data/config/application.rb +4 -0
- data/config/shared_commands.rb +16 -0
- data/config/version.rb +1 -1
- data/lib/test_ids/allocator.rb +9 -12
- data/lib/test_ids/git.rb +58 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afcff07db00bb24f204b83bb988a98630d623642
|
4
|
+
data.tar.gz: 7b396dc69641b9375d45ca513709376a40ffe7e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b940f125fb2e81190a0699a1b9ca9d4566bfc8e3b3b370ecaac57e955175008616f73b6336bcff841295a8a379c5e562c0ed192fb91ee82574df1fb0bbdf94d7
|
7
|
+
data.tar.gz: 22eda1e5968da45e985035a3e0a539a8dc0a2396eb7d5da43013d958849d90f98f0f591abc1e6b9681a92817ac524361c58718bdf1b3ee0ea9a2799013704b17
|
data/config/application.rb
CHANGED
@@ -36,6 +36,10 @@ class TestIdsApplication < Origen::Application
|
|
36
36
|
#files: ["lib", "config/application.rb"],
|
37
37
|
}
|
38
38
|
|
39
|
+
config.shared = {
|
40
|
+
command_launcher: "config/shared_commands.rb"
|
41
|
+
}
|
42
|
+
|
39
43
|
config.semantically_version = true
|
40
44
|
|
41
45
|
# An example of how to set application specific LSF parameters
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# The requested command is passed in here as @command
|
2
|
+
case @command
|
3
|
+
|
4
|
+
when "test_ids:rollback"
|
5
|
+
if ARGV[0]
|
6
|
+
TestIds::Git.rollback(ARGV[0])
|
7
|
+
else
|
8
|
+
puts "You must supply a commit ID to rollback to, e.g. origen test_ids:rollback 456ac3f53"
|
9
|
+
end
|
10
|
+
exit 0
|
11
|
+
else
|
12
|
+
@plugin_commands << <<-EOT
|
13
|
+
test_ids:rollback Rollback the TestIds store to the given commit ID
|
14
|
+
EOT
|
15
|
+
|
16
|
+
end
|
data/config/version.rb
CHANGED
data/lib/test_ids/allocator.rb
CHANGED
@@ -22,7 +22,7 @@ module TestIds
|
|
22
22
|
t = store['tests'][name]
|
23
23
|
# If the user has supplied any of these, that number should be used
|
24
24
|
# and reserved so that it is not automatically generated later
|
25
|
-
if options[:bin]
|
25
|
+
if options[:bin] && options[:bin].is_a?(Numeric)
|
26
26
|
t['bin'] = options[:bin]
|
27
27
|
store['manually_assigned']['bin'][options[:bin].to_s] = true
|
28
28
|
# Regenerate the bin if the original allocation has since been applied
|
@@ -33,7 +33,7 @@ module TestIds
|
|
33
33
|
t['softbin'] = nil if config.softbins.function?
|
34
34
|
t['number'] = nil if config.numbers.function?
|
35
35
|
end
|
36
|
-
if options[:softbin]
|
36
|
+
if options[:softbin] && options[:softbin].is_a?(Numeric)
|
37
37
|
t['softbin'] = options[:softbin]
|
38
38
|
store['manually_assigned']['softbin'][options[:softbin].to_s] = true
|
39
39
|
elsif store['manually_assigned']['softbin'][t['softbin'].to_s]
|
@@ -41,7 +41,7 @@ module TestIds
|
|
41
41
|
# Also regenerate the number as it could be a function of the softbin
|
42
42
|
t['number'] = nil if config.numbers.function?
|
43
43
|
end
|
44
|
-
if options[:number]
|
44
|
+
if options[:number] && options[:number].is_a?(Numeric)
|
45
45
|
t['number'] = options[:number]
|
46
46
|
store['manually_assigned']['number'][options[:number].to_s] = true
|
47
47
|
elsif store['manually_assigned']['number'][t['number'].to_s]
|
@@ -51,19 +51,16 @@ module TestIds
|
|
51
51
|
t['bin'] ||= allocate_bin
|
52
52
|
t['softbin'] ||= allocate_softbin(t['bin'])
|
53
53
|
t['number'] ||= allocate_number(t['bin'], t['softbin'])
|
54
|
-
t['bin'] = nil if t['bin'] == :none
|
55
|
-
t['softbin'] = nil if t['softbin'] == :none
|
56
|
-
t['number'] = nil if t['number'] == :none
|
57
54
|
# Record that there has been a reference to the final numbers
|
58
55
|
time = Time.now.to_f
|
59
|
-
store['references']['bin'][t['bin'].to_s] = time if t['bin']
|
60
|
-
store['references']['softbin'][t['softbin'].to_s] = time if t['softbin']
|
61
|
-
store['references']['number'][t['number'].to_s] = time if t['number']
|
56
|
+
store['references']['bin'][t['bin'].to_s] = time if t['bin'] && options[:bin] != :none
|
57
|
+
store['references']['softbin'][t['softbin'].to_s] = time if t['softbin'] && options[:softbin] != :none
|
58
|
+
store['references']['number'][t['number'].to_s] = time if t['number'] && options[:number] != :none
|
62
59
|
# Update the supplied options hash that will be forwarded to the
|
63
60
|
# program generator
|
64
|
-
options[:bin] = t['bin']
|
65
|
-
options[:softbin] = t['softbin']
|
66
|
-
options[:number] = t['number']
|
61
|
+
options[:bin] = t['bin'] unless options.delete(:bin) == :none
|
62
|
+
options[:softbin] = t['softbin'] unless options.delete(:softbin) == :none
|
63
|
+
options[:number] = t['number'] unless options.delete(:number) == :none
|
67
64
|
options
|
68
65
|
end
|
69
66
|
|
data/lib/test_ids/git.rb
CHANGED
@@ -10,8 +10,66 @@ module TestIds
|
|
10
10
|
#
|
11
11
|
# An instance of this class is instantiated as TestIds.git
|
12
12
|
class Git
|
13
|
+
include Origen::Utility::InputCapture
|
14
|
+
|
13
15
|
attr_reader :repo, :local
|
14
16
|
|
17
|
+
class Rollback
|
18
|
+
include Origen::Utility::InputCapture
|
19
|
+
|
20
|
+
def initialize(id)
|
21
|
+
repos = Dir.glob("#{Origen.app.imports_dir}/test_ids/*.git")
|
22
|
+
if repos.size == 0
|
23
|
+
puts 'No TestIds repositories were found in this application'
|
24
|
+
elsif repos.size > 1
|
25
|
+
puts
|
26
|
+
puts 'Multiple TestIDs repositories found, select the one to rollback:'
|
27
|
+
puts
|
28
|
+
repos.each_with_index do |repo, i|
|
29
|
+
puts " #{i} - #{Pathname.new(repo).basename}"
|
30
|
+
end
|
31
|
+
accept = repos.map.with_index { |r, i| i }
|
32
|
+
puts
|
33
|
+
selection = repos.size + 1
|
34
|
+
until repos[selection]
|
35
|
+
selection = get_text(single: true, accept: accept).to_i
|
36
|
+
end
|
37
|
+
else
|
38
|
+
selection = 0
|
39
|
+
end
|
40
|
+
name = Pathname.new(repos[selection]).basename.to_s
|
41
|
+
repo = ::Git.open(repos[selection])
|
42
|
+
begin
|
43
|
+
commit = repo.object(id)
|
44
|
+
rescue ::Git::GitExecuteError
|
45
|
+
puts 'The given commit ID cannot be found in that repository'
|
46
|
+
exit
|
47
|
+
end
|
48
|
+
day = 24 * 60 * 60
|
49
|
+
if commit.date < Time.now - (7 * day)
|
50
|
+
puts "Sorry, that commit is more than a week old and I'm too scared to rollback that far."
|
51
|
+
puts 'You will need to do that manually if you must.'
|
52
|
+
exit
|
53
|
+
end
|
54
|
+
puts
|
55
|
+
puts "About to rollback the TestIds repository #{name} to commit #{id}."
|
56
|
+
puts
|
57
|
+
puts 'This will permanently delete any IDs assigned by anyone, anywhere, since that commit.'
|
58
|
+
puts
|
59
|
+
puts 'ARE YOU SURE YOU KNOW WHAT YOU ARE DOING?'
|
60
|
+
puts
|
61
|
+
get_text(confirm: true, default: 'no')
|
62
|
+
repo.reset_hard(id)
|
63
|
+
repo.push('origin', 'master', force: true)
|
64
|
+
puts 'As you wish, rolled back successfully!'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.rollback(id)
|
69
|
+
# Implemented as a class as a hack to get access to InputCapture
|
70
|
+
Rollback.new(id)
|
71
|
+
end
|
72
|
+
|
15
73
|
def initialize(options)
|
16
74
|
unless File.exist?("#{options[:local]}/.git")
|
17
75
|
FileUtils.rm_rf(options[:local]) if File.exist?(options[:local])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_ids
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen McGinty
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: origen
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- config/application.rb
|
63
63
|
- config/boot.rb
|
64
64
|
- config/commands.rb
|
65
|
+
- config/shared_commands.rb
|
65
66
|
- config/version.rb
|
66
67
|
- lib/tasks/test_ids.rake
|
67
68
|
- lib/test_ids.rb
|