Artifact f275ff6c93ce380ed6c1e3cad2b9eb5a48ec8695c06b8ef1373788593961a046:
- File
cli/repo_rename.go
— part of check-in
[f5744359d3]
at
2026-04-19 16:30:54
on branch trunk
— Initial open source release
libfossil is a pure-Go implementation of the Fossil SCM, reading and writing the same .fossil SQLite repository format as upstream Fossil.
This is the first public release of code that previously lived in a private repository. The module path is github.com/danmestas/libfossil and the binary is named libfossil to avoid $PATH collisions with upstream fossil.
Included: - Repo lifecycle (create, clone), checkout/checkin, timeline, merge, diff, annotate, shun, tag, branch, bisect, stash, undo/redo - Sync-over-HTTP protocol (client and handler) - Two SQLite drivers: modernc (pure Go, default) and ncruces (wasm-capable) - Observer interfaces (SyncObserver, CheckoutObserver) with an optional OpenTelemetry implementation in observer/otel (separate submodule) - Deterministic simulation testing harness with BUGGIFY fault injection - Kong-based embeddable CLI under cli/ and a standalone binary under cmd/libfossil/ (user: [email protected], size: 1052) [annotate] [blame] [check-ins using]
package cli import "fmt" // RepoRenameCmd renames a tracked file in the checkout. type RepoRenameCmd struct { From string `arg:"" help:"Current file name"` To string `arg:"" help:"New file name"` Dir string `short:"d" help:"Checkout directory" default:"."` } func (c *RepoRenameCmd) Run(g *Globals) error { ckout, err := openCheckout(c.Dir) if err != nil { return err } defer ckout.Close() vid, err := checkoutVid(ckout) if err != nil { return err } var id int64 err = ckout.QueryRow("SELECT id FROM vfile WHERE pathname=? AND vid=?", c.From, vid).Scan(&id) if err != nil { return fmt.Errorf("%s: not tracked in checkout", c.From) } var existing int64 if ckout.QueryRow("SELECT id FROM vfile WHERE pathname=? AND vid=?", c.To, vid).Scan(&existing) == nil { return fmt.Errorf("%s: already tracked in checkout", c.To) } _, err = ckout.Exec("UPDATE vfile SET pathname=?, origname=?, chnged=1 WHERE id=?", c.To, c.From, id) if err != nil { return err } fmt.Printf("RENAMED %s -> %s\n", c.From, c.To) return nil }