Webhook: nach Umzug Repo-Adresse aus dem aktuellen Namen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a5da4849e5
commit
ed8c0f82d5
2 files changed
+18
-5
No files matched your search
@@ -100,19 +100,27 @@ router.post('/gitea', async (req, res) => {
|
||||
}
|
||||
|
||||
// Phase 3: Dokument unter derselben Repo-Sperre wie Import/Umzug anlegen/aktualisieren.
|
||||
// Namen dabei ERNEUT aufloesen - deckt einen Umzug ab, der waehrend des (unter Sperre
|
||||
// laufenden) Deploys oben passiert ist. `current` ab hier fuer alle weiteren Schritte.
|
||||
// Namen dabei ERNEUT aufloesen - deckt einen Umzug ab, der waehrend des Deploys oben (ohne
|
||||
// gehaltene Sperre) passiert ist. `current` ab hier fuer alle weiteren Schritte.
|
||||
let current
|
||||
const project = await withLocks(
|
||||
[repoLockKey(name)],
|
||||
async () => {
|
||||
current = await currentRepoFullName(name)
|
||||
|
||||
// Ein spaet zugestellter Webhook (z. B. nach einem Umzug) traegt noch den ALTEN
|
||||
// Repo-Namen in repo.html_url/repo.name - diese Payload-Felder duerfen das Dokument
|
||||
// dann nicht ueberschreiben, sonst zeigt es mit repoFullName=current trotzdem auf die
|
||||
// alte URL (Fix-Runde 1). Nur wenn `payloadName` noch zu `current` passt, gelten sie.
|
||||
const payloadNameStillCurrent = payloadName.toLowerCase() === current.toLowerCase()
|
||||
|
||||
const projectPayload = {
|
||||
projectName: previewConfig.displayName || repo.name || subdomain,
|
||||
projectName: previewConfig.displayName || (payloadNameStillCurrent ? repo.name : '') || subdomain,
|
||||
templateName: previewConfig.templateName || config.gitea.templateRepo,
|
||||
giteaRepoUrl: repo.html_url || `${config.gitea.baseUrl}/${current}`,
|
||||
giteaRepoName: repo.name || subdomain,
|
||||
giteaRepoUrl: payloadNameStillCurrent
|
||||
? repo.html_url || `${config.gitea.baseUrl}/${current}`
|
||||
: `${config.gitea.baseUrl}/${current}`,
|
||||
giteaRepoName: payloadNameStillCurrent ? repo.name || subdomain : current.split('/').pop(),
|
||||
repoFullName: current,
|
||||
}
|
||||
|
||||
|
||||
@@ -212,6 +212,11 @@ test('Webhook nach Umzug mit altem Namen', async () => {
|
||||
assert.equal(r.status, 200)
|
||||
assert.equal(aw.all('websiteProjects').length, docs)
|
||||
assert.ok(aw.all('worksheets').some((w) => w.workorderId === 't1' && w.details.includes('Commit: f00dbee')))
|
||||
// Fix-Runde 1: die veraltete Payload (repo.html_url/repo.name auf den alten Namen) darf die
|
||||
// Repo-Adresse des laengst umgezogenen Dokuments nicht mit dem alten Namen ueberschreiben.
|
||||
const p1 = aw.get('websiteProjects', 'p1')
|
||||
assert.ok(p1.giteaRepoUrl.endsWith('/WEBklar/D-ner-Nation'))
|
||||
assert.equal(p1.giteaRepoName, 'D-ner-Nation')
|
||||
})
|
||||
test('Webhook des System-Kontos', async () => {
|
||||
const before = aw.all('worksheets').length
|
||||
|
||||
Reference in new issue
Block a user