Documentation
¶
Overview ¶
Package git provides git operations for the data entry app.
Package git provides git operations for the data entry app.
Index ¶
- Variables
- func Clone(opts CloneOptions) error
- func ExtractRepoName(repoURL string) string
- func IsRepo(root string) bool
- func IsValidRepoURL(repoURL string) bool
- type ChangeSet
- type CloneOptions
- type Config
- type DeviceCodeResponse
- type EntityChange
- type EntityRef
- type OAuth
- type OAuthConfig
- type Ops
- type RelationChange
- type Status
- type TokenErrorResponse
- type TokenResponse
Constants ¶
This section is empty.
Variables ¶
var ( ErrAuthorizationPending = errors.New("authorization pending") ErrSlowDown = errors.New("slow down") ErrExpiredToken = errors.New("device code expired") ErrAccessDenied = errors.New("access denied by user") )
Common OAuth errors.
var ErrConflictInProgress = errors.New("merge conflict in progress, resolve before syncing")
ErrConflictInProgress indicates a merge conflict that must be resolved first.
Functions ¶
func Clone ¶
func Clone(opts CloneOptions) error
Clone clones a git repository to the specified path. For private repositories, set Token from OAuth device flow.
func ExtractRepoName ¶
ExtractRepoName extracts repository name from URL. e.g., "https://github.com/user/repo.git" -> "repo"
func IsValidRepoURL ¶
IsValidRepoURL checks if the URL looks like a valid git repository URL.
Types ¶
type ChangeSet ¶
type ChangeSet struct {
Added []EntityChange
Modified []EntityChange
Deleted []EntityRef
Relations []RelationChange
}
ChangeSet represents analyzed changes for commit message generation.
func (*ChangeSet) GenerateCommitMessage ¶
GenerateCommitMessage creates a human-readable commit message from changes.
type CloneOptions ¶
type CloneOptions struct {
URL string // Repository URL (HTTPS)
Path string // Local path to clone into
Branch string // Branch to checkout (optional, defaults to default branch)
Token string // OAuth token for authentication (optional for public repos)
Username string // Username for authentication (defaults to "oauth2" when token is set)
}
CloneOptions configures the clone operation.
type Config ¶
type Config struct {
Enabled bool `yaml:"enabled"`
Mode string `yaml:"mode"` // "direct" or "pr"
Branch string `yaml:"branch"` // for direct mode
BaseBranch string `yaml:"base_branch"` // for pr mode: merge from this
PushBranch string `yaml:"push_branch"` // for pr mode: push to this
FetchInterval int `yaml:"fetch_interval"` // seconds, 0 = disabled
Token string `yaml:"-"` // OAuth token for auth (not persisted)
Username string `yaml:"-"` // Username for auth (not persisted)
}
Config holds git configuration for the data entry app.
type DeviceCodeResponse ¶
type DeviceCodeResponse struct {
DeviceCode string `json:"device_code"`
UserCode string `json:"user_code"`
VerificationURI string `json:"verification_uri"`
ExpiresIn int `json:"expires_in"`
Interval int `json:"interval"`
}
DeviceCodeResponse is returned when initiating the device flow.
type EntityChange ¶
type EntityChange struct {
Type string
ID string
PropsChanged []string
BodyChanged bool
IsNew bool
}
EntityChange represents a changed entity.
type OAuth ¶
type OAuth struct {
// contains filtered or unexported fields
}
OAuth provides GitHub OAuth device flow authentication.
func (*OAuth) PollForToken ¶
PollForToken polls GitHub until the user authorizes the device or the code expires. Returns ErrAuthorizationPending if still waiting, ErrExpiredToken if expired.
func (*OAuth) RequestDeviceCode ¶
func (o *OAuth) RequestDeviceCode(ctx context.Context) (*DeviceCodeResponse, error)
RequestDeviceCode initiates the device flow and returns a code for the user.
func (*OAuth) WaitForAuthorization ¶
func (o *OAuth) WaitForAuthorization(ctx context.Context, deviceCode string, interval int) (*TokenResponse, error)
WaitForAuthorization polls until authorized or context cancelled. It respects the interval from the device code response.
type OAuthConfig ¶
type OAuthConfig struct {
ClientID string // GitHub OAuth App client ID
}
OAuthConfig holds GitHub OAuth configuration.
type Ops ¶
type Ops struct {
// contains filtered or unexported fields
}
Ops provides git operations for a repository.
func (*Ops) AnalyzeChanges ¶
AnalyzeChanges examines staged/unstaged changes and returns a ChangeSet.
type RelationChange ¶
RelationChange represents a changed relation.
type Status ¶
type Status struct {
Available bool // true if git repo with remote
Branch string // current branch name
LocalChanges int // number of uncommitted files
RemoteAhead int // commits ahead on remote
Syncing bool // true if sync in progress
Conflict bool // true if merge conflict
ConflictFiles []string // files with conflicts
}
Status represents the current git state.
type TokenErrorResponse ¶
type TokenErrorResponse struct {
Error string `json:"error"`
ErrorDescription string `json:"error_description"`
}
TokenErrorResponse is returned when polling for token fails.
type TokenResponse ¶
type TokenResponse struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
Scope string `json:"scope"`
}
TokenResponse is returned when the device is authorized.