[why] There are two files need init job content, then use a function to wrap the code.
Signed-off-by: Cao Xueliang caoxl78320@163.com --- lib/git_bisect.rb | 8 +------- src/delimiter/find-commit/bisect_run_script.rb | 3 +-- src/delimiter/utils.rb | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/lib/git_bisect.rb b/lib/git_bisect.rb index c548861..9033db2 100644 --- a/lib/git_bisect.rb +++ b/lib/git_bisect.rb @@ -35,13 +35,7 @@ class GitBisect end
def set_bad_job - @bad_job = @es.query_by_id @bad_job_id - raise "es query job id: #{@bad_job_id} failed!" unless @bad_job - - @bad_job.delete('uuid') - @bad_job.delete('stats') - @bad_job.delete('id') - @bad_job.delete('error_ids') + @bad_job = Utils.init_job_content(@bad_job_id) end
def set_upstream diff --git a/src/delimiter/find-commit/bisect_run_script.rb b/src/delimiter/find-commit/bisect_run_script.rb index d5e4226..4877d79 100755 --- a/src/delimiter/find-commit/bisect_run_script.rb +++ b/src/delimiter/find-commit/bisect_run_script.rb @@ -18,8 +18,7 @@ class GitBisectRun end
def git_bisect - job = @es.query_by_id @job_id - job.delete('stats') if job.key?('stats') + job = Utils.init_job_content(@job_id) commit = `git -C #{@work_dir} log --pretty=format:"%H" -1` job['upstream_commit'] = commit get_bisect_status job diff --git a/src/delimiter/utils.rb b/src/delimiter/utils.rb index 82cb918..679c8d9 100644 --- a/src/delimiter/utils.rb +++ b/src/delimiter/utils.rb @@ -87,5 +87,23 @@ module Utils
return 'good' end + + def init_job_content(job_id) + es = ESQuery.new + job = es.query_by_id(job_id) + raise "es query job id: #{job_id} failed!" unless job + + job['bad_job_id'] = job_id + job['suite'] = 'bisect' + + job.delete('id') + job.delete('uuid') + job.delete('error_ids') + job.delete('start_time') + job.delete('end_time') + job.delete('loadavg') + + return job + end end end