Jaypore CI

> Jaypore CI: Minimal, Offline, Local CI system.
Log | Files | Refs | README | LICENSE

commit dc5b93ba25c5fc55a8d9061c132d310e6bd91ccd
parent 87072a6aa1e230cf0443521845fdab924cc60cc4
Author: Arjoonn@exe.dev <arjoonn+exe.dev@midpathsoftware.com>
Date:   Wed, 25 Feb 2026 06:44:29 +0000

Optimize push to only push new CI results

- Skip refs that already exist on the remote
- Show count of new results being pushed
- Print each ref as it's pushed

Co-authored-by: Shelley <shelley@exe.dev>

Diffstat:
Minternal/jci/push.go | 59++++++++++++++++++++++++++++++++++++++++++++++++++++-------
Minternal/jci/web.go | 23-----------------------
2 files changed, 52 insertions(+), 30 deletions(-)

diff --git a/internal/jci/push.go b/internal/jci/push.go @@ -2,6 +2,7 @@ package jci import ( "fmt" + "strings" ) // Push pushes CI results to remote @@ -11,24 +12,68 @@ func Push(args []string) error { remote = args[0] } - refs, err := ListJCIRefs() + // Get local refs + localRefs, err := ListJCIRefs() if err != nil { return err } - if len(refs) == 0 { + if len(localRefs) == 0 { fmt.Println("No CI results to push") return nil } - fmt.Printf("Pushing %d CI result(s) to %s...\n", len(refs), remote) + // Get remote refs to find what's already pushed + remoteRefs := getRemoteJCIRefs(remote) - // Push all refs/jci/* to remote - _, err = git("push", remote, "refs/jci/*:refs/jci/*") - if err != nil { - return err + // Find refs that need to be pushed + var toPush []string + for _, ref := range localRefs { + commit := strings.TrimPrefix(ref, "jci/") + if !remoteRefs[commit] { + toPush = append(toPush, "refs/jci/"+commit) + } + } + + if len(toPush) == 0 { + fmt.Println("All CI results already pushed") + return nil + } + + fmt.Printf("Pushing %d new CI result(s) to %s...\n", len(toPush), remote) + + // Push each ref individually + for _, ref := range toPush { + _, err = git("push", remote, ref+":"+ref) + if err != nil { + return fmt.Errorf("failed to push %s: %w", ref, err) + } + fmt.Printf(" %s\n", ref) } fmt.Println("Done") return nil } + +// getRemoteJCIRefs returns a set of commits that have CI refs on the remote +func getRemoteJCIRefs(remote string) map[string]bool { + remoteCI := make(map[string]bool) + + out, err := git("ls-remote", "--refs", remote, "refs/jci/*") + if err != nil { + return remoteCI + } + if out == "" { + return remoteCI + } + + for _, line := range strings.Split(out, "\n") { + parts := strings.Fields(line) + if len(parts) >= 2 { + ref := parts[1] + commit := strings.TrimPrefix(ref, "refs/jci/") + remoteCI[commit] = true + } + } + return remoteCI +} diff --git a/internal/jci/web.go b/internal/jci/web.go @@ -98,29 +98,6 @@ func getLocalBranches() ([]string, error) { } // getRemoteJCIRefs returns a set of commits that have CI refs pushed to remote -func getRemoteJCIRefs(remote string) map[string]bool { - remoteCI := make(map[string]bool) - - // Get remote JCI refs - out, err := git("ls-remote", "--refs", remote, "refs/jci/*") - if err != nil { - return remoteCI - } - if out == "" { - return remoteCI - } - - for _, line := range strings.Split(out, "\n") { - parts := strings.Fields(line) - if len(parts) >= 2 { - // refs/jci/<commit> -> <commit> - ref := parts[1] - commit := strings.TrimPrefix(ref, "refs/jci/") - remoteCI[commit] = true - } - } - return remoteCI -} // getBranchCommits returns recent commits for a branch func getBranchCommits(branch string, limit int) ([]CommitInfo, error) {