IF Commons GitHub

logical/merge

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0003-repoctl-sync FR-005

repoctl merge <ref> (commons repoctl 0003-repoctl-sync FR-005, FR-006): Git merges the reference; where files conflict, the ones a generator writes are never resolved by hand but made again by their generators (taking one side to clear the markers, running sync, and staging what is then as its generator makes it), and the ones a person wrote are left exactly as Git left them and named. The merge is completed only where nothing conflicts any more.

import { partitionConflicts } from "./merge.ts";
partitionConflicts([], ["README.md"]); // { generated: [], written: ["README.md"] }

Source: commons/repoctl/src/logical/merge.ts

2 of 8 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

logical.MergeReporttypeno test imports it
type MergeReport = | { readonly kind: "refused"; readonly why: readonly string[] } | { readonly kind: "merged"; read… (921 characters)
type MergeReport =
  | { readonly kind: "refused"; readonly why: readonly string[] }
  | { readonly kind: "merged"; readonly sync: SyncReport }
  | {
      readonly kind: "conflicts";
      /** The generated files that conflicted and were made again and staged. */
      readonly regenerated: readonly string[];
      /** Of those, the ones that also hold what a person wrote: the lines of both sides were kept and the generated part was made again, so that nothing a side wrote is lost. */
      readonly unioned: readonly string[];
      /** The generated files that conflicted and could not be made again: they stay conflicted. */
      readonly unresolved: readonly string[];
      /** The files a person wrote that conflict, untouched. */
      readonly written: readonly string[];
      /** Whether the merge was completed with a commit. */
      readonly committed: boolean;
      readonly sync: SyncReport;
    };

What a merge came to.

logical.partitionConflictsfunctionno test imports it
function partitionConflicts(table: readonly Generator[], paths: readonly string[]): { readonly generated: readonly string[]; readonly written: readonly string[]; }

The conflicted paths split into the ones a generator writes and the ones a person wrote.

logical.isMixedfunctionno test imports it
function isMixed(table: readonly Generator[], path: string): boolean

Whether a conflicted generated file also holds text a person wrote.

logical.runMergefunctionno test imports it
function runMerge(w: Pick<World, "files" | "process" | "repo">, ref: GitRef, order: readonly Generator[], identity: Identity): Promise<MergeReport>

Merges ref into the checkout, in the order the generators are given.

MergeReporttypeno test imports it
type MergeReport = | { readonly kind: "refused"; readonly why: readonly string[] } | { readonly kind: "merged"; read… (921 characters)
type MergeReport =
  | { readonly kind: "refused"; readonly why: readonly string[] }
  | { readonly kind: "merged"; readonly sync: SyncReport }
  | {
      readonly kind: "conflicts";
      /** The generated files that conflicted and were made again and staged. */
      readonly regenerated: readonly string[];
      /** Of those, the ones that also hold what a person wrote: the lines of both sides were kept and the generated part was made again, so that nothing a side wrote is lost. */
      readonly unioned: readonly string[];
      /** The generated files that conflicted and could not be made again: they stay conflicted. */
      readonly unresolved: readonly string[];
      /** The files a person wrote that conflict, untouched. */
      readonly written: readonly string[];
      /** Whether the merge was completed with a commit. */
      readonly committed: boolean;
      readonly sync: SyncReport;
    };

What a merge came to.

partitionConflictsfunction
function partitionConflicts(table: readonly Generator[], paths: readonly string[]): { readonly generated: readonly string[]; readonly written: readonly string[]; }

The conflicted paths split into the ones a generator writes and the ones a person wrote.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

isMixedfunctionno test imports it
function isMixed(table: readonly Generator[], path: string): boolean

Whether a conflicted generated file also holds text a person wrote.

runMergefunction
function runMerge(w: Pick<World, "files" | "process" | "repo">, ref: GitRef, order: readonly Generator[], identity: Identity): Promise<MergeReport>

Merges ref into the checkout, in the order the generators are given.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.