If we use "git -C /srv/git/#{repo}.git", we need mount "/srv/git", but sometimes we have clone the git repo, so we don't need mount "/srv/git". Now, we just need to pass the work_dir to the GitCommit class.
Signed-off-by: Cao Xueliang caoxl78320@163.com --- lib/git.rb | 4 ++-- lib/git_bisect.rb | 2 +- lib/mail_bisect_result.rb | 8 +++++++- 3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/lib/git.rb b/lib/git.rb index db97c47..9751dcf 100644 --- a/lib/git.rb +++ b/lib/git.rb @@ -2,8 +2,8 @@
# wrap common git commands class GitCommit - def initialize(repo, commit) - @git_prefix = "git -C /srv/git/#{repo}.git" + def initialize(work_dir, commit) + @git_prefix = "git -C #{work_dir}" @commit = commit end
diff --git a/lib/git_bisect.rb b/lib/git_bisect.rb index e577afd..5d13074 100644 --- a/lib/git_bisect.rb +++ b/lib/git_bisect.rb @@ -100,10 +100,10 @@ class GitBisect bisect_error = ErrorMessages.new(@build_pkg_dir).obtain_error_messages_by_error_id(@error_id) all_errors = Utils.obt_errors(@work_dir, first_bad_commit) first_bad_commit_result_root = Utils.obt_result_root_by_commit(first_bad_commit) - FileUtils.rm_r(@work_dir) if Dir.exist?(@work_dir)
return Hash['repo' => @upstream_repo, 'commit' => first_bad_commit, + 'work_dir' => @work_dir, 'bisect_error' => bisect_error, 'all_errors' => all_errors, 'pkgbuild_repo' => @pkgbuild_repo, diff --git a/lib/mail_bisect_result.rb b/lib/mail_bisect_result.rb index 209a28d..637c008 100644 --- a/lib/mail_bisect_result.rb +++ b/lib/mail_bisect_result.rb @@ -12,12 +12,13 @@ require_relative 'assign_account_client' class MailBisectResult def initialize(bisect_info) @repo = bisect_info['repo'] + @work_dir = bisect_info['work_dir'] @commit_id = bisect_info['commit'] @all_errors = bisect_info['all_errors'] @bisect_error = bisect_info['bisect_error'] @pkgbuild_repo = bisect_info['pkgbuild_repo'] @first_bad_commit_result_root = bisect_info['first_bad_commit_result_root'] - @git_commit = GitCommit.new(@repo, @commit_id) + @git_commit = GitCommit.new(@work_dir, @commit_id) @to = @git_commit.author_email # now send mail to review @bcc = 'caoxl@crystal.ci, caoxl78320@163.com, huming15@163.com, wfg@mail.ustc.edu.cn' @@ -26,6 +27,7 @@ class MailBisectResult def create_send_email send_report_mail(compose_mail) send_account_mail + rm_work_dir end
def compose_mail @@ -80,4 +82,8 @@ class MailBisectResult apply_account = AutoAssignAccount.new(user_info) apply_account.send_account end + + def rm_work_dir + FileUtils.rm_r(@work_dir) if Dir.exist?(@work_dir) + end end