From 61cb32cc70d182a85ea303b1bee9beef353216a2 Mon Sep 17 00:00:00 2001 From: donghee yang Date: Thu, 29 Nov 2012 17:03:49 +0900 Subject: [PATCH] [Title] Fixed remote build to work even when the git cache is corruppted --- src/build_server/GitBuildJob.rb | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/build_server/GitBuildJob.rb b/src/build_server/GitBuildJob.rb index adb8dc7..978e016 100644 --- a/src/build_server/GitBuildJob.rb +++ b/src/build_server/GitBuildJob.rb @@ -54,7 +54,7 @@ class GitBuildJob < BuildJob @log.error( "Job is stopped by ERROR" , Log::LV_USER) @server.cleaner.clean_afterwards(@id) elsif @status == "CANCELED" then - if not @log.nil? then then + if not @log.nil? then @log.error( "Job is CANCELED" , Log::LV_USER) end @server.cleaner.clean_afterwards(@id) @@ -222,12 +222,24 @@ class GitBuildJob < BuildJob FileUtils.mkdir_p cache_path end - # check branch name + # verify git & check branch name if File.exist? git_path then - current_branch = git_cmd_return( "branch", git_path).select{|x| x.start_with?("*")}[0].split(" ")[1].strip - if current_branch != @git_branch then - @log.warn( "Branch name is changed.", Log::LV_USER) + std_out_lines = git_cmd_return( "branch", git_path) + if std_out_lines.nil? then + @log.warn( "Git cache is corrupted! : #{@project.name}", Log::LV_USER) FileUtils.rm_rf git_path + else + branch_list = std_out_lines.select{|x| x.start_with?("*")} + if branch_list.count == 0 then + @log.warn( "Git cache is corrupted! : #{@project.name}", Log::LV_USER) + FileUtils.rm_rf git_path + else + current_branch = branch_list[0].split(" ")[1].strip + if current_branch != @git_branch then + @log.warn( "Branch name is changed.", Log::LV_USER) + FileUtils.rm_rf git_path + end + end end end -- 2.34.1