Documentation
¶
Overview ¶
Package git provides Git repository management functionality with GitHub integration
Index ¶
- type Conflict
- type ConflictResolutionResult
- type ConflictVersion
- type GitRepositoryManager
- func (m *GitRepositoryManager) AddRemote(repo *git.Repository, remoteName string, urls []string) error
- func (m *GitRepositoryManager) CheckAccess(user *auth.User, owner, repo string) (bool, error)
- func (m *GitRepositoryManager) Clone(ctx context.Context, user *auth.User, owner, repo string) error
- func (m *GitRepositoryManager) Commit(repo *git.Repository, message string, authorName string, authorEmail string) (plumbing.Hash, error)
- func (m *GitRepositoryManager) CreateBranch(repo *git.Repository, branchName string, startPoint *plumbing.Reference) error
- func (m *GitRepositoryManager) DeleteBranch(repo *git.Repository, branchName string) error
- func (m *GitRepositoryManager) Diff(repo *git.Repository) (string, error)
- func (m *GitRepositoryManager) FetchRepository(ctx context.Context, repo *git.Repository) error
- func (m *GitRepositoryManager) GetChangesSince(repo *git.Repository, commitHash string) ([]string, error)
- func (m *GitRepositoryManager) GetConflictVersions(repo *git.Repository, path string) ([]ConflictVersion, error)
- func (m *GitRepositoryManager) GetFilteredChanges(repo *git.Repository, includes, excludes []string) ([]string, error)
- func (m *GitRepositoryManager) GetHeadReference(repo *git.Repository) (*plumbing.Reference, error)
- func (m *GitRepositoryManager) GetRepoMetadata(ctx context.Context, user *auth.User, owner, repo string) (*RepositoryMetadata, error)
- func (m *GitRepositoryManager) GetRepositoryList() []string
- func (m *GitRepositoryManager) ListBranches(repo *git.Repository) ([]string, error)
- func (m *GitRepositoryManager) ListRemotes(repo *git.Repository) ([]*config.RemoteConfig, error)
- func (m *GitRepositoryManager) OpenRepository(repoName string) (*git.Repository, error)
- func (m *GitRepositoryManager) Push(repo *git.Repository) error
- func (m *GitRepositoryManager) ResetToClean(repo *git.Repository) error
- func (m *GitRepositoryManager) ResolveConflict(repo *git.Repository, path string, strategy string) error
- func (m *GitRepositoryManager) SyncAllBranches(ctx context.Context, repo *git.Repository, strategy MergeStrategy) error
- func (m *GitRepositoryManager) SyncBranch(ctx context.Context, repo *git.Repository, branchName string, ...) error
- type MergeStrategy
- type RemoteConfig
- type RepositoryMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conflict ¶
type Conflict struct {
ID string `json:"id"`
FilePath string `json:"file_path"`
Versions []ConflictVersion `json:"versions"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
}
Conflict represents a Git merge conflict
type ConflictResolutionResult ¶
type ConflictResolutionResult struct {
FilePath string
ResolvingHash string
Strategy MergeStrategy
Success bool
Error error
}
ConflictResolutionResult represents the result of conflict resolution
type ConflictVersion ¶
type ConflictVersion struct {
PeerID string `json:"peer_id"`
Timestamp time.Time `json:"timestamp"`
Hash string `json:"hash"`
Content []byte `json:"content"`
}
ConflictVersion represents a version of a file in conflict
type GitRepositoryManager ¶
type GitRepositoryManager struct {
// contains filtered or unexported fields
}
GitRepositoryManager manages Git repositories with GitHub integration
func NewGitRepositoryManager ¶
func NewGitRepositoryManager(baseDir string, authStore auth.UserStore) *GitRepositoryManager
NewGitRepositoryManager creates a new GitRepositoryManager instance
func (*GitRepositoryManager) AddRemote ¶
func (m *GitRepositoryManager) AddRemote(repo *git.Repository, remoteName string, urls []string) error
AddRemote adds a new remote to the repository
func (*GitRepositoryManager) CheckAccess ¶
CheckAccess verifies if a user has access to a repository
func (*GitRepositoryManager) Clone ¶
func (m *GitRepositoryManager) Clone(ctx context.Context, user *auth.User, owner, repo string) error
Clone clones a GitHub repository using the user's credentials
func (*GitRepositoryManager) Commit ¶
func (m *GitRepositoryManager) Commit(repo *git.Repository, message string, authorName string, authorEmail string) (plumbing.Hash, error)
Commit creates a new commit in the repository.
func (*GitRepositoryManager) CreateBranch ¶
func (m *GitRepositoryManager) CreateBranch(repo *git.Repository, branchName string, startPoint *plumbing.Reference) error
CreateBranch creates a new branch in the repository
func (*GitRepositoryManager) DeleteBranch ¶
func (m *GitRepositoryManager) DeleteBranch(repo *git.Repository, branchName string) error
DeleteBranch deletes a branch from the repository
func (*GitRepositoryManager) Diff ¶
func (m *GitRepositoryManager) Diff(repo *git.Repository) (string, error)
Diff shows changes between the working directory and HEAD
func (*GitRepositoryManager) FetchRepository ¶
func (m *GitRepositoryManager) FetchRepository(ctx context.Context, repo *git.Repository) error
FetchRepository fetches updates from all remotes.
func (*GitRepositoryManager) GetChangesSince ¶
func (m *GitRepositoryManager) GetChangesSince(repo *git.Repository, commitHash string) ([]string, error)
GetChangesSince returns list of changes since a specific commit
func (*GitRepositoryManager) GetConflictVersions ¶
func (m *GitRepositoryManager) GetConflictVersions(repo *git.Repository, path string) ([]ConflictVersion, error)
GetConflictVersions returns different versions of a file in conflict
func (*GitRepositoryManager) GetFilteredChanges ¶
func (m *GitRepositoryManager) GetFilteredChanges(repo *git.Repository, includes, excludes []string) ([]string, error)
GetFilteredChanges returns changes that match include patterns and don't match exclude patterns
func (*GitRepositoryManager) GetHeadReference ¶
func (m *GitRepositoryManager) GetHeadReference(repo *git.Repository) (*plumbing.Reference, error)
GetHeadReference returns the HEAD reference of the repository.
func (*GitRepositoryManager) GetRepoMetadata ¶
func (m *GitRepositoryManager) GetRepoMetadata(ctx context.Context, user *auth.User, owner, repo string) (*RepositoryMetadata, error)
func (*GitRepositoryManager) GetRepositoryList ¶
func (m *GitRepositoryManager) GetRepositoryList() []string
GetRepositoryList returns a list of all managed repositories
func (*GitRepositoryManager) ListBranches ¶
func (m *GitRepositoryManager) ListBranches(repo *git.Repository) ([]string, error)
ListBranches returns a list of all branches in the repository
func (*GitRepositoryManager) ListRemotes ¶
func (m *GitRepositoryManager) ListRemotes(repo *git.Repository) ([]*config.RemoteConfig, error)
ListRemotes returns a list of configured remotes
func (*GitRepositoryManager) OpenRepository ¶
func (m *GitRepositoryManager) OpenRepository(repoName string) (*git.Repository, error)
OpenRepository opens an existing Git repository or initializes a new one if it doesn't exist.
func (*GitRepositoryManager) Push ¶
func (m *GitRepositoryManager) Push(repo *git.Repository) error
Push pushes the local commits to the remote repository.
func (*GitRepositoryManager) ResetToClean ¶
func (m *GitRepositoryManager) ResetToClean(repo *git.Repository) error
ResetToClean resets the repository to a clean state
func (*GitRepositoryManager) ResolveConflict ¶
func (m *GitRepositoryManager) ResolveConflict(repo *git.Repository, path string, strategy string) error
ResolveConflict resolves a conflict by choosing a strategy
func (*GitRepositoryManager) SyncAllBranches ¶
func (m *GitRepositoryManager) SyncAllBranches(ctx context.Context, repo *git.Repository, strategy MergeStrategy) error
SyncAllBranches synchronizes all tracked branches with their remote counterparts
func (*GitRepositoryManager) SyncBranch ¶
func (m *GitRepositoryManager) SyncBranch(ctx context.Context, repo *git.Repository, branchName string, strategy MergeStrategy) error
SyncBranch synchronizes a specific branch with its remote counterpart
type MergeStrategy ¶
type MergeStrategy string
MergeStrategy represents different merge strategies
const ( // MergeStrategyOctopus uses the octopus merge strategy for multiple branches MergeStrategyOctopus MergeStrategy = "octopus" // MergeStrategyResolve uses the resolve merge strategy MergeStrategyResolve MergeStrategy = "resolve" // MergeStrategyOurs takes our version in conflicts MergeStrategyOurs MergeStrategy = "ours" MergeStrategyTheirs MergeStrategy = "theirs" MergeStrategyUnion MergeStrategy = "union" MergeStrategyManual MergeStrategy = "manual" )
type RemoteConfig ¶
type RemoteConfig struct {
Name string
URLs []string
Priority int // Priority for synchronization (higher number = higher priority)
}
RemoteConfig represents configuration for a remote
type RepositoryMetadata ¶
type RepositoryMetadata struct {
Owner string
Name string
CloneURL string
Private bool
DefaultBranch string
}
RepositoryMetadata contains GitHub-specific repository information
func ParseGitHubURL ¶
func ParseGitHubURL(repoURL string) (*RepositoryMetadata, error)
ParseGitHubURL extracts owner and repo name from GitHub URL