abcxyz / abcxyz/abc

Add a merge helper subcommand

Offen
#564 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Go
Sterne
16
Forks
4
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

# Summary

In the as-yet-unreleased `abc upgrade` feature, we're going to be outputting merge conflicts into the user's template destination directory. We could add subcommands to make it easy to launch an editor to resolve these conflicts, like `abc resolve outputs.tf`.

# Example

For example, suppose there's a template that outputs a file named "outputs.tf" that initially contains:

```
output "foo" {
value = a.b
}
```

Then suppose the user locally edits the file to be:

```
output "foo" {
value = x.y
}
```

While at the same time a new version of the template is released that contains:

```
output "foo" {
value = j.k
}
```

At upgrade time, abc detects this as an "edit-edit conflict" and asks the user to resolve it manually.

# Implementation of `resolve` subcomamnd

One way this could work: `abc resolve outputs.tf` would look at the filesystem to determine what kind of merge conflict it is, then launch vimdiff as apprioriate. For an edit-edit conflict involving `outputs.tf`, we could exec vim with three editor windows using `vim -d outputs.tf.abcmerge_locally_edited outputs.tf outputs.tf.abcmerge_from_new_template`.

# Possible extras
- Populate the middle pane of vimdiff with the lines that are the same between the two files. Probably requires integrating with a diff library.
- Use meld on Linux and $SOMETHING_GRAPHICAL on macos.
- Let users define their own editor, like how git uses $GIT_EDITOR
- A "resolve all" mode that scans for unresolved merge conflicts and presents each one in the editor
- A "--theirs" and "--ours" flags, analogous to git, to blindly keep one of the two versions

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.