Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Bu proje [Keep a Changelog](https://keepachangelog.com/tr/1.0.0/) biçimini ve S
- **README görselleri yenilendi:** Tüm ekran görüntüleri güncel arayüzle (demo verisiyle) yeniden çekildi ve tarayıcı penceresi çerçevesine alınmış tek dosyalık SVG oldu (`scripts/ekran-cercevesi.py`; çekim: `tests/e2e/ekran-goruntuleri.mjs`). Eski `.webp` görüntüler kişisel tarayıcı sekmelerini/yer imlerini gösteriyordu; kaldırıldı. Merge Kuyruğu, Dal koruması ve MCP pencereleri için yeni görseller; "Kuyrukta biri kırmızı yandı" senaryosu eklendi.

### Düzeltilenler
- **20'den fazla açık PR sessizce görünmez oluyordu:** açık PR listesi `--limit 20` ile okunur (büyük depolarda yavaşlamasın) ama sınıra dayanınca bunu kimse söylemiyordu. Artık sınıra dayanırsa `RepoMeta.openPRsTruncated` ile bildirilir ve Merge Kuyruğu penceresi "yalnızca ilk 20 açık PR okunuyor" notunu gösterir (sınır `openPRListLimit` sabitinde, gh'ye aynı sabitle verilir).
- **Taze depo (hiç commit/dal yok) için sınama:** `git init` ile açılan boş depoda anlık görüntü/kuyruk planı hata vermez ve "proje yok"a düşmez; motor testi ve tarayıcı duman testi (`taze depo çökmeden açılır`) eklendi.
- **MCP `gitarc_cleanup_candidates` var olmayan dalları aday sayıyor ve `release/*` için silme öneriyordu:** 13 adayın 10'u ne yerelde ne uzakta olan, yalnızca PR geçmişinden gelen adlardı (`suggestedCmd` boş), ve `release/0.10.0` için `git branch -D` önerilmişti (araç arayüzün tek kuralı `IsPrunable`'ı kullanmıyor, kendi koşulunu yazmıştı). Artık aday = `Prunable` ve dal gerçekten var; PR geçmişi adları `historyOnlyIgnored` olarak sayılır; aday yoksa `count: 0`, `candidates: []`.
- **MCP `gitarc_protection_status` Ruleset'li depoda içi boş döndürüyordu:** dala uygulanan Ruleset kuralları artık salt okunur okunur (`rules/branches/<dal>`: zorunlu CI, PR/onay, force-push, silme; `source: ruleset`). Okunamayan ya da korumasız durumda sıfır değerli `current` (`checks: null`) yerine `current: null` + `reason` döner ("korumasız" ile "okunamadı" ayrı). Koruma penceresindeki "Şu an" listesi de Ruleset'li depolarda artık gerçek kuralları gösterir.
- **MCP `gitarc_audit_log` proje belirsizdi:** her kayıt `repoId` + `repoName` taşır; varsayılan yalnızca seçili proje, `repoId="all"` ile tümü; projesi bilinmeyen eski kayıtlar varsayılanda gizli (sayısı `hiddenUnknownRepo`), yalnızca `all` ile "bilinmiyor" görünür.
Expand Down
7 changes: 6 additions & 1 deletion e2e_smoke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@ func TestBrowserSmoke(t *testing.T) {
gitRun(t, repo, "branch", "-D", "feat/x")
liveURL := serveApp(t, gitengine.NewManager(repo))

// 4) Taze depo: hiç commit'i/dalı olmayan `git init` (çökmemeli, "proje yok"a da düşmemeli).
fresh := t.TempDir()
gitRun(t, fresh, "init", "-q", "-b", "main")
freshURL := serveApp(t, gitengine.NewManager(fresh))

ctx, cancel := context.WithTimeout(context.Background(), 150*time.Second)
defer cancel()
cmd := exec.CommandContext(ctx, node, filepath.Join(old, "tests", "e2e", "smoke.mjs"), noneURL, simURL, liveURL)
cmd := exec.CommandContext(ctx, node, filepath.Join(old, "tests", "e2e", "smoke.mjs"), noneURL, simURL, liveURL, freshURL)
cmd.Dir = old
out, err := cmd.CombinedOutput()
if ee, ok := err.(*exec.ExitError); ok && ee.ExitCode() == 77 {
Expand Down
1 change: 1 addition & 0 deletions internal/gitengine/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ func CollectLiveRepo(repoID, repoName, repoPath string, repos []model.RepoOption
BranchProtected: protectionState == "active",
StrictUpToDate: protectionIsStrict(protectionSummary) || rulesetStrict,
RequiredChecks: reqChecks,
OpenPRsTruncated: openPRsTruncatedFor(repoPath),
ProtectionState: protectionState,
ProtectionSummary: protectionSummary,
MainCI: mainCIFor(repoPath),
Expand Down
16 changes: 15 additions & 1 deletion internal/gitengine/collector_github.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ var (
)

// ghData, GitHub'dan alınan son başarılı sonuçlardır (bayat gösterim için saklanır).
// openPRListLimit: tek seferde okunan açık PR sayısı (büyük depolarda yavaşlamasın). Sınıra dayanırsa kullanıcıya SÖYLENİR (RepoMeta.OpenPRsTruncated);
// aksi halde fazlası sessizce görünmez olurdu.
const openPRListLimit = 20

type ghData struct {
openPRs map[string]model.PRStatus
mergedPRs map[string]model.PRStatus
Expand All @@ -46,6 +50,7 @@ type ghData struct {
protectionState string
protectionSummary string
mainCI *model.MainCIStatus
openPRsTruncated bool // açık PR listesi sınıra dayandı
requiredChecks []string // zorunlu CI kontrol adları (Ruleset + klasik); okunamazsa önceki değer korunur
rulesetStrict bool // Ruleset "dal güncel olmalı" (strict_required_status_checks_policy)
}
Expand Down Expand Up @@ -405,6 +410,7 @@ func (st *repoBG) refreshGH(repoPath, defaultBranch string, nodes []model.Commit

if apply("prs", prErr, dPR, len(prs)) {
st.data.openPRs = prs
st.data.openPRsTruncated = len(prs) >= openPRListLimit
st.haveData = true
}
if apply("merged", mErr, dMerged, len(merged)) {
Expand Down Expand Up @@ -575,6 +581,14 @@ func fetchRequiredChecks(ctx context.Context, repoPath, branch string) (checks [
return checks, strict, ok
}

// openPRsTruncatedFor: açık PR listesi sınıra dayandı mı (son başarılı okuma).
func openPRsTruncatedFor(repoPath string) bool {
st := bgFor(repoPath)
st.mu.Lock()
defer st.mu.Unlock()
return st.data.openPRsTruncated
}

// requiredChecksFor / rulesetStrictFor: son bilinen zorunlu kontroller (anlık görüntüye girer).
func requiredChecksFor(repoPath string) ([]string, bool) {
st := bgFor(repoPath)
Expand Down Expand Up @@ -674,7 +688,7 @@ func fetchGHPRs(ctx context.Context, repoPath string) (map[string]model.PRStatus
}
ghCtx, cancel := context.WithTimeout(ctx, ghPRTimeout)
defer cancel()
out, _, err := runCmd(ghCtx, repoPath, "gh", "pr", "list", "--state", "open", "--limit", "20",
out, _, err := runCmd(ghCtx, repoPath, "gh", "pr", "list", "--state", "open", "--limit", strconv.Itoa(openPRListLimit),
"--json", "number,headRefName,title,body,author,reviewDecision,statusCheckRollup,url")
if err != nil {
return res, fmt.Errorf("gh pr list: %s", shortErr(out, err))
Expand Down
85 changes: 85 additions & 0 deletions internal/gitengine/fresh_repo_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package gitengine

import (
"fmt"
"os/exec"
"strings"
"testing"
"time"
)

// Taze depo (hiç commit'i/dalı olmayan `git init`): GitArc çökmemeli ve "proje yok"a düşmemeli; boş ama geçerli bir canlı depo gösterir.
func TestSnapshotOfFreshEmptyRepoDoesNotFail(t *testing.T) {
dir := t.TempDir()
if out, err := exec.Command("git", "-C", dir, "init", "-q", "-b", "main").CombinedOutput(); err != nil {
t.Skipf("git init: %v %s", err, out)
}
mgr := NewManager(dir)
if mgr.NoProject() {
t.Fatal("taze depo 'proje yok' sayılmamalı")
}
snap, err := mgr.Snapshot()
if err != nil {
t.Fatalf("taze depoda anlık görüntü hata vermemeli: %v", err)
}
if snap.Repo.Mode != "live" || snap.Repo.DefaultBranch != "main" {
t.Fatalf("canlı mod ve omurga 'main' beklenirdi: %+v", snap.Repo)
}
if len(snap.Branches) != 0 {
t.Fatalf("hiç dal yok: %d", len(snap.Branches))
}
// Kuyruk planı da boş depoda hata vermeden "aday yok" demeli.
if _, err := mgr.QueuePlan(nil); err != nil {
t.Fatalf("boş depoda kuyruk planı hata vermemeli: %v", err)
}
}

// Açık PR listesi sınıra (openPRListLimit) dayandıysa bu SÖYLENİR; aksi halde 20'den fazla açık PR sessizce görünmez olurdu.
func TestOpenPRListHitsLimitIsReportedAndLimitIsPassedToGH(t *testing.T) {
gh := newGHStub(t)
dir, _ := newGitHubLikeRepo(t)
var items []string
for i := 1; i <= openPRListLimit; i++ {
items = append(items, fmt.Sprintf(`{"number":%d,"headRefName":"feat/b%d","title":"t%d","body":"","author":{"login":"u"},"reviewDecision":"","statusCheckRollup":[],"url":"https://github.com/acme/demo/pull/%d"}`, i, i, i, i))
}
gh.set("pr_list_open", "["+strings.Join(items, ",")+"]", 0)

mgr := NewManager(dir)
if _, err := mgr.SwitchRepo("live-custom"); err != nil {
t.Fatal(err)
}
var truncated bool
for i := 0; i < 25 && !truncated; i++ {
snap, err := mgr.Snapshot()
if err != nil {
t.Fatal(err)
}
truncated = snap.Repo.OpenPRsTruncated
if !truncated {
time.Sleep(200 * time.Millisecond)
}
}
if !truncated {
t.Fatal("liste sınıra dayandı: openPRsTruncated true olmalı")
}
if !gh.called("pr list", "--state open", fmt.Sprintf("--limit %d", openPRListLimit)) {
t.Fatalf("sınır gh'ye bu sabitle verilmeli: %v", gh.calls())
}

// Sınırın altında: uyarı yok.
gh2 := newGHStub(t)
dir2, _ := newGitHubLikeRepo(t)
gh2.set("pr_list_open", "["+items[0]+"]", 0)
mgr2 := NewManager(dir2)
if _, err := mgr2.SwitchRepo("live-custom"); err != nil {
t.Fatal(err)
}
time.Sleep(1500 * time.Millisecond)
snap2, err := mgr2.Snapshot()
if err != nil {
t.Fatal(err)
}
if snap2.Repo.OpenPRsTruncated {
t.Fatal("tek açık PR: kesilme uyarısı olmamalı")
}
}
2 changes: 2 additions & 0 deletions internal/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ type RepoMeta struct {
// RequiredChecks: varsayılan dalda birleştirmek için GEÇMESİ ZORUNLU CI kontrol adları (Ruleset + klasik koruma; salt okunur). Boş = zorunlu kontrol yok
// ya da okunamadı. Bir PR'ın CI durumu henüz yokken (GitHub kontrolleri birkaç sn geç açar) düz "Merge" yerine "CI bitince" sunmak için kullanılır.
RequiredChecks []string `json:"requiredChecks,omitempty"`
// OpenPRsTruncated: açık PR listesi sınıra (openPRListLimit) dayandı; daha fazla açık PR olabilir ve kuyruk/kartlarda görünmeyebilir.
OpenPRsTruncated bool `json:"openPRsTruncated,omitempty"`
// BaseCandidates: omurga olarak seçilebilecek yerel dallar (yalnızca canlı depoda dolu).
BaseCandidates []string `json:"baseCandidates,omitempty"`
RemoteName string `json:"remoteName"`
Expand Down
15 changes: 13 additions & 2 deletions tests/e2e/smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// tıklama yakalar. Kullanım: node tests/e2e/smoke.mjs <proje-yok-url> <demo-url> <canlı-url>. Çıkış: 0 geçti, 1 kaldı, 77 atlandı.
import { launch } from './cdp.mjs';

const [noneUrl, simUrl, liveUrl] = process.argv.slice(2);
if (!noneUrl || !simUrl || !liveUrl) { console.error('kullanım: smoke.mjs <none> <sim> <live>'); process.exit(2); }
const [noneUrl, simUrl, liveUrl, freshUrl] = process.argv.slice(2); // freshUrl isteğe bağlı: hiç commit'i/dalı olmayan taze depo
if (!noneUrl || !simUrl || !liveUrl) { console.error('kullanım: smoke.mjs <none> <sim> <live> [fresh]'); process.exit(2); }

const t00 = Date.now();
const b = await launch();
Expand Down Expand Up @@ -261,6 +261,17 @@ try {
await click('#diff-modal-close');
});
await step('konsolda hata yok', async () => noConsoleErrors());
if (freshUrl) {
console.log('Taze depo (hiç commit/dal yok):');
await b.goto(freshUrl);
await step('taze depo çökmeden açılır: canlı depo, proje-yok paneli yok, kapsül yok, konsolda hata yok', async () => {
await expect(`!document.body.classList.contains('no-project')`, 'taze depo "proje yok" sayıldı');
await expect(`!!document.querySelector('#rail-svg') && document.querySelectorAll('#rail-svg .fo-capsule').length === 0`, 'taze depoda tuval çizilmedi ya da olmayan kapsül var');
await expect(`document.getElementById('kpi-pills').children.length > 0`, 'KPI şeridi boş: arayüz yüklenmedi');
await expect(hidden('#demo-banner'), 'taze depoda demo şeridi görünmemeli');
noConsoleErrors();
});
}
} finally {
b.close();
}
Expand Down
8 changes: 8 additions & 0 deletions tests/js/ci-pending.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,11 @@ test('projectSwitchWarning: koşu yoksa null; koşu sürüyorsa ilerlemeyi ve "y
assert.match(w, /DURUR ve yarım kalabilir/);
assert.match(w, /Yine de projeyi değiştirmek istiyor musunuz\?/);
});

import { openPRsTruncationNote } from '../../web/modules/queue.js';

test('openPRsTruncationNote: liste sınıra dayandıysa söyler, yoksa boş', () => {
assert.equal(openPRsTruncationNote(null), '');
assert.equal(openPRsTruncationNote({ repo: {} }), '');
assert.match(openPRsTruncationNote({ repo: { openPRsTruncated: true } }), /yalnızca ilk 20 açık PR/);
});
9 changes: 9 additions & 0 deletions web/modules/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,20 @@ function appendText(parent, tag, text, cls) {
return n;
}

/** Açık PR listesi sınıra dayandıysa kuyruk penceresinde uyarı metni (yoksa ""): fazlası burada görünmeyebilir, sessizce eksik kalmasın. */
export function openPRsTruncationNote(snap) {
return snap?.repo?.openPRsTruncated
? 'Not: GitHub\'dan yalnızca ilk 20 açık PR okunuyor; daha fazla açık PR varsa burada görünmeyebilir. Birleşenler kuyruktan kalkınca kalanlar listelenir.'
: '';
}

function renderCandidates() {
const box = el.queueCandidates;
if (!box) return;
box.textContent = '';
const byId = Object.fromEntries(queueCandidates(state.snapshot).map((b) => [b.id, b]));
const truncNote = openPRsTruncationNote(state.snapshot);
if (truncNote) appendText(box, 'div', truncNote, 'prot-note');
if (!view.order.length) {
appendText(box, 'div', 'Kuyruğa girecek açık PR yok.', 'prot-note');
return;
Expand Down
Loading