Documentation
¶
Overview ¶
Package movemerge implements the file-level move and merge family: `gitmap mv`, `merge-both`, `merge-left`, `merge-right`. Each endpoint (LEFT or RIGHT) is either a local folder or a remote git URL with optional :branch suffix. The package resolves both into working folders, performs the requested file operation, and (for URL endpoints) commits + pushes the result.
Spec: spec/01-app/97-move-and-merge.md
Index ¶
- func AddCommitPush(dir, msg string, push bool) (string, error)
- func CloneURL(url, branch, dir string) error
- func CopyFile(src, dst string, info os.FileInfo) error
- func CopyTree(src, dst string, opts Options) (int, error)
- func FolderExists(path string) (bool, error)
- func GetOriginURL(dir string) (string, error)
- func GuardEndpoints(left, right Endpoint) error
- func HashFile(path string) (string, error)
- func IndexTree(root string, opts Options) (map[string]FileMeta, error)
- func IsGitRepo(path string) bool
- func MapURLToFolder(cwd, url string) string
- func PullFFOnly(dir string) error
- func RunMerge(left, right Endpoint, dir Direction, opts Options) error
- func RunMove(left, right Endpoint, opts Options) error
- func SortedKeys(a, b map[string]FileMeta) []string
- type Choice
- type DiffEntry
- type DiffKind
- type Direction
- type Endpoint
- type EndpointKind
- type FileMeta
- type Options
- type PreferPolicy
- type Resolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCommitPush ¶
AddCommitPush stages, commits, and pushes the working folder. Returns the commit SHA on success.
func CopyFile ¶
CopyFile copies src -> dst, preserving mode bits and parent dirs. Symlinks are recreated, not followed.
func FolderExists ¶
FolderExists reports whether path exists and is a directory.
func GetOriginURL ¶
GetOriginURL reads `git config --get remote.origin.url` for dir.
func GuardEndpoints ¶
GuardEndpoints checks LEFT and RIGHT do not collide on disk.
func IndexTree ¶
IndexTree walks root and returns rel-path -> FileMeta for every non-ignored regular file. Symlinks are recorded but not followed.
func MapURLToFolder ¶
MapURLToFolder derives the candidate working folder for a URL endpoint. `https://github.com/owner/repo.git` -> `<cwd>/repo`.
func PullFFOnly ¶
PullFFOnly runs `git pull --ff-only` inside dir.
func RunMove ¶
RunMove executes `gitmap mv LEFT RIGHT`: copy LEFT into RIGHT, then delete LEFT entirely.
func SortedKeys ¶
SortedKeys returns the union of two map keysets, sorted ascending.
Types ¶
type Endpoint ¶
type Endpoint struct {
Raw string // original CLI token
DisplayName string // trimmed, used in commit messages and logs
Kind EndpointKind // folder or URL
URL string // canonical URL when Kind == EndpointURL
Branch string // optional :branch suffix; "" when omitted
WorkingDir string // absolute resolved working folder
IsGitRepo bool // true when WorkingDir contains .git/
Existed bool // true when WorkingDir already existed pre-resolve
}
Endpoint is a fully resolved LEFT or RIGHT argument.
type EndpointKind ¶
type EndpointKind int
EndpointKind classifies a positional argument once at command start.
const ( // EndpointFolder is a plain on-disk path (relative or absolute). EndpointFolder EndpointKind = iota // EndpointURL is an https/http/ssh/git@ remote, optionally :branch. EndpointURL )
func ClassifyEndpoint ¶
func ClassifyEndpoint(raw string) (kind EndpointKind, url, branch, display string)
ClassifyEndpoint inspects raw and returns its kind and (for URLs) the canonical URL plus optional :branch suffix.
type Options ¶
type Options struct {
Yes bool
Prefer PreferPolicy
NoPush bool
NoCommit bool
ForceFolder bool
PullFolder bool
InitNewRight bool
DryRun bool
IncludeVCS bool
IncludeNodeMods bool
CommandName string // "mv" | "merge-both" | "merge-left" | "merge-right"
LogPrefix string // "[mv]" etc.
CommitMsgFmt string // template; "%s" filled from other side's display
}
Options bundles every CLI flag for the move/merge family.
type PreferPolicy ¶
type PreferPolicy int
PreferPolicy is how -y / --prefer-* resolve conflicts non-interactively.
const ( // PreferNone means use the interactive prompt. PreferNone PreferPolicy = iota // PreferLeft makes LEFT always win. PreferLeft // PreferRight makes RIGHT always win. PreferRight // PreferNewer compares mtime; newer side wins. PreferNewer // PreferSkip skips every conflict (only missing files copied). PreferSkip )
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver picks a Choice for each conflict. Stateful: All-Left/Right stickiness is held inside the resolver instance.
func NewResolver ¶
NewResolver builds a Resolver for the run. When policy is non-None, the resolver short-circuits without reading from in.