Compare commits
41 Commits
auto-sync/
...
v2.2.1
| Author | SHA1 | Date | |
|---|---|---|---|
| c7871397d3 | |||
| e8d4ae392e | |||
|
|
4187798fd7 | ||
|
|
fac1127539 | ||
| dc2cdea360 | |||
| f2e39be5e1 | |||
| b28662d3b4 | |||
| 5e9b134168 | |||
| 1cb23a4411 | |||
| 479b592076 | |||
| 65cc8eaf8a | |||
| 4861179c6f | |||
| c9b37f2477 | |||
| d3799187a1 | |||
| b4eaa47ef6 | |||
| d6f334b861 | |||
| 8ab07b83ab | |||
| 95b83bd538 | |||
| ce53d3c1d2 | |||
| 16257f25d7 | |||
| c0ddb887ff | |||
| 22bd59a9d7 | |||
| d7f8618b38 | |||
| 5929585d6c | |||
| 187a9ead14 | |||
| 401d0e87a4 | |||
| fbacec7f6f | |||
| 553f006174 | |||
| cb14cf9bd4 | |||
| 0363b0ee77 | |||
| 72430714af | |||
| 105216a27e | |||
| 405e5f4535 | |||
| cc08c530d1 | |||
| 5758987942 | |||
| 0edbdae558 | |||
| a19b795f9b | |||
| 0d2aea9664 | |||
| ad925d8228 | |||
| f2785241bf | |||
| 7c2d731399 |
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