Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improved merge conflict solver #139

Merged
merged 28 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2b6f3b6
work
Katajisto Sep 4, 2024
68101b1
feat: add diff utilities
michal-futurice Aug 29, 2024
e828ca8
fix: improve diff tests
michal-futurice Sep 4, 2024
97a8b46
Merge branch 'temp/merge-michal' into feat/merge-conflict-solver
Katajisto Sep 4, 2024
e4d27a8
feat: add function to calculate unified diff conflict start line indices
michal-futurice Sep 5, 2024
7679cfa
work on better ui
Katajisto Sep 9, 2024
06bfce4
Merge branch 'temp/merge-michal' into feat/merge-conflict-solver
Katajisto Sep 9, 2024
4e6d282
refactor + improvements
Katajisto Sep 10, 2024
3e29cc4
fix: remove todo
Katajisto Sep 12, 2024
5411211
fix: fix issue with first line visibility and footer percent border
Katajisto Sep 12, 2024
2056564
fix: lint issue with constant types
Katajisto Sep 12, 2024
b59856c
fix: stop doing -1 to conflict diff line numbers
Katajisto Sep 12, 2024
4ff1af6
fix: make all of the result strings present tense
Katajisto Sep 12, 2024
7779ecd
fix: unify viewport height calculation
Katajisto Sep 13, 2024
43bc5dd
feat: colorize diff display content and add end of file marker
Katajisto Sep 16, 2024
cda5915
feat: better diff navigation
Katajisto Sep 17, 2024
f43ee97
lint: remove redundant break statements
Katajisto Sep 20, 2024
2b32593
fix: typo in conflict resolution
Katajisto Sep 20, 2024
c0c8030
fix: tests
Katajisto Sep 20, 2024
bebb8d7
fix: update tests to reflect the current ui
Katajisto Sep 23, 2024
ecd8ac0
chore: change colors, refactor a bit and change to keep old
Katajisto Sep 24, 2024
82d0b67
chore: make common colors publicly available
majori Sep 24, 2024
e253a64
chore: add yellow to common colors
majori Sep 24, 2024
4d2e1a1
chore: fix typo in variable name
michal-futurice Sep 26, 2024
03f0c68
chore: switch to using embed package for test data reading
michal-futurice Sep 26, 2024
55b11cf
chore: remove unnecessary star from testdata path
michal-futurice Sep 26, 2024
5004486
chore: make end of file marker gray
Katajisto Oct 2, 2024
fc057e2
chore: change gray into adaptive highlight color
Katajisto Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/cli/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/futurice/jalapeno/internal/cli/option"
"github.com/futurice/jalapeno/pkg/recipe"
"github.com/futurice/jalapeno/pkg/recipeutil"
"github.com/futurice/jalapeno/pkg/ui/colors"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -197,6 +198,6 @@ func runCheck(cmd *cobra.Command, opts checkOptions) error {
}
}

cmd.Printf("All recipes with newer versions upgraded %s\n", ColorGreen.Render("successfully!"))
cmd.Printf("All recipes with newer versions upgraded %s\n", colors.Green.Render("successfully!"))
return nil
}
3 changes: 2 additions & 1 deletion internal/cli/create_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/futurice/jalapeno/internal/cli/option"
"github.com/futurice/jalapeno/pkg/recipe"
"github.com/futurice/jalapeno/pkg/recipeutil"
"github.com/futurice/jalapeno/pkg/ui/colors"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -48,7 +49,7 @@ func runCreateManifest(cmd *cobra.Command, opts createManifestOptions) error {

cmd.Printf(
"Manifest created %s\n",
ColorGreen.Render("successfully!"),
colors.Green.Render("successfully!"),
)

return nil
Expand Down
3 changes: 2 additions & 1 deletion internal/cli/create_recipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/futurice/jalapeno/internal/cli/option"
"github.com/futurice/jalapeno/pkg/recipe"
"github.com/futurice/jalapeno/pkg/recipeutil"
"github.com/futurice/jalapeno/pkg/ui/colors"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -73,7 +74,7 @@ func runCreateRecipe(cmd *cobra.Command, opts createRecipeOptions) error {
cmd.Printf(
"Recipe '%s' created %s\n",
opts.RecipeName,
ColorGreen.Render("successfully!"),
colors.Green.Render("successfully!"),
)

return nil
Expand Down
3 changes: 2 additions & 1 deletion internal/cli/create_rtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/futurice/jalapeno/internal/cli/option"
"github.com/futurice/jalapeno/pkg/recipe"
"github.com/futurice/jalapeno/pkg/recipeutil"
"github.com/futurice/jalapeno/pkg/ui/colors"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -55,7 +56,7 @@ func runCreateTest(cmd *cobra.Command, opts createTestOptions) error {
cmd.Printf(
"Test '%s' created %s\n\n",
test.Name,
ColorGreen.Render("successfully!"),
colors.Green.Render("successfully!"),
)

fmt.Printf("Following files were created: \n%s", recipeutil.CreateFileTree(opts.Dir, map[string]recipeutil.FileStatus{
Expand Down
3 changes: 2 additions & 1 deletion internal/cli/eject.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/futurice/jalapeno/internal/cli/option"
"github.com/futurice/jalapeno/pkg/recipe"
"github.com/futurice/jalapeno/pkg/ui/colors"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -56,6 +57,6 @@ func runEject(cmd *cobra.Command, opts ejectOptions) error {
return err
}

cmd.Printf("Ejected %s\n", ColorGreen.Render("successfully!"))
cmd.Printf("Ejected %s\n", colors.Green.Render("successfully!"))
return nil
}
9 changes: 5 additions & 4 deletions internal/cli/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/futurice/jalapeno/pkg/engine"
"github.com/futurice/jalapeno/pkg/recipe"
"github.com/futurice/jalapeno/pkg/recipeutil"
"github.com/futurice/jalapeno/pkg/ui/colors"
"github.com/futurice/jalapeno/pkg/ui/survey"
"github.com/gofrs/uuid"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -129,11 +130,11 @@ func runExecute(cmd *cobra.Command, opts executeOptions) error {
}

func executeRecipe(cmd *cobra.Command, opts executeOptions, re *recipe.Recipe) error {
cmd.Printf("%s: %s\n", ColorRed.Render("Recipe name"), re.Metadata.Name)
cmd.Printf("%s: %s\n", ColorRed.Render("Version"), re.Metadata.Version)
cmd.Printf("%s: %s\n", colors.Red.Render("Recipe name"), re.Metadata.Name)
cmd.Printf("%s: %s\n", colors.Red.Render("Version"), re.Metadata.Version)

if re.Metadata.Description != "" {
cmd.Printf("%s: %s\n", ColorRed.Render("Description"), re.Metadata.Description)
cmd.Printf("%s: %s\n", colors.Red.Render("Description"), re.Metadata.Description)
}

cmd.Println()
Expand Down Expand Up @@ -233,7 +234,7 @@ func executeRecipe(cmd *cobra.Command, opts executeOptions, re *recipe.Recipe) e
return err
}

cmd.Printf("Recipe executed %s\n", ColorGreen.Render("successfully!"))
cmd.Printf("Recipe executed %s\n", colors.Green.Render("successfully!"))

files := sauce.Files
if opts.Subpath != "" {
Expand Down
3 changes: 2 additions & 1 deletion internal/cli/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/futurice/jalapeno/internal/cli/option"
"github.com/futurice/jalapeno/pkg/recipe"
"github.com/futurice/jalapeno/pkg/ui/colors"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -69,6 +70,6 @@ func runPull(cmd *cobra.Command, opts pullOptions) error {
return err
}

cmd.Printf("Recipe pulled %s\n", ColorGreen.Render("successfully!"))
cmd.Printf("Recipe pulled %s\n", colors.Green.Render("successfully!"))
return nil
}
3 changes: 2 additions & 1 deletion internal/cli/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/futurice/jalapeno/internal/cli/option"
"github.com/futurice/jalapeno/pkg/recipe"
"github.com/futurice/jalapeno/pkg/ui/colors"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -65,6 +66,6 @@ func runPush(cmd *cobra.Command, opts pushOptions) error {
return fmt.Errorf("failed to push recipe: %w", err)
}

cmd.Printf("Recipe pushed %s\n", ColorGreen.Render("successfully!"))
cmd.Printf("Recipe pushed %s\n", colors.Green.Render("successfully!"))
return nil
}
9 changes: 3 additions & 6 deletions internal/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@ import (
"time"

"github.com/carlmjohnson/versioninfo"
"github.com/futurice/jalapeno/pkg/ui/colors"
uiutil "github.com/futurice/jalapeno/pkg/ui/util"

"github.com/charmbracelet/lipgloss"
"github.com/spf13/cobra"
)

var (
// https://goreleaser.com/cookbooks/using-main.version/
version string

ColorRed = lipgloss.NewStyle().Foreground(lipgloss.Color("#EF4136"))
ColorGreen = lipgloss.NewStyle().Foreground(lipgloss.Color("#26A568"))
)

type ExitCodeContextKey struct{}
Expand Down Expand Up @@ -89,6 +86,6 @@ func errorHandler(cmd *cobra.Command, err error) error {
}

// Color the error message
cmd.SetErrPrefix(ColorRed.Render("Error:"))
return errors.New(ColorRed.Render(err.Error()))
cmd.SetErrPrefix(colors.Red.Render("Error:"))
return errors.New(colors.Red.Render(err.Error()))
}
3 changes: 2 additions & 1 deletion internal/cli/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/futurice/jalapeno/pkg/engine"
"github.com/futurice/jalapeno/pkg/recipe"
"github.com/futurice/jalapeno/pkg/recipeutil"
"github.com/futurice/jalapeno/pkg/ui/colors"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -169,6 +170,6 @@ func updateSnapshots(cmd *cobra.Command, opts testOptions, re *recipe.Recipe) er
return fmt.Errorf("failed to save recipe: %w", err)
}

cmd.Printf("Recipe test snapshots updated %s\n", ColorGreen.Render("successfully!"))
cmd.Printf("Recipe test snapshots updated %s\n", colors.Green.Render("successfully!"))
return nil
}
3 changes: 2 additions & 1 deletion internal/cli/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/futurice/jalapeno/pkg/engine"
"github.com/futurice/jalapeno/pkg/recipe"
"github.com/futurice/jalapeno/pkg/recipeutil"
"github.com/futurice/jalapeno/pkg/ui/colors"
"github.com/futurice/jalapeno/pkg/ui/conflict"
"github.com/futurice/jalapeno/pkg/ui/survey"
"github.com/gofrs/uuid"
Expand Down Expand Up @@ -407,7 +408,7 @@ func runUpgrade(cmd *cobra.Command, opts upgradeOptions) error {
for _, status := range fileStatuses {
if status != recipeutil.FileUnchanged {
changesFound = true
cmd.Printf("Recipe upgraded %s\n", ColorGreen.Render("successfully!"))
cmd.Printf("Recipe upgraded %s\n", colors.Green.Render("successfully!"))
tree := recipeutil.CreateFileTree(opts.Dir, fileStatuses)
cmd.Printf("The following files have been processed by the recipe:\n\n%s", tree)
break
Expand Down
3 changes: 2 additions & 1 deletion internal/cli/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/futurice/jalapeno/internal/cli/option"
"github.com/futurice/jalapeno/pkg/recipe"
"github.com/futurice/jalapeno/pkg/ui/colors"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -59,7 +60,7 @@ func runValidate(cmd *cobra.Command, opts validateOptions) error {

cmd.Printf(
"%s The recipe is valid.\n",
ColorGreen.Render("Success!"),
colors.Green.Render("Success!"),
)

return nil
Expand Down
Loading