From 19d43a1cc3f69b35d634d9d3efaaf6008a52cf4a Mon Sep 17 00:00:00 2001 From: Ziya Yesilbahce Date: Sat, 21 Nov 2026 00:58:49 +0300 Subject: [PATCH] feat(ui): kompakt ust cubuk, sade koruma/MCP pencereleri; fix: bitmemis CI'da merge hatasi Turkce + otomatik CI-bitince kosusu --- CHANGELOG.md | 7 +++ internal/gitengine/gh_stub_test.go | 15 ++++++ internal/gitengine/live_mutations.go | 9 ++++ tests/e2e/smoke.mjs | 3 +- tests/js/protection.test.mjs | 15 +++++- web/app.js | 10 ++++ web/index.html | 69 ++++++++++++++++++---------- web/modules/protection.js | 47 +++++++++++++++++-- web/modules/state.js | 3 +- web/tasarim.css | 35 +++++++++++++- 10 files changed, 182 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 410cb7b..92fe6f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ Bu proje [Keep a Changelog](https://keepachangelog.com/tr/1.0.0/) biçimini ve S ## [Yayımlanmamış] +### Değişenler +- **Üst çubuk kompakt:** Başlık `GitArc` (Arc yeşil, "SVG" kaldırıldı); sürüm rozeti başlığın altına taşındı; `Proje Ekle`, `Birleşmiş Paraboller`, `Tur` kısaltıldı: 1280 px'te sığar. +- **Koruma ve MCP pencereleri sadeleşti:** Koruma: "1 · Şu an (✓/– kontrol listesi) → 2 · Profil (önerilen işaretli) → 3 · Değişecekler" + kısa açıklama (`currentRows`). MCP: 1 · yapılandırmayı ekle, 2 · araçlar üç grupta (okuma, güvenli yazma, uzağa yazan KAPALI olanlar ve açan ortam değişkeni). + +### Düzeltilenler +- **Bitmemiş zorunlu CI ile Merge hep ham İngilizce `--auto/--admin` hatası veriyordu:** GitHub, korumalı dalda zorunlu kontrol bitmeden birleştirmeyi reddedince (`base branch policy prohibits the merge`) artık açıklayıcı Türkçe hata gelir ve arayüz çıkmaz sokak yerine 1 PR'lık "CI bitince merge et" koşusunu otomatik başlatır. `--admin` hiçbir yerde kullanılmaz. + ### Değişenler - **"⏳ CI Bitince Merge Et" artık sunucuda 1 PR'lık koşu (`startSingleMergeRun`):** Bekçi sekme belleğinde (`pendingAutoMerge`) duruyordu; sayfa yenilenince kayboluyor, geride kalan PR'ı güncellemiyordu. Çevrimiçi modda tıklama `/api/queue/run/plan` + `/start` ile 1 PR'lık koşu başlatır (güncelle → CI bekle → birleştir; yenilemede sürer, ikinci tıklama koşuyu durdurur, kart etiketi kuyrukla aynı). Çevrimdışı yedek eski sekme bekçisini korur. Duman testi güncellendi. diff --git a/internal/gitengine/gh_stub_test.go b/internal/gitengine/gh_stub_test.go index f17532e..78bf38d 100644 --- a/internal/gitengine/gh_stub_test.go +++ b/internal/gitengine/gh_stub_test.go @@ -330,6 +330,21 @@ func TestMergeBranchLiveBlocksOnFailingCIAndSurfacesGHError(t *testing.T) { } } +// Korumalı dalda zorunlu kontrol bitmeden merge: ham `--auto/--admin` metni sızmaz, "CI Bitince Merge Et"e yönlendirilir. +func TestMergeBlockedByPolicyGivesActionableTurkishError(t *testing.T) { + gh := newGHStub(t) + mgr, _ := prSetup(t, gh, "feat/policy") + gh.set("pr_merge", "X Pull request o/r#7 is not mergeable: the base branch policy prohibits the merge. To have the pull request merged after all the requirements have been met, add the `--auto` flag. To use administrator privileges to immediately merge the pull request, add the `--admin` flag.", 1) + _, err := mgr.MergeBranch("feat/policy", "merge") + if err == nil { + t.Fatal("merge must fail") + } + msg := err.Error() + if !strings.Contains(msg, "CI Bitince Merge Et") || strings.Contains(msg, "--admin") || strings.Contains(msg, "--auto") { + t.Fatalf("error must be actionable Turkish without raw gh flags: %s", msg) + } +} + func TestUpdatePRMetaLiveCallsGHEdit(t *testing.T) { gh := newGHStub(t) mgr, _ := prSetup(t, gh, "feat/edit") diff --git a/internal/gitengine/live_mutations.go b/internal/gitengine/live_mutations.go index f6ab242..bafe4d5 100644 --- a/internal/gitengine/live_mutations.go +++ b/internal/gitengine/live_mutations.go @@ -331,6 +331,9 @@ func (m *Manager) mergeBranchLive(live *repoEntry, branchID, strategy string) (m if isBehindMergeError(out) { return model.CockpitSnapshot{}, fmt.Errorf("PR #%d birleştirilemedi: dal %s dalının gerisinde kaldı (korumada \"dal güncel olmalı\" açık). Önce \"↻ Güncelle & Birleştir\" ile dalı güncelleyin; hiçbir şey değiştirilmedi", b.PR.Number, defBranch) } + if isPolicyBlockedMergeError(out) { + return model.CockpitSnapshot{}, fmt.Errorf("PR #%d şu an birleştirilemiyor: %s dalının koruma kuralı engelliyor (zorunlu CI kontrolü henüz bitmemiş/geçmemiş ya da onay eksik olabilir). \"⏳ CI Bitince Merge Et\" ile kontroller yeşil olunca otomatik birleşmesini sağlayın; hiçbir şey değiştirilmedi", b.PR.Number, defBranch) + } return model.CockpitSnapshot{}, fmt.Errorf("PR #%d merge edilemedi: %s", b.PR.Number, strings.TrimSpace(out)) } syncDefaultBranchNonDestructive(ctx, live.path, defBranch) @@ -648,6 +651,12 @@ func (m *Manager) GetDiffStat() (model.DiffStat, error) { return m.getDiffStatSimLocked(), nil } +// isPolicyBlockedMergeError: `gh pr merge` çıktısı "dal koruma kuralı birleştirmeyi engelliyor" reddi mi (bitmemiş zorunlu CI, eksik +// onay...)? Ham metin `--auto` / `--admin` önerir; GitArc'ta doğru yol "CI Bitince Merge Et"tir, `--admin` hiçbir yerde kullanılmaz. +func isPolicyBlockedMergeError(out string) bool { + return strings.Contains(strings.ToLower(out), "base branch policy prohibits the merge") +} + // isBehindMergeError: `gh pr merge` çıktısı "dal ana dala göre güncel değil" reddi mi? (Ham GitHub/CLI metni kullanıcıya sızdırılmaz.) func isBehindMergeError(out string) bool { o := strings.ToLower(out) diff --git a/tests/e2e/smoke.mjs b/tests/e2e/smoke.mjs index b968fab..6e07ccc 100644 --- a/tests/e2e/smoke.mjs +++ b/tests/e2e/smoke.mjs @@ -61,7 +61,7 @@ try { await step('MCP penceresi açılır ve kapanır', async () => { await click('#btn-mcp-connect'); await expect(visible('#mcp-connect-modal'), 'MCP penceresi açılmadı'); - await expect(`document.getElementById('mcp-connect-modal').textContent.includes('gitarc_protection_apply') && document.getElementById('mcp-connect-modal').textContent.includes('22 Araç')`, 'MCP penceresi koruma araçlarını/16 araç sayısını göstermiyor'); + await expect(`document.getElementById('mcp-connect-modal').textContent.includes('gitarc_protection_apply') && document.getElementById('mcp-connect-modal').textContent.includes('Araçlar (22)') && document.getElementById('mcp-connect-modal').textContent.includes('varsayılan KAPALI')`, 'MCP penceresi koruma araçlarını/22 araç sayısını/kapalı grubu göstermiyor'); await click('#mcp-close'); await expect(hidden('#mcp-connect-modal'), 'MCP penceresi kapanmadı'); }); @@ -180,6 +180,7 @@ try { await click('#btn-protect-branch'); await expect(visible('#security-update-modal'), 'Koruma penceresi açılmadı'); await expect(`document.querySelectorAll('#prot-changes li').length > 0`, 'plan satırları görünmüyor'); + await expect(`document.querySelectorAll('#prot-now .prot-now-row').length >= 5`, '"Şu an" kontrol listesi görünmüyor'); await click('input[name="prot-profile"][value="temel"]'); // Düğme plan gelene kadar gizlidir: GÖRÜNÜR olmasını beklemek, "Temel" planının geldiğinin kanıtıdır (önceki profilin // eski düğmesine tıklayıp yarışa girmeyelim). diff --git a/tests/js/protection.test.mjs b/tests/js/protection.test.mjs index f8637da..8b2dfab 100644 --- a/tests/js/protection.test.mjs +++ b/tests/js/protection.test.mjs @@ -5,7 +5,7 @@ import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import vm from 'node:vm'; -import { changeRows, canApplyPlan, applyLabel, PROTECTION_PROFILES } from '../../web/modules/protection.js'; +import { changeRows, canApplyPlan, applyLabel, currentRows, PROTECTION_PROFILES } from '../../web/modules/protection.js'; function loadEngine() { const ctx = { window: {}, console }; @@ -78,3 +78,16 @@ test('window model: rows, apply gating and label', () => { assert.equal(applyLabel(plan), '🛡️ 1 Değişikliği Uygula'); assert.equal(applyLabel({ ...plan, changes: [] }), '🛡️ Değişecek Bir Şey Yok'); }); + +test('currentRows: "şu an" listesi korumanın bugünkü hâlini sade satırlara çevirir', () => { + assert.deepEqual(currentRows(null), []); + const rows = currentRows({ current: { requirePR: true, approvals: 0, strictUpToDate: true, checks: ['test'], blockForcePush: true, blockDeletion: false, enforceAdmins: false } }); + const by = Object.fromEntries(rows.map((r) => [r.label, r])); + assert.equal(by['PR olmadan push yok'].on, true); + assert.equal(by['CI kontrolleri geçmeden merge yok'].value, 'test'); + assert.equal(by['Dal main\'e göre güncel olmalı'].on, true); + assert.equal(by['Gereken onay sayısı'].on, false); + assert.equal(by['Dal silme engelli'].on, false); + const none = currentRows({ current: { checks: [] } }); + assert.equal(none.find((r) => r.label.startsWith('CI kontrolleri')).value, 'zorunlu kontrol yok'); +}); diff --git a/web/app.js b/web/app.js index cee0a74..cfddea9 100644 --- a/web/app.js +++ b/web/app.js @@ -151,6 +151,16 @@ async function handleMergeBranch(branchId, btnEl = null) { showToast(err.message, 'danger'); // Sunucu "dal main'in gerisinde" diyorsa (kural arayüzce bilinmiyordu: ruleset/okunamadı) çıkmaz sokakta bırakma: aynı planı aç. if (/gerisinde kaldı/.test(err.message || '')) openQueueModal(applySnapshot, { only: branchId, autoPlan: true }); + // Koruma kuralı (bitmemiş zorunlu CI) engelledi: çıkmaz sokak yerine güvenli ön adım — CI bitince birleştiren 1 PR'lık koşu. + else if (!state.offlineMode && /koruma kuralı engelliyor/.test(err.message || '')) { + try { + const res = await startSingleMergeRun(branchId); + if (res.started) { + showToast(`⏳ '${b?.name}' için kontroller bitince otomatik birleştirilecek (sunucu koşusu)`, 'warn'); + applySnapshot(await apiCall('/api/snapshot')); + } + } catch { /* koşu başlatılamadı: yukarıdaki açıklayıcı hata zaten gösterildi */ } + } } }); } diff --git a/web/index.html b/web/index.html index c1f917c..091ec82 100644 --- a/web/index.html +++ b/web/index.html @@ -18,15 +18,18 @@
- GitArc SVG - Parabolik Topoloji + GitArc + + + Parabolik Topoloji +
- +
@@ -39,17 +42,16 @@
-
@@ -412,22 +414,38 @@

🔍 Kod Değişikl