gitlocal

package
v0.129.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package gitlocal implements the Backend interface using the local filesystem with a Git repository for history. Each write operation produces one commit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcquireGitLock added in v0.123.1

func AcquireGitLock(configDir string) error

acquireGitLock spins until it wins an O_EXCL lock file, stealing stale locks from dead processes. Holds the lock for the duration of the git operation. AcquireGitLock is the exported form for use in tests.

func ReleaseGitLock added in v0.123.1

func ReleaseGitLock(configDir string)

ReleaseGitLock is the exported form for use in tests.

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

Backend stores notes as Markdown files in a Git-backed directory. mu serialises add+commit pairs so concurrent goroutines in the same process do not interleave staging. Cross-process isolation is handled by the commit queue.

func New

func New(dir string) (*Backend, error)

New returns a Backend rooted at dir, using the default nn config directory for the commit queue.

func NewWithConfigDir added in v0.123.0

func NewWithConfigDir(dir, configDir string) (*Backend, error)

NewWithConfigDir returns a Backend rooted at dir using configDir for the commit queue. Used in tests to isolate queue state.

func (b *Backend) AddLink(fromID, toID, annotation, linkType, linkStatus string) error

AddLink adds an annotated link from fromID to toID and commits.

func (b *Backend) AddLinks(fromID string, targets []backend.LinkTarget) error

AddLinks adds multiple annotated links from fromID in a single git commit.

func (b *Backend) BulkUpdateLinks(fromID string, updates []backend.LinkUpdate) error

BulkUpdateLinks applies multiple link updates to fromID in a single git commit.

func (*Backend) BulkWrite added in v0.14.0

func (b *Backend) BulkWrite(notes []*note.Note) error

BulkWrite writes all notes and commits in a single commit.

func (*Backend) Delete

func (b *Backend) Delete(id string) error

Delete removes the note file for id and commits the deletion.

func (*Backend) List

func (b *Backend) List() ([]*note.Note, error)

List returns all notes in the notebook directory.

func (*Backend) Promote

func (b *Backend) Promote(id string, to note.Status) error

Promote updates the status of the note with the given id and commits.

func (*Backend) Read

func (b *Backend) Read(id string) (*note.Note, error)

Read finds and parses the note with the given ID.

func (b *Backend) RemoveLink(fromID, toID string) error

RemoveLink removes the link from fromID to toID and commits.

func (*Backend) RemoveLinkByType added in v0.35.1

func (b *Backend) RemoveLinkByType(fromID, toID, linkType string) error

RemoveLinkByType removes only edges from fromID to toID with the given type.

func (*Backend) Update

func (b *Backend) Update(n *note.Note) error

Update writes the modified note and commits with an "update" message.

func (b *Backend) UpdateLink(fromID, toID string, annotation, linkType, linkStatus *string) error

UpdateLink modifies the annotation, type, and/or status of an existing link without removing it. nil pointer arguments mean "leave unchanged".

func (*Backend) Write

func (b *Backend) Write(n *note.Note) error

Write serialises n to a Markdown file and commits it to Git.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL