[PATCH v1 compass-ci] lib/job.cr: fix failed to upload package

[why] If the JSON::Any type pkg_style value is nil, we don't set the default upload path. [how] If the JSON::Any type pkg_style value is nil, we set it to empty hash that will get a default upload path. Signed-off-by: Cao Xueliang <caoxl78320@163.com> --- src/lib/job.cr | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/job.cr b/src/lib/job.cr index 1d25236..07bfda0 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -256,7 +256,9 @@ class Job pkg_style = @hash[item]? break if pkg_style end - return nil unless pkg_style && pkg_style != nil + return nil unless pkg_style + + pkg_style = JSON.parse("{}") if pkg_style == nil tmp_os = pkg_style["os"]? == nil ? "#{os}" : pkg_style["os"] tmp_os_arch = pkg_style["os_arch"]? == nil ? "#{os_arch}" : pkg_style["os_arch"] -- 2.23.0

Reviewed-by: Wang Yong <wangyong0117@qq.com> On Fri, Jan 15, 2021 at 04:12:30PM +0800, Cao Xueliang wrote:
[why] If the JSON::Any type pkg_style value is nil, we don't set the default upload path.
[how] If the JSON::Any type pkg_style value is nil, we set it to empty hash that will get a default upload path.
Signed-off-by: Cao Xueliang <caoxl78320@163.com> --- src/lib/job.cr | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr index 1d25236..07bfda0 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -256,7 +256,9 @@ class Job pkg_style = @hash[item]? break if pkg_style end - return nil unless pkg_style && pkg_style != nil + return nil unless pkg_style + + pkg_style = JSON.parse("{}") if pkg_style == nil
tmp_os = pkg_style["os"]? == nil ? "#{os}" : pkg_style["os"] tmp_os_arch = pkg_style["os_arch"]? == nil ? "#{os_arch}" : pkg_style["os_arch"] -- 2.23.0

On Fri, Jan 15, 2021 at 04:12:30PM +0800, Cao Xueliang wrote:
[why] If the JSON::Any type pkg_style value is nil, we don't set the default upload path.
If -> When | Once Thanks, RenWen
[how] If the JSON::Any type pkg_style value is nil, we set it to empty hash that will get a default upload path.
Signed-off-by: Cao Xueliang <caoxl78320@163.com> --- src/lib/job.cr | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr index 1d25236..07bfda0 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -256,7 +256,9 @@ class Job pkg_style = @hash[item]? break if pkg_style end - return nil unless pkg_style && pkg_style != nil + return nil unless pkg_style + + pkg_style = JSON.parse("{}") if pkg_style == nil
tmp_os = pkg_style["os"]? == nil ? "#{os}" : pkg_style["os"] tmp_os_arch = pkg_style["os_arch"]? == nil ? "#{os_arch}" : pkg_style["os_arch"] -- 2.23.0

On Fri, Jan 15, 2021 at 04:58:58PM +0800, Ren Wen wrote:
On Fri, Jan 15, 2021 at 04:12:30PM +0800, Cao Xueliang wrote:
[why] If the JSON::Any type pkg_style value is nil, we don't set the default upload path.
If -> When | Once
Ignore this. 'If' is suitable. Thanks, RenWen
Thanks, RenWen
[how] If the JSON::Any type pkg_style value is nil, we set it to empty hash that will get a default upload path.
Signed-off-by: Cao Xueliang <caoxl78320@163.com> --- src/lib/job.cr | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr index 1d25236..07bfda0 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -256,7 +256,9 @@ class Job pkg_style = @hash[item]? break if pkg_style end - return nil unless pkg_style && pkg_style != nil + return nil unless pkg_style + + pkg_style = JSON.parse("{}") if pkg_style == nil
tmp_os = pkg_style["os"]? == nil ? "#{os}" : pkg_style["os"] tmp_os_arch = pkg_style["os_arch"]? == nil ? "#{os_arch}" : pkg_style["os_arch"] -- 2.23.0
participants (3)
-
Cao Xueliang
-
Ren Wen
-
Wang Yong