Skip to content

Commit c2349aa

Browse files
Merge pull request #5 from RohitRavindra-dev/feat/v1/revert
feat: revert now reverts overlook
2 parents 2f35720 + eae4cbf commit c2349aa

3 files changed

Lines changed: 73 additions & 1 deletion

File tree

cmd/revert.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/RohitRavindra-dev/devlocal/internal/filesystem"
7+
"github.com/RohitRavindra-dev/devlocal/internal/service/revert"
8+
"github.com/spf13/cobra"
9+
)
10+
11+
var revertCmd = &cobra.Command{
12+
Use: "revert",
13+
Short: "Revert .devlocal changes that reverts overlooks and dev patches",
14+
PreRunE: func(cmd *cobra.Command, args []string) error {
15+
fmt.Println("[Started] to revert devlocal changes")
16+
17+
return filesystem.ValidateDevLocalFilesystem()
18+
},
19+
RunE: func(cmd *cobra.Command, args []string) error {
20+
return revert.Run()
21+
},
22+
}
23+
24+
func init() {
25+
rootCmd.AddCommand(revertCmd)
26+
}

internal/service/apply/applicator.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ package apply
22

33
import (
44
"fmt"
5+
"strings"
56

67
"github.com/RohitRavindra-dev/devlocal/internal/filesystem"
78
"github.com/RohitRavindra-dev/devlocal/internal/git"
89
)
910

1011
func applyOverlook(overlookFiles []string) error {
11-
fmt.Println("[Running] git skip worktree for files: ", overlookFiles)
12+
fmt.Println("[Running] git skip worktree for files: ", strings.Join(overlookFiles, ", "))
1213
if len(overlookFiles) == 0 {
1314
fmt.Println("[Warn] No files found in overlook section of devlocal config, skipping")
1415
return nil
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package revert
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
7+
"github.com/RohitRavindra-dev/devlocal/internal/filesystem"
8+
"github.com/RohitRavindra-dev/devlocal/internal/git"
9+
)
10+
11+
func revertOverlook(overlookedFiles []string) error {
12+
fmt.Println("[Running] revert git skip worktree for files: ", strings.Join(overlookedFiles, ", "))
13+
14+
if len(overlookedFiles) == 0 {
15+
fmt.Println("[Warn] No files found in overlook section of devlocal config, skipping")
16+
return nil
17+
}
18+
19+
if err := git.NoSkipWorkTree(overlookedFiles); err != nil {
20+
return err
21+
}
22+
23+
fmt.Println("[Completed] revert git skip worktree")
24+
25+
return nil
26+
27+
}
28+
29+
func Run() error {
30+
31+
config, err := filesystem.LoadDevlocalConfig()
32+
33+
if err != nil {
34+
return err
35+
}
36+
37+
// revert overlooked files
38+
if overlookRevertErr := revertOverlook(config.Overlook); overlookRevertErr != nil {
39+
return overlookRevertErr
40+
}
41+
42+
//TODO: revert patches
43+
44+
return nil
45+
}

0 commit comments

Comments
 (0)