Files
MidoriKurageandwizardchen 236d8c098f fix(datasource): perform real sync deletions scoped per data source (#2690)
* test(datasource): cover scoped sync deletions

- deleted connector items remove the matching KB knowledge, scoped per data
  source via metadata datasource_id + external_id
- SyncDeletions=false neither deletes nor counts
- stream handler classifies deleted/failed items like the batch loop

* fix(datasource): perform real sync deletions scoped per data source

- applyFetchedItem now performs the KB deletion instead of only counting
- lookup is scoped to datasource_id + external_id so identical external IDs
  from two data sources cannot collide or overwrite each other
- ingestItem update-path lookup uses the same scoped query

* fix(datasource): note failed deletions retry only on full sync

- SyncResult.DeletionFailed tracks deletion failures (subset of Failed)
- streaming partial message warns that failed deletions only retry on a full
  sync, since the connector cursor is checkpointed past the deleted item

* fix(datasource): humanize deletion errors, keep raw detail in logs

- raw lookup/delete errors go to server logs only, with full context
- UI samples carry a humanized "see server logs" fallback
- add datasource.syncError.* i18n keys

Note: ko-KR / ru-RU syncError translations were generated without a
native-speaker review.

* fix(datasource): hard-delete synced rows and tighten deletion scoping

Sync-internal deletions now call HardDeleteKnowledge after the soft-delete
cascade so tombstones cannot block re-sync; subtree sweeps and URL metadata
attach failures are handled with datasource scoping and explicit errors.

* chore: add git hooks aligned with CI and PR checks

Install via scripts/install-git-hooks.sh (sets core.hooksPath). Pre-commit
runs whitespace/gofmt/golangci-lint on staged files; pre-push mirrors
app/frontend/cli workflows on the diff since origin/main.

* fix: gofmt test file; tighten pre-push to match CI app workflow

Pre-push now gofmts the full PR diff and runs go vet on all app packages
(like app.yml), not only Go files in the latest commit. Previous pushes
skipped checks via --no-verify and because hook-only commits had no .go files.

* fix(hooks): align pre-push diff with GitHub PR base via gh

Use three-dot diff against the open PR baseRefOid (same as CI) instead of
a two-dot merge-base range; run full go vet on every push with Go PR changes.

* style: gofumpt datasource_service_test.go

---------

Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-08-13 19:52:44 +08:00

39 lines
894 B
Bash
Executable File

#!/usr/bin/env bash
# Fast checks on staged files (PR checklist + gofmt). Mirrors app.yml formatting gate.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
# shellcheck source=scripts/git-hooks/common.sh
source "$ROOT/scripts/git-hooks/common.sh"
if hook_skip; then
exit 0
fi
cd "$ROOT"
log_step "pre-commit"
check_whitespace --cached
staged_go=()
while IFS= read -r line; do
[[ -n "$line" ]] && staged_go+=("$line")
done < <(git diff --cached --name-only --diff-filter=ACMR -- '*.go' ':!cli/**' || true)
if [[ ${#staged_go[@]} -gt 0 ]]; then
go_files=()
for f in "${staged_go[@]}"; do
go_files+=("$ROOT/$f")
done
check_gofmt_files write "${go_files[@]}"
if command -v golangci-lint >/dev/null 2>&1; then
# Lint only what differs from HEAD (staged + unstaged in those packages).
run_golangci_if_available HEAD
fi
fi
log_ok "pre-commit passed"