Compare commits
7 Commits
v2.2.0
...
c7871397d3
| Author | SHA1 | Date | |
|---|---|---|---|
| c7871397d3 | |||
| e8d4ae392e | |||
|
|
4187798fd7 | ||
| 5d8af5f76a | |||
| 2fce9b19af | |||
|
|
fac1127539 | ||
|
|
b35703d271 |
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,5 +1,15 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Unreleased - REACHED the standalone repo
|
||||||
|
|
||||||
|
- Bidirectional sync smoke-test marker — forward leg (monorepo → subrepo), 2026-05-28.
|
||||||
|
|
||||||
|
## 2.2.1
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
|
||||||
|
- Initial import now force-adds copied subrepo files so tracked files that match the copied `.gitignore` are included in the import PR.
|
||||||
|
|
||||||
## 2.2.0
|
## 2.2.0
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|||||||
@@ -500,7 +500,7 @@ initial_import() {
|
|||||||
|
|
||||||
mkdir -p "$subfolder"
|
mkdir -p "$subfolder"
|
||||||
rsync -a --exclude='.git' "${work_dir}/subrepo/" "${subfolder}/"
|
rsync -a --exclude='.git' "${work_dir}/subrepo/" "${subfolder}/"
|
||||||
git add "$subfolder"
|
git add -f -- "$subfolder"
|
||||||
|
|
||||||
if git diff --cached --quiet; then
|
if git diff --cached --quiet; then
|
||||||
log "INFO" "No changes — subfolder already matches subrepo"
|
log "INFO" "No changes — subfolder already matches subrepo"
|
||||||
|
|||||||
90
tests/unit/sync.bats
Normal file
90
tests/unit/sync.bats
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
# tests/unit/sync.bats — Sync/import algorithm tests
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
export JOSH_SYNC_ROOT="$(cd "$BATS_TEST_DIRNAME/../.." && pwd)"
|
||||||
|
source "$JOSH_SYNC_ROOT/lib/core.sh"
|
||||||
|
source "$JOSH_SYNC_ROOT/lib/sync.sh"
|
||||||
|
|
||||||
|
TEST_ROOT="$(mktemp -d)"
|
||||||
|
export BOT_NAME="test-bot"
|
||||||
|
export BOT_EMAIL="test-bot@test.local"
|
||||||
|
export BOT_TRAILER="Josh-Sync-Origin"
|
||||||
|
export GITEA_TOKEN="test-token"
|
||||||
|
export MONOREPO_API="https://gitea.test.local/api/v1/repos/org/mono"
|
||||||
|
export JOSH_SYNC_TARGET_NAME="crm"
|
||||||
|
export JOSH_SYNC_TARGETS='[{"name":"crm","subfolder":"apps/crm"}]'
|
||||||
|
export SYNC_BRANCH_MONO="main"
|
||||||
|
export SYNC_BRANCH_SUBREPO="main"
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
rm -rf "$TEST_ROOT"
|
||||||
|
}
|
||||||
|
|
||||||
|
make_mono_repo() {
|
||||||
|
local work="${TEST_ROOT}/mono-work"
|
||||||
|
local bare="${TEST_ROOT}/mono.git"
|
||||||
|
|
||||||
|
git init "$work" >/dev/null
|
||||||
|
git -C "$work" checkout -b main >/dev/null
|
||||||
|
git -C "$work" config user.name "Test User"
|
||||||
|
git -C "$work" config user.email "test@test.local"
|
||||||
|
printf 'mono\n' > "${work}/README.md"
|
||||||
|
git -C "$work" add README.md
|
||||||
|
git -C "$work" commit -m "mono base" >/dev/null
|
||||||
|
|
||||||
|
git init --bare "$bare" >/dev/null
|
||||||
|
git -C "$work" remote add origin "$bare"
|
||||||
|
git -C "$work" push origin main >/dev/null
|
||||||
|
printf '%s\n' "$bare"
|
||||||
|
}
|
||||||
|
|
||||||
|
make_subrepo_with_tracked_ignored_file() {
|
||||||
|
local work="${TEST_ROOT}/subrepo-work"
|
||||||
|
local bare="${TEST_ROOT}/subrepo.git"
|
||||||
|
|
||||||
|
git init "$work" >/dev/null
|
||||||
|
git -C "$work" checkout -b main >/dev/null
|
||||||
|
git -C "$work" config user.name "Test User"
|
||||||
|
git -C "$work" config user.email "test@test.local"
|
||||||
|
|
||||||
|
mkdir -p "${work}/.dependencies"
|
||||||
|
printf '.dependencies/\n' > "${work}/.gitignore"
|
||||||
|
printf 'visible\n' > "${work}/visible.txt"
|
||||||
|
printf 'tracked even though ignored\n' > "${work}/.dependencies/tracked.txt"
|
||||||
|
|
||||||
|
git -C "$work" add .gitignore visible.txt
|
||||||
|
git -C "$work" add -f .dependencies/tracked.txt
|
||||||
|
git -C "$work" commit -m "subrepo with tracked ignored file" >/dev/null
|
||||||
|
|
||||||
|
git init --bare "$bare" >/dev/null
|
||||||
|
git -C "$work" remote add origin "$bare"
|
||||||
|
git -C "$work" push origin main >/dev/null
|
||||||
|
printf '%s\n' "$bare"
|
||||||
|
}
|
||||||
|
|
||||||
|
mono_auth_url() {
|
||||||
|
printf '%s\n' "$MONO_BARE"
|
||||||
|
}
|
||||||
|
|
||||||
|
subrepo_auth_url() {
|
||||||
|
printf '%s\n' "$SUBREPO_BARE"
|
||||||
|
}
|
||||||
|
|
||||||
|
create_pr() {
|
||||||
|
printf '%s\n' "$4" > "${TEST_ROOT}/created-pr-head"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "initial_import stages files tracked in subrepo even when ignored by copied .gitignore" {
|
||||||
|
MONO_BARE="$(make_mono_repo)"
|
||||||
|
SUBREPO_BARE="$(make_subrepo_with_tracked_ignored_file)"
|
||||||
|
|
||||||
|
local result import_branch
|
||||||
|
result="$(initial_import)"
|
||||||
|
import_branch="$(cat "${TEST_ROOT}/created-pr-head")"
|
||||||
|
|
||||||
|
[ "$result" = "pr-created" ]
|
||||||
|
git --git-dir="$MONO_BARE" ls-tree -r --name-only "$import_branch" \
|
||||||
|
| grep -q '^apps/crm/.dependencies/tracked.txt$'
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user