Changeset 0.21.4 (#90)
This commit is contained in:
61
server/models/models_git.go
Normal file
61
server/models/models_git.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// GitCredential stores encrypted git authentication credentials.
|
||||
// The encrypted_data field contains JSON: { "token": "..." } for PAT,
|
||||
// { "username": "...", "password": "..." } for basic auth, or
|
||||
// { "private_key": "...", "passphrase": "..." } for SSH keys.
|
||||
type GitCredential struct {
|
||||
ID string `json:"id" db:"id"`
|
||||
UserID string `json:"user_id" db:"user_id"`
|
||||
Name string `json:"name" db:"name"`
|
||||
AuthType string `json:"auth_type" db:"auth_type"` // https_pat, https_basic, ssh_key
|
||||
EncryptedData []byte `json:"-" db:"encrypted_data"` // never expose
|
||||
Nonce []byte `json:"-" db:"nonce"` // never expose
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||
}
|
||||
|
||||
// GitCredentialSummary is the safe-to-expose version (no encrypted data).
|
||||
type GitCredentialSummary struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
AuthType string `json:"auth_type"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// Summary returns a safe version without encrypted fields.
|
||||
func (c *GitCredential) Summary() GitCredentialSummary {
|
||||
return GitCredentialSummary{
|
||||
ID: c.ID,
|
||||
Name: c.Name,
|
||||
AuthType: c.AuthType,
|
||||
CreatedAt: c.CreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// GitStatus represents the output of git status.
|
||||
type GitStatus struct {
|
||||
Branch string `json:"branch"`
|
||||
Clean bool `json:"clean"`
|
||||
Ahead int `json:"ahead"`
|
||||
Behind int `json:"behind"`
|
||||
Staged []GitFileStatus `json:"staged,omitempty"`
|
||||
Modified []GitFileStatus `json:"modified,omitempty"`
|
||||
Untracked []string `json:"untracked,omitempty"`
|
||||
}
|
||||
|
||||
// GitFileStatus represents a single file in git status output.
|
||||
type GitFileStatus struct {
|
||||
Path string `json:"path"`
|
||||
Status string `json:"status"` // M, A, D, R, C, U
|
||||
}
|
||||
|
||||
// GitLogEntry represents a single commit in git log.
|
||||
type GitLogEntry struct {
|
||||
Hash string `json:"hash"`
|
||||
ShortHash string `json:"short_hash"`
|
||||
Author string `json:"author"`
|
||||
Date time.Time `json:"date"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
@@ -33,6 +33,12 @@ type Workspace struct {
|
||||
|
||||
IndexingEnabled bool `json:"indexing_enabled" db:"indexing_enabled"`
|
||||
|
||||
// Git integration (v0.21.4)
|
||||
GitRemoteURL *string `json:"git_remote_url,omitempty" db:"git_remote_url"`
|
||||
GitBranch *string `json:"git_branch,omitempty" db:"git_branch"`
|
||||
GitCredentialID *string `json:"git_credential_id,omitempty" db:"git_credential_id"`
|
||||
GitLastSync *time.Time `json:"git_last_sync,omitempty" db:"git_last_sync"`
|
||||
|
||||
// Computed fields (not DB columns)
|
||||
FileCount int `json:"file_count,omitempty"`
|
||||
TotalBytes int64 `json:"total_bytes,omitempty"`
|
||||
@@ -44,6 +50,11 @@ type WorkspacePatch struct {
|
||||
MaxBytes *int64 `json:"max_bytes,omitempty"`
|
||||
Status *string `json:"status,omitempty"`
|
||||
IndexingEnabled *bool `json:"indexing_enabled,omitempty"`
|
||||
|
||||
// Git integration (v0.21.4)
|
||||
GitRemoteURL *string `json:"git_remote_url,omitempty"`
|
||||
GitBranch *string `json:"git_branch,omitempty"`
|
||||
GitCredentialID *string `json:"git_credential_id,omitempty"`
|
||||
}
|
||||
|
||||
// WorkspaceFile represents metadata for a single file or directory in a workspace.
|
||||
|
||||
Reference in New Issue
Block a user