Signed-off-by: Zhang Yu 2134782174@qq.com --- src/lib/job.cr | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr index a4345e0..70eab23 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -136,6 +136,15 @@ class Job update(json.as_h) end
+ def delete(key : String) + initialized_keys = get_initialized_keys + if initialized_keys.includes?(key) + raise "Should not delete #{key}" + else + @hash.delete(key) + end + end + private def set_defaults append_init_field() set_user_lkp_src() @@ -324,7 +333,7 @@ class Job @hash.delete("my_uuid") end
- private def initialized? + private def get_initialized_keys() initialized_keys = [] of String
REQUIRED_KEYS.each do |key| @@ -350,7 +359,10 @@ class Job "kernel_uri", "kernel_params", "linux_vmlinuz_path"] + end
+ private def initialized? + initialized_keys = get_initialized_keys initialized_keys.each do |key| return false unless @hash.has_key?(key) end
On Tue, Dec 08, 2020 at 10:08:30AM +0800, Zhang Yu wrote:
Signed-off-by: Zhang Yu 2134782174@qq.com
src/lib/job.cr | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr index a4345e0..70eab23 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -136,6 +136,15 @@ class Job update(json.as_h) end
- def delete(key : String)
- initialized_keys = get_initialized_keys
- if initialized_keys.includes?(key)
raise "Should not delete #{key}"
- else
@hash.delete(key)
- end
- end
- private def set_defaults append_init_field() set_user_lkp_src()
@@ -324,7 +333,7 @@ class Job @hash.delete("my_uuid") end
- private def initialized?
- private def get_initialized_keys()
no need to add () for no parameter in
you should use rubocop to check the code. and you should run 'cd repo_dir; overcommit -i' to install the overcommit to the repo
Thanks, Luan Shengde
initialized_keys = [] of String REQUIRED_KEYS.each do |key|
@@ -350,7 +359,10 @@ class Job "kernel_uri", "kernel_params", "linux_vmlinuz_path"]
end
private def initialized?
initialized_keys = get_initialized_keys initialized_keys.each do |key| return false unless @hash.has_key?(key) end
-- 2.23.0
- private def get_initialized_keys()
no need to add () for no parameter in
ok
you should use rubocop to check the code.
this is crystal file not ruby.
and you should run 'cd repo_dir; overcommit -i' to install the overcommit to the repo
ok
Thanks, Luan Shengde
initialized_keys = [] of String REQUIRED_KEYS.each do |key|
@@ -350,7 +359,10 @@ class Job "kernel_uri", "kernel_params", "linux_vmlinuz_path"]
end
private def initialized?
initialized_keys = get_initialized_keys initialized_keys.each do |key| return false unless @hash.has_key?(key) end
-- 2.23.0