commit df295981cc6198cc2a9c8a645ece17a55ebc5e06
parent fe176f7c54d7a1b564f693313bebb9a61c7ca292
Author: Arjoonn Sharma <arjoonn@midpathsoftware.com>
Date: Sat, 28 Feb 2026 12:33:20 +0530
x
Diffstat:
4 files changed, 67 insertions(+), 79 deletions(-)
diff --git a/cmd/git-jci/main.go b/cmd/git-jci/main.go
@@ -1,10 +1,10 @@
package main
import (
- "fmt"
- "os"
+ "fmt"
+ "os"
- "github.com/exedev/git-jci/internal/jci"
+ "github.com/exedev/git-jci/internal/jci"
)
// version is set at build time via -ldflags "-X main.version=<version>".
@@ -12,48 +12,48 @@ import (
var version = "dev"
func main() {
- if len(os.Args) < 2 {
- printUsage()
- os.Exit(1)
- }
+ if len(os.Args) < 2 {
+ printUsage()
+ os.Exit(1)
+ }
- cmd := os.Args[1]
- args := os.Args[2:]
+ cmd := os.Args[1]
+ args := os.Args[2:]
- var err error
- switch cmd {
- case "run":
- err = jci.Run(args)
- case "web":
- err = jci.Web(args)
- case "push":
- err = jci.Push(args)
- case "pull":
- err = jci.Pull(args)
- case "prune":
- err = jci.Prune(args)
- case "cron":
- err = jci.Cron(args)
- case "version", "--version", "-v":
- fmt.Println("git-jci version " + version)
- return
- case "help", "-h", "--help":
- printUsage()
- return
- default:
- fmt.Fprintf(os.Stderr, "unknown command: %s\n", cmd)
- printUsage()
- os.Exit(1)
- }
+ var err error
+ switch cmd {
+ case "run":
+ err = jci.Run(args)
+ case "web":
+ err = jci.Web(args)
+ case "push":
+ err = jci.Push(args)
+ case "pull":
+ err = jci.Pull(args)
+ case "prune":
+ err = jci.Prune(args)
+ case "cron":
+ err = jci.Cron(args)
+ case "version", "--version", "-v":
+ fmt.Println("git-jci version " + version)
+ return
+ case "help", "-h", "--help":
+ printUsage()
+ return
+ default:
+ fmt.Fprintf(os.Stderr, "unknown command: %s\n", cmd)
+ printUsage()
+ os.Exit(1)
+ }
- if err != nil {
- fmt.Fprintf(os.Stderr, "error: %v\n", err)
- os.Exit(1)
- }
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "error: %v\n", err)
+ os.Exit(1)
+ }
}
func printUsage() {
- fmt.Printf(`git-jci %s - Local-first CI system stored in git
+ fmt.Printf(`git-jci %s - Local-first CI system stored in git
Usage: git jci <command> [options]
diff --git a/internal/jci/cron.go b/internal/jci/cron.go
@@ -170,11 +170,12 @@ func cronSync() error {
// parseCrontab parses a .jci/crontab file
// Format:
-// # comment
-// SCHEDULE [branch:BRANCH] [name:NAME]
-// 0 * * * * # every hour, current branch
-// 0 0 * * * branch:main # daily at midnight, main branch
-// */15 * * * * name:quick-test # every 15 min
+//
+// # comment
+// SCHEDULE [branch:BRANCH] [name:NAME]
+// 0 * * * * # every hour, current branch
+// 0 0 * * * branch:main # daily at midnight, main branch
+// */15 * * * * name:quick-test # every 15 min
func parseCrontab(path string) ([]CronEntry, error) {
f, err := os.Open(path)
if err != nil {
diff --git a/internal/jci/web.go b/internal/jci/web.go
@@ -19,20 +19,20 @@ type BranchInfo struct {
// CommitInfo holds commit data for the UI
type CommitInfo struct {
- Hash string `json:"hash"`
- ShortHash string `json:"shortHash"`
- Message string `json:"message"`
- HasCI bool `json:"hasCI"`
- CIStatus string `json:"ciStatus"` // "success", "failed", or ""
- CIPushed bool `json:"ciPushed"` // whether CI ref is pushed to remote
- Runs []RunInfo `json:"runs"` // multiple runs (for cron)
+ Hash string `json:"hash"`
+ ShortHash string `json:"shortHash"`
+ Message string `json:"message"`
+ HasCI bool `json:"hasCI"`
+ CIStatus string `json:"ciStatus"` // "success", "failed", or ""
+ CIPushed bool `json:"ciPushed"` // whether CI ref is pushed to remote
+ Runs []RunInfo `json:"runs"` // multiple runs (for cron)
}
// RunInfo holds info about a single CI run
type RunInfo struct {
- RunID string `json:"runId"`
- Status string `json:"status"`
- Ref string `json:"ref"`
+ RunID string `json:"runId"`
+ Status string `json:"status"`
+ Ref string `json:"ref"`
}
// Web starts a web server to view CI results
@@ -217,7 +217,7 @@ func getCIStatusFromRef(ref string) string {
return "running"
}
}
-
+
// Fallback: parse index.html for old results
cmd = exec.Command("git", "show", ref+":index.html")
out, err = cmd.Output()
@@ -236,14 +236,14 @@ func getCIStatusFromRef(ref string) string {
// CommitDetail holds detailed commit info for the API
type CommitDetail struct {
- Hash string `json:"hash"`
- Author string `json:"author"`
- Date string `json:"date"`
- Status string `json:"status"`
- Files []string `json:"files"`
- Ref string `json:"ref"` // The actual ref used
- RunID string `json:"runId"` // Current run ID
- Runs []RunInfo `json:"runs"` // All runs for this commit
+ Hash string `json:"hash"`
+ Author string `json:"author"`
+ Date string `json:"date"`
+ Status string `json:"status"`
+ Files []string `json:"files"`
+ Ref string `json:"ref"` // The actual ref used
+ RunID string `json:"runId"` // Current run ID
+ Runs []RunInfo `json:"runs"` // All runs for this commit
}
// serveCommitAPI returns commit details and file list
diff --git a/scripts/check_go.sh b/scripts/check_go.sh
@@ -11,23 +11,10 @@ if ! command -v go >/dev/null 2>&1; then
fi
echo "Running gofmt checks..."
-mapfile -t GO_FILES < <(git ls-files '*.go')
-if [[ ${#GO_FILES[@]} -eq 0 ]]; then
- echo "No Go files found; skipping Go checks."
- exit 0
-fi
-
-FMT_OUTPUT="$(gofmt -l "${GO_FILES[@]}")"
-if [[ -n "${FMT_OUTPUT}" ]]; then
- echo "The following files need 'gofmt':"
- echo "${FMT_OUTPUT}"
- exit 1
-fi
+gofmt -e cmd
+gofmt -e internal
echo "Running go vet..."
go vet ./...
-echo "Ensuring packages build (without tests)..."
-go build ./...
-
-echo "Go formatting, vet, and build checks passed."
+echo "Go formatting, and vet checks passed."