Skip to content

Commit 6a7e78c

Browse files
committed
chore(migration): add initial source repository cleanup at startup
1 parent 02733fb commit 6a7e78c

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

monorepo-migration/migrate.sh

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,13 @@ MIGRATION_HEAD_BRANCH="main"
9292
echo "Basing migration branch on: ${MIGRATION_HEAD_BRANCH}"
9393

9494
# 1. Clone the source repository
95-
if [ ! -d "$SOURCE_DIR" ]; then
95+
if [ "${SKIP_SOURCE_UPDATE:-false}" = "true" ] && [ -d "$SOURCE_DIR" ]; then
96+
echo "Skipping source repository update and reusing existing directory..."
97+
else
98+
echo "Ensuring clean slate for history filters by removing existing source directory..."
99+
rm -rf "$SOURCE_DIR"
96100
echo "Cloning source repo: $SOURCE_REPO_URL into $SOURCE_DIR"
97101
git clone --branch main --single-branch "$SOURCE_REPO_URL" "$SOURCE_DIR"
98-
elif [ "${SKIP_SOURCE_UPDATE:-false}" = "true" ]; then
99-
echo "Skipping source repository update..."
100-
else
101-
echo "Source directory $SOURCE_DIR already exists. Ensuring it is clean and up-to-date..."
102-
cd "$SOURCE_DIR"
103-
git remote add origin "$SOURCE_REPO_URL" 2>/dev/null || git remote set-url origin "$SOURCE_REPO_URL"
104-
git fetch origin main
105-
git checkout -f "main"
106-
git reset --hard origin/main
107-
git clean -fd
108-
cd - > /dev/null
109102
fi
110103

111104
if [ "${SKIP_SOURCE_UPDATE:-false}" != "true" ]; then
@@ -438,7 +431,7 @@ bash generation/apply_versions.sh versions.txt current
438431

439432
# 7.12c Sync all owlbot.py formatting
440433
echo "Syncing all owlbot.py formatting..."
441-
bash generation/update_owlbot_postprocessor_config.sh || true
434+
bash generation/update_owlbot_postprocessor_config.sh "$SOURCE_REPO_NAME" || true
442435

443436
git add -u
444437
git commit -n --no-gpg-sign -m "chore($SOURCE_REPO_NAME): align versions and format owlbot configurations"

0 commit comments

Comments
 (0)