From a8d26c65b89adafe279f1be8eb0f895ffe2d4b5c Mon Sep 17 00:00:00 2001 From: Dylan Griffith <dyl.griffith@gmail.com> Date: Thu, 25 Jan 2024 02:49:08 +0000 Subject: [PATCH] Minor fixes for `Keeps::OverdueFinalizeBackgroundMigration` in CI --- gems/gitlab-housekeeper/lib/gitlab/housekeeper/git.rb | 4 +++- keeps/overdue_finalize_background_migration.rb | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gems/gitlab-housekeeper/lib/gitlab/housekeeper/git.rb b/gems/gitlab-housekeeper/lib/gitlab/housekeeper/git.rb index 329d32885eeef..cb2a8154d85a0 100644 --- a/gems/gitlab-housekeeper/lib/gitlab/housekeeper/git.rb +++ b/gems/gitlab-housekeeper/lib/gitlab/housekeeper/git.rb @@ -30,7 +30,9 @@ def with_branch_from_branch yield ensure - Shell.execute("git", "checkout", current_branch) + # The `current_branch` won't be set in CI due to how the repo is cloned. Therefore we should only checkout + # `current_branch` if we actually have one. + Shell.execute("git", "checkout", current_branch) if current_branch.present? Shell.execute('git', 'stash', 'pop') if stashed end diff --git a/keeps/overdue_finalize_background_migration.rb b/keeps/overdue_finalize_background_migration.rb index 035db201b4857..02dc33c4d6318 100644 --- a/keeps/overdue_finalize_background_migration.rb +++ b/keeps/overdue_finalize_background_migration.rb @@ -3,6 +3,7 @@ require_relative '../config/environment' require_relative '../lib/generators/post_deployment_migration/post_deployment_migration_generator' require_relative './helpers/postgres_ai' +require 'rubocop' module Keeps # This is an implementation of a ::Gitlab::Housekeeper::Keep. This keep will locate any old batched background -- GitLab