🐛 fix(thirdparty): preserve manifest during snapshot update
This commit is contained in:
parent
2e26f98687
commit
91b0ea7458
|
|
@ -99,15 +99,30 @@ cd "$REPO_DIR"
|
|||
git config user.name "$COMMIT_AUTHOR_NAME"
|
||||
git config user.email "$COMMIT_AUTHOR_EMAIL"
|
||||
|
||||
git fetch origin "$TARGET_BRANCH"
|
||||
git checkout -B "$TARGET_BRANCH" "origin/$TARGET_BRANCH"
|
||||
|
||||
tmp_dir="$(mktemp -d)"
|
||||
cleanup() {
|
||||
rm -rf "$tmp_dir"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
if [ ! -f "$MANIFEST_PATH" ]; then
|
||||
echo "ERROR: third-party manifest not found: $MANIFEST_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
manifest_copy="$tmp_dir/thirdparty_skills.json"
|
||||
cp "$MANIFEST_PATH" "$manifest_copy"
|
||||
MANIFEST_PATH="$manifest_copy"
|
||||
|
||||
git fetch origin "$TARGET_BRANCH"
|
||||
git checkout -B "$TARGET_BRANCH" "origin/$TARGET_BRANCH"
|
||||
|
||||
sources_file="$tmp_dir/sources.tsv"
|
||||
if ! emit_sources_tsv > "$sources_file"; then
|
||||
echo "ERROR: failed to load third-party manifest: $MANIFEST_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
changed=0
|
||||
while IFS=$'\t' read -r source_id upstream_repo upstream_ref snapshot_dir sync_mode; do
|
||||
[ -n "$source_id" ] || continue
|
||||
|
|
@ -167,7 +182,7 @@ EOF
|
|||
|
||||
git add -A "$snapshot_dir"
|
||||
changed=1
|
||||
done < <(emit_sources_tsv)
|
||||
done < "$sources_file"
|
||||
|
||||
if [ "$changed" -eq 0 ] || git diff --cached --quiet; then
|
||||
echo "All third-party snapshots are up to date."
|
||||
|
|
|
|||
|
|
@ -80,6 +80,18 @@ class ThirdpartySkillsPipelineTests(unittest.TestCase):
|
|||
self.assertTrue((UI_UX_PRO_MAX_DIR / "data").is_dir())
|
||||
self.assertTrue((UI_UX_PRO_MAX_DIR / "scripts").is_dir())
|
||||
|
||||
def test_update_script_materializes_manifest_before_target_checkout(self):
|
||||
text = UPDATE_SCRIPT.read_text(encoding="utf-8")
|
||||
self.assertIn('manifest_copy="$tmp_dir/thirdparty_skills.json"', text)
|
||||
self.assertIn('cp "$MANIFEST_PATH" "$manifest_copy"', text)
|
||||
self.assertIn('MANIFEST_PATH="$manifest_copy"', text)
|
||||
self.assertIn('if ! emit_sources_tsv > "$sources_file"; then', text)
|
||||
self.assertNotIn("done < <(emit_sources_tsv)", text)
|
||||
self.assertLess(
|
||||
text.index('cp "$MANIFEST_PATH" "$manifest_copy"'),
|
||||
text.index('git checkout -B "$TARGET_BRANCH" "origin/$TARGET_BRANCH"'),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Reference in New Issue