Documentation
¶
Overview ¶
Package githubsync implements two-way synchronization between cloop PM tasks and GitHub Issues. It maintains a persistent mapping in .cloop/github-sync.json so that each pull or push only processes new/changed items.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mapping ¶
type Mapping struct {
// TaskToIssue maps cloop task ID → GitHub issue number.
TaskToIssue map[int]int `json:"task_to_issue"`
// IssueToTask maps GitHub issue number → cloop task ID.
IssueToTask map[int]int `json:"issue_to_task"`
}
Mapping persists the task↔issue relationship across runs.
func LoadMapping ¶
LoadMapping reads the persisted mapping file. Returns an empty mapping when the file does not exist yet.
On parse failure (zero-byte file from a pre-atomicfile torn write, manual edit gone wrong, schema drift) the corrupt file is quarantined aside as github-sync.json.corrupt-<unix> and an empty mapping is returned. The next `cloop sync github push|pull` will rebuild the mapping from the current plan (and from any pre-existing Task.GitHubIssue links). Losing the mapping is preferable to hard-failing every github sync subcommand on a single bad save — a lost mapping just means duplicate-issue checks fall back to the legacy Task.GitHubIssue field, which the codebase already reconciles.
func (*Mapping) Save ¶
Save writes the mapping to disk atomically.
A torn write (crash mid-write, ENOSPC, two `cloop sync github` runs racing) would leave a 0-byte or truncated github-sync.json; the next LoadMapping would lose every task↔issue link, causing the next push to recreate already- linked issues as duplicates. The write is staged into a sibling .tmp file, fsynced, then renamed into place; the parent directory is fsynced so the dirent survives a power loss.
type PullResult ¶
PullResult contains the outcome of a Pull operation.
func Pull ¶
func Pull(workDir string, client *gh.Client, plan *pm.Plan, mapping *Mapping, labelFilter []string, force bool) (*PullResult, error)
Pull fetches open GitHub issues and creates PM tasks for those not yet in the plan. If force is true, already-linked tasks are also updated from GitHub. The mapping and plan are mutated in place; callers must save state and mapping.
type PushResult ¶
PushResult contains the outcome of a Push operation.
func Push ¶
func Push(workDir string, client *gh.Client, plan *pm.Plan, mapping *Mapping, defaultLabels []string, dryRun, closeDone, addComment bool) (*PushResult, error)
Push creates or updates GitHub issues for each PM task. If closeDone is true, issues linked to done/skipped tasks are closed. The mapping is mutated in place; callers must save state and mapping.