Documentation
¶
Overview ¶
Package gitutils provides Git repository operations for Syncwright
Index ¶
- func CleanupBackups(repoPath string, filePaths []string) error
- func CommitChanges(message string) error
- func CreateBackup(repoPath, filePath string) error
- func ExtractConflictContent(filePath, repoPath string) (map[int]ConflictContent, error)
- func ExtractFileContext(filePath, repoPath string, contextLines int) ([]string, error)
- func GetAllTrackedFiles(repoPath string) ([]string, error)
- func GetConflictVersions(repoPath, filePath string) (ours, theirs, base []string, err error)
- func GetConflictedFiles() ([]string, error)
- func GetFileAtRevision(repoPath, filePath, revision string) ([]string, error)
- func GetRecentlyModifiedFiles(repoPath string, days int) ([]string, error)
- func IsGitRepository() (bool, error)
- func IsGitRepositoryPath(repoPath string) bool
- func IsInMergeState(repoPath string) (bool, error)
- func IsTextFile(filePath string) bool
- func RestoreBackup(repoPath, filePath string) error
- func ValidateResolution(resolution ConflictResolution) error
- type ConflictContent
- type ConflictFile
- type ConflictHunk
- type ConflictReport
- type ConflictResolution
- type ConflictStatus
- type DiffFile
- type DiffHunk
- type ResolutionResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupBackups ¶
CleanupBackups removes backup files
func CommitChanges ¶
CommitChanges creates a commit with the provided message
func CreateBackup ¶
CreateBackup creates a backup of the file before applying resolutions
func ExtractConflictContent ¶
func ExtractConflictContent(filePath, repoPath string) (map[int]ConflictContent, error)
ExtractConflictContent extracts the content of conflict markers
func ExtractFileContext ¶
ExtractFileContext extracts surrounding context lines for AI processing
func GetAllTrackedFiles ¶
GetAllTrackedFiles returns all files tracked by git
func GetConflictVersions ¶
GetConflictVersions retrieves all versions of a conflicted file
func GetConflictedFiles ¶
GetConflictedFiles returns a list of files with merge conflicts
func GetFileAtRevision ¶
GetFileAtRevision retrieves file content at a specific git revision
func GetRecentlyModifiedFiles ¶
GetRecentlyModifiedFiles returns files modified within the specified number of days
func IsGitRepository ¶
IsGitRepository checks if the current directory is a Git repository
func IsGitRepositoryPath ¶
IsGitRepositoryPath checks if the specified path is a Git repository
func IsInMergeState ¶
IsInMergeState checks if the repository is currently in a merge state
func IsTextFile ¶
IsTextFile checks if a file is likely to be a text file (not binary)
func RestoreBackup ¶
RestoreBackup restores a file from its backup
func ValidateResolution ¶
func ValidateResolution(resolution ConflictResolution) error
ValidateResolution performs basic validation on a resolution
Types ¶
type ConflictContent ¶
type ConflictContent struct {
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
StartMarker string `json:"start_marker"`
MiddleMarker string `json:"middle_marker"`
EndMarker string `json:"end_marker"`
BaseMarker string `json:"base_marker,omitempty"`
OursLines []string `json:"ours_lines"`
TheirsLines []string `json:"theirs_lines"`
BaseLines []string `json:"base_lines,omitempty"`
}
ConflictContent represents the detailed content of a conflict
type ConflictFile ¶
type ConflictFile struct {
Path string `json:"path"`
Hunks []ConflictHunk `json:"hunks"`
Context []string `json:"context,omitempty"` // Surrounding lines for AI context
}
ConflictFile represents a file with merge conflicts
type ConflictHunk ¶
type ConflictHunk struct {
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
OursLines []string `json:"ours_lines"`
TheirsLines []string `json:"theirs_lines"`
BaseLines []string `json:"base_lines,omitempty"` // For diff3 style conflicts
}
ConflictHunk represents a single conflict region in a file
func ParseConflictHunks ¶
func ParseConflictHunks(filePath, repoPath string) ([]ConflictHunk, error)
ParseConflictHunks extracts conflict hunks from a file's content
type ConflictReport ¶
type ConflictReport struct {
ConflictedFiles []ConflictFile `json:"conflicted_files"`
TotalConflicts int `json:"total_conflicts"`
RepoPath string `json:"repo_path"`
}
ConflictReport represents the overall conflict detection report
func GetConflictReport ¶
func GetConflictReport(repoPath string) (*ConflictReport, error)
GetConflictReport generates a comprehensive conflict report
type ConflictResolution ¶
type ConflictResolution struct {
FilePath string `json:"file_path"`
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
ResolvedLines []string `json:"resolved_lines"`
Confidence float64 `json:"confidence"`
Reasoning string `json:"reasoning,omitempty"`
}
ConflictResolution represents a resolved conflict hunk
type ConflictStatus ¶
type ConflictStatus struct {
FilePath string
Status string // "UU" for both modified, "AA" for both added, etc.
}
ConflictStatus represents the status of a conflicted file
func DetectConflicts ¶
func DetectConflicts(repoPath string) ([]ConflictStatus, error)
DetectConflicts identifies files with merge conflicts from git status
type DiffFile ¶
type DiffFile struct {
OldPath string `json:"old_path"`
NewPath string `json:"new_path"`
Hunks []DiffHunk `json:"hunks"`
}
DiffFile represents a file in git diff output
func GetConflictDiff ¶
GetConflictDiff retrieves the git diff for conflicted files
func GetMergeBaseDiff ¶
GetMergeBaseDiff gets the diff between merge base and current state
type DiffHunk ¶
type DiffHunk struct {
OldStart int `json:"old_start"`
OldLines int `json:"old_lines"`
NewStart int `json:"new_start"`
NewLines int `json:"new_lines"`
Lines []string `json:"lines"`
Header string `json:"header"`
}
DiffHunk represents a single hunk from git diff output
type ResolutionResult ¶
type ResolutionResult struct {
Success bool `json:"success"`
AppliedCount int `json:"applied_count"`
FailedCount int `json:"failed_count"`
Errors []string `json:"errors,omitempty"`
ModifiedFiles []string `json:"modified_files"`
}
ResolutionResult represents the result of applying resolutions
func ApplyResolutions ¶
func ApplyResolutions(repoPath string, resolutions []ConflictResolution) (*ResolutionResult, error)
ApplyResolutions applies conflict resolutions to files