config

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConflictMarkerStart  = "<<<<<<< LOCAL"
	ConflictMarkerMiddle = "======="
	ConflictMarkerEnd    = ">>>>>>> REMOTE"
)

ConflictMarkers for merge conflicts

View Source
const MergeStateFile = "MERGE_STATE"

Variables

This section is empty.

Functions

func CreateConflictedFile

func CreateConflictedFile(path string, localContent, remoteContent []byte, remoteName string) error

CreateConflictedFile writes a file with conflict markers

func GlobalConfigPath added in v1.1.0

func GlobalConfigPath() string

GlobalConfigPath returns the path to the global config file Follows XDG Base Directory spec on Linux, platform conventions elsewhere

func HasConflictMarkers

func HasConflictMarkers(path string) (bool, error)

HasConflictMarkers checks if a file contains conflict markers

func ListGlobalKeys added in v1.1.0

func ListGlobalKeys() []string

ListGlobalKeys returns all available global config keys

func MergeStatePath

func MergeStatePath(repoRoot string) string

MergeStatePath returns the path to the merge state file

Types

type Config

type Config struct {
	Core    CoreConfig              `toml:"core"`
	User    UserConfig              `toml:"user"`
	Remotes map[string]RemoteConfig `toml:"remote"`
}

Config represents the .pgit/config.toml file

func DefaultConfig

func DefaultConfig(repoPath string) *Config

DefaultConfig returns a new config with default values

func Load

func Load(repoRoot string) (*Config, error)

Load reads the config file from the repository

func (*Config) GetRemote

func (c *Config) GetRemote(name string) (RemoteConfig, bool)

GetRemote returns a remote config by name

func (*Config) GetUserEmail

func (c *Config) GetUserEmail() string

GetUserEmail returns the user email from config or environment

func (*Config) GetUserName

func (c *Config) GetUserName() string

GetUserName returns the user name from config or environment

func (*Config) RemoveRemote

func (c *Config) RemoveRemote(name string) bool

RemoveRemote removes a remote by name

func (*Config) Save

func (c *Config) Save(repoRoot string) error

Save writes the config file to the repository

func (*Config) SetRemote

func (c *Config) SetRemote(name string, url string)

SetRemote adds or updates a remote

type ContainerConfig added in v1.1.0

type ContainerConfig struct {
	ShmSize string `toml:"shm_size"` // Shared memory size (default: 256m)
	Port    int    `toml:"port"`     // PostgreSQL port (default: 5433)
	Image   string `toml:"image"`    // Custom image (default: ghcr.io/imgajeed76/pg-xpatch:latest)
}

ContainerConfig contains Docker/Podman container settings

type CoreConfig

type CoreConfig struct {
	LocalDB string `toml:"local_db"` // Local database name (e.g., "pgit_a1b2c3d4")
}

CoreConfig contains core repository settings

type FileStatus

type FileStatus string

FileStatus represents the status of a file in the index

const (
	StatusAdded    FileStatus = "A" // New file
	StatusModified FileStatus = "M" // Modified file
	StatusDeleted  FileStatus = "D" // Deleted file
)

type GlobalConfig added in v1.1.0

type GlobalConfig struct {
	Container ContainerConfig `toml:"container"`
	Import    ImportConfig    `toml:"import"`
}

GlobalConfig represents global pgit settings stored in user's config directory These settings affect all repositories and the local container

func DefaultGlobalConfig added in v1.1.0

func DefaultGlobalConfig() *GlobalConfig

DefaultGlobalConfig returns a new global config with default values

func LoadGlobal added in v1.1.0

func LoadGlobal() (*GlobalConfig, error)

LoadGlobal reads the global config file, creating defaults if it doesn't exist

func (*GlobalConfig) GetValue added in v1.1.0

func (c *GlobalConfig) GetValue(key string) (string, bool)

GetGlobalValue returns a global config value by key

func (*GlobalConfig) Save added in v1.1.0

func (c *GlobalConfig) Save() error

Save writes the global config file

func (*GlobalConfig) SetValue added in v1.1.0

func (c *GlobalConfig) SetValue(key, value string) error

SetGlobalValue sets a global config value by key

type IgnorePatterns

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

IgnorePatterns holds the patterns from .gitignore and .pgitignore files

func LoadIgnorePatterns

func LoadIgnorePatterns(repoRoot string) (*IgnorePatterns, error)

LoadIgnorePatterns loads patterns from .gitignore and .pgitignore files

func (*IgnorePatterns) IsIgnored

func (ip *IgnorePatterns) IsIgnored(path string, isDir bool) bool

IsIgnored checks if a path should be ignored

func (*IgnorePatterns) ShouldInclude

func (ip *IgnorePatterns) ShouldInclude(path string, isDir bool) bool

ShouldInclude returns true if a path should be included (not ignored)

type ImportConfig added in v1.1.0

type ImportConfig struct {
	Workers int `toml:"workers"` // Default number of workers (default: CPU count, max 3)
}

ImportConfig contains default import settings

type Index

type Index struct {
	Entries map[string]IndexEntry // path -> entry
}

Index represents the staging area (.pgit/index)

func LoadIndex

func LoadIndex(repoRoot string) (*Index, error)

LoadIndex reads the index file from the repository

func NewIndex

func NewIndex() *Index

NewIndex creates a new empty index

func (*Index) Add

func (idx *Index) Add(path string, isNew bool)

Add stages a file for addition or modification

func (*Index) Clear

func (idx *Index) Clear()

Clear removes all entries from the index

func (*Index) Delete

func (idx *Index) Delete(path string)

Delete stages a file for deletion

func (*Index) Get

func (idx *Index) Get(path string) (IndexEntry, bool)

Get returns an entry by path

func (*Index) IsEmpty

func (idx *Index) IsEmpty() bool

IsEmpty returns true if the index has no entries

func (*Index) List

func (idx *Index) List() []IndexEntry

List returns all entries sorted by path

func (*Index) ListByStatus

func (idx *Index) ListByStatus(status FileStatus) []IndexEntry

ListByStatus returns entries filtered by status

func (*Index) Remove

func (idx *Index) Remove(path string)

Remove unstages a file (removes from index)

func (*Index) Save

func (idx *Index) Save(repoRoot string) error

Save writes the index to the repository

type IndexEntry

type IndexEntry struct {
	Status FileStatus
	Path   string
}

IndexEntry represents a single entry in the staging index

type MergeState

type MergeState struct {
	// InProgress indicates a merge is in progress
	InProgress bool `json:"in_progress"`

	// RemoteName is the remote we're merging from
	RemoteName string `json:"remote_name"`

	// RemoteCommitID is the commit we're merging in
	RemoteCommitID string `json:"remote_commit_id"`

	// LocalCommitID is our commit before the merge
	LocalCommitID string `json:"local_commit_id"`

	// CommonAncestor is the common ancestor commit
	CommonAncestor string `json:"common_ancestor"`

	// ConflictedFiles lists files with merge conflicts
	ConflictedFiles []string `json:"conflicted_files"`
}

MergeState tracks the state of an in-progress merge/pull operation

func LoadMergeState

func LoadMergeState(repoRoot string) (*MergeState, error)

LoadMergeState loads the merge state from disk

func (*MergeState) AddConflict

func (m *MergeState) AddConflict(path string)

AddConflict adds a file to the conflict list

func (*MergeState) Clear

func (m *MergeState) Clear(repoRoot string) error

Clear removes the merge state

func (*MergeState) HasConflicts

func (m *MergeState) HasConflicts() bool

HasConflicts returns true if there are unresolved conflicts

func (*MergeState) IsConflicted

func (m *MergeState) IsConflicted(path string) bool

IsConflicted checks if a file is in the conflict list

func (*MergeState) RemoveConflict

func (m *MergeState) RemoveConflict(path string)

RemoveConflict removes a file from the conflict list

func (*MergeState) Save

func (m *MergeState) Save(repoRoot string) error

Save writes the merge state to disk

type RemoteConfig

type RemoteConfig struct {
	URL string `toml:"url"` // PostgreSQL connection URL
}

RemoteConfig contains remote repository settings

type UserConfig

type UserConfig struct {
	Name  string `toml:"name"`
	Email string `toml:"email"`
}

UserConfig contains user information for commits

Jump to

Keyboard shortcuts

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