package git

import (
	"bit.admedia.com/scm/ad/adpilot-indexing-repo-sync.com/internal/contracts/events"
	"bit.admedia.com/scm/ad/adpilot-indexing-repo-sync.com/internal/contracts/metadata"
)

const SnapshotStatusReady = "ready"

// RepositorySnapshot represents a materialized repository snapshot.
type RepositorySnapshot struct {
	RepoID     string `json:"repo_id"`
	SnapshotID string `json:"snapshot_id"`
	CommitSHA  string `json:"commit_sha"`
	Ref        string `json:"ref"`
	Status     string `json:"status"`
}

// SyncResult is returned by GitProvider after a repository sync.
type SyncResult struct {
	CloneURL      string             `json:"clone_url"`
	Snapshot      RepositorySnapshot `json:"snapshot"`
	FileChanges   []FileChange       `json:"file_changes"`
	CommitChanges []CommitChange     `json:"commit_changes"`
	IsFirstSync   bool               `json:"is_first_sync"`
}

// FileChange describes a single file change detected during sync.
type FileChange struct {
	Path       string             `json:"path"`
	OldPath    string             `json:"old_path,omitempty"`
	ChangeType events.ChangeType  `json:"change_type"`
	Language   string             `json:"language"`
	FileKind   events.FileKind    `json:"file_kind"`
}

// CommitChange describes a commit introduced between syncs.
type CommitChange struct {
	CommitSHA string `json:"commit_sha"`
	ParentSHA string `json:"parent_sha,omitempty"`
	metadata.GitCommitMetadata
}
