Documentation
¶
Index ¶
- Constants
- func CreateConflictedFile(path string, localContent, remoteContent []byte, remoteName string) error
- func GlobalConfigPath() string
- func HasConflictMarkers(path string) (bool, error)
- func ListGlobalKeys() []string
- func MergeStatePath(repoRoot string) string
- type Config
- type ContainerConfig
- type CoreConfig
- type FileStatus
- type GlobalConfig
- type IgnorePatterns
- type ImportConfig
- type Index
- func (idx *Index) Add(path string, isNew bool)
- func (idx *Index) Clear()
- func (idx *Index) Delete(path string)
- func (idx *Index) Get(path string) (IndexEntry, bool)
- func (idx *Index) IsEmpty() bool
- func (idx *Index) List() []IndexEntry
- func (idx *Index) ListByStatus(status FileStatus) []IndexEntry
- func (idx *Index) Remove(path string)
- func (idx *Index) Save(repoRoot string) error
- type IndexEntry
- type MergeState
- type RemoteConfig
- type UserConfig
Constants ¶
const ( ConflictMarkerStart = "<<<<<<< LOCAL" ConflictMarkerMiddle = "=======" ConflictMarkerEnd = ">>>>>>> REMOTE" )
ConflictMarkers for merge conflicts
const MergeStateFile = "MERGE_STATE"
Variables ¶
This section is empty.
Functions ¶
func CreateConflictedFile ¶
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 ¶
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 ¶
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 ¶
DefaultConfig returns a new config with default values
func (*Config) GetRemote ¶
func (c *Config) GetRemote(name string) (RemoteConfig, bool)
GetRemote returns a remote config by name
func (*Config) GetUserEmail ¶
GetUserEmail returns the user email from config or environment
func (*Config) GetUserName ¶
GetUserName returns the user name from config or environment
func (*Config) RemoveRemote ¶
RemoveRemote removes a remote by name
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 (*Index) Get ¶
func (idx *Index) Get(path string) (IndexEntry, bool)
Get returns an entry by path
func (*Index) ListByStatus ¶
func (idx *Index) ListByStatus(status FileStatus) []IndexEntry
ListByStatus returns entries filtered by status
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 ¶
UserConfig contains user information for commits