CI Pipeline with Test Management / 🧪 Run Tests & Generate Reports (push) Waiting to run
CI Pipeline with Test Management / 🐳 Docker Integration Tests (push) Blocked by required conditions
CI Pipeline with Test Management / 🏗️ Build Docker Image (push) Blocked by required conditions
CI Pipeline with Test Management / 📊 Generate Test Summary (push) Blocked by required conditions
Test Reporting & Gherkin Analysis / 🧪 Run Tests & Generate Reports (push) Waiting to run
Test Reporting & Gherkin Analysis / 📊 Analyze Test Coverage (push) Blocked by required conditions
Test Reporting & Gherkin Analysis / 🔄 Sync with Linear (push) Blocked by required conditions
Test Reporting & Gherkin Analysis / ⚡ Performance Monitoring (push) Blocked by required conditions
Review follow-up on MITHOME-59:
- no-op publish no longer triggers a background deploy (deploy moved behind
a deterministic hadChanges flag)
- replace output-regex classification ('Already up to date.' also appears on
real publishes when the remote did not move, which misclassified them as
no_changes) with an explicit __NO_CONTENT_CHANGES__ marker echoed by the
shell skip-branch
- failed git pull --rebase is aborted immediately so the repo is never left
mid-rebase; the error is reported and nothing is pushed or deployed
- command + interpretation extracted to scripts/cms-publish.js
- CONTENT_EDITOR_CONTENT_DIR / CONTENT_EDITOR_DEPLOY_CMD env overrides enable
an integration test against throwaway git repos covering: no-change skip,
real publish + deploy, rebase conflict abort
- .gitignore: drop patterns already covered by .env.*
- user guide: new no-changes message
Closes MITHOME-60
41 lines
1.7 KiB
JavaScript
41 lines
1.7 KiB
JavaScript
// Publish (git commit + push) command construction and result interpretation
|
|
// for the Content Editor. Extracted so it is unit-testable in isolation.
|
|
//
|
|
// WHY the shell shape:
|
|
// - `git diff --cached --quiet && echo MARKER || git commit` — commit only when
|
|
// staged changes exist; a skipped commit must NOT produce a failing exit code
|
|
// (that was the original bug: "nothing added to commit" surfaced as an error).
|
|
// - the MARKER echo is the only reliable signal for "no content changes": plain
|
|
// output matching ("Already up to date", "Everything up-to-date") also appears
|
|
// after REAL publishes (the pull prints it when the remote did not move), which
|
|
// used to misclassify genuine publishes as no-ops.
|
|
// - `git pull --rebase || (git rebase --abort; false)` — a failed rebase must be
|
|
// aborted, otherwise the repo stays mid-rebase and every later publish fails
|
|
// with "cannot pull with rebase".
|
|
|
|
const NO_CHANGES_MARKER = '__NO_CONTENT_CHANGES__';
|
|
|
|
function buildPublishCommand(commitMessage) {
|
|
return [
|
|
'git add .',
|
|
`(git diff --cached --quiet && echo ${NO_CHANGES_MARKER} || git commit -m "${commitMessage}")`,
|
|
'(git pull --rebase origin main || (git rebase --abort; false))',
|
|
'git push origin main',
|
|
].join(' && ');
|
|
}
|
|
|
|
function interpretPublishResult(error, stdout, stderr) {
|
|
const hadChanges = !stdout.includes(NO_CHANGES_MARKER);
|
|
if (error) {
|
|
return { ok: false, hadChanges, result: 'error', error: stderr || stdout || error.message };
|
|
}
|
|
return {
|
|
ok: true,
|
|
hadChanges,
|
|
result: hadChanges ? 'ok' : 'no_changes',
|
|
output: hadChanges ? stdout : 'Nincs új változtatás.',
|
|
};
|
|
}
|
|
|
|
module.exports = { NO_CHANGES_MARKER, buildPublishCommand, interpretPublishResult };
|