-
Notifications
You must be signed in to change notification settings - Fork 0
feat: status command shipped #7
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "github.com/RohitRavindra-dev/devlocal/internal/filesystem" | ||
| "github.com/RohitRavindra-dev/devlocal/internal/service/status" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| var statusCmd = &cobra.Command{ | ||
| Use: "status", | ||
| Short: "View the current status of devlocal setup", | ||
| PreRunE: func(cmd *cobra.Command, args []string) error { | ||
| return filesystem.ValidateDevLocalFilesystem() | ||
| }, | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| return status.Run() | ||
| }, | ||
| } | ||
|
|
||
| func init() { | ||
| rootCmd.AddCommand(statusCmd) | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,76 @@ | ||||||||||||||||||||||
| package status | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import ( | ||||||||||||||||||||||
| "fmt" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| "github.com/RohitRavindra-dev/devlocal/internal/config" | ||||||||||||||||||||||
| "github.com/RohitRavindra-dev/devlocal/internal/filesystem" | ||||||||||||||||||||||
| "github.com/RohitRavindra-dev/devlocal/internal/git" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| func displayConfigVersion(version int) { | ||||||||||||||||||||||
| fmt.Printf("[Version] %d \n", version) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| func displayOverlookStatus(fileNames []string) { | ||||||||||||||||||||||
| fmt.Println("[Overlooked files]") | ||||||||||||||||||||||
| if len(fileNames) == 0 { | ||||||||||||||||||||||
| fmt.Println("\t- No files registed in config for overlooking!") | ||||||||||||||||||||||
| return | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| for _, filename := range fileNames { | ||||||||||||||||||||||
| exists, err := filesystem.FileExists(filename) | ||||||||||||||||||||||
| overlookStatus := "✗" | ||||||||||||||||||||||
| overlookComment := "Being tracked" | ||||||||||||||||||||||
| if exists { | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if isOverlooked, _ := git.IsSkipWorktree(filename); isOverlooked { | ||||||||||||||||||||||
| overlookStatus = "✓" | ||||||||||||||||||||||
| overlookComment = "Overlooked" | ||||||||||||||||||||||
|
Comment on lines
+27
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Don't swallow When Suggested fix- if isOverlooked, _ := git.IsSkipWorktree(filename); isOverlooked {
+ isOverlooked, err := git.IsSkipWorktree(filename)
+ if err != nil {
+ overlookComment = err.Error()
+ } else if isOverlooked {
overlookStatus = "✓"
overlookComment = "Overlooked"
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
| overlookComment = err.Error() | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| fmt.Printf("\t%s %s \n\t\t- %s\n", overlookStatus, filename, overlookComment) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| func displayPatchesStatus(patches []string) { | ||||||||||||||||||||||
| fmt.Println("[Patches]") | ||||||||||||||||||||||
| if len(patches) == 0 { | ||||||||||||||||||||||
| fmt.Println("\t- No patches registed in config for patching!") | ||||||||||||||||||||||
| return | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+41
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Configured patches never render any status. For any non-empty 🤖 Prompt for AI Agents |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| func displayDevlocalConfig(config *config.DevlocalConfigYaml) error { | ||||||||||||||||||||||
| fmt.Println("\n===============================") | ||||||||||||||||||||||
| fmt.Println("| devlocal [Status] |") | ||||||||||||||||||||||
| fmt.Printf("===============================\n\n") | ||||||||||||||||||||||
| displayConfigVersion(config.Version) | ||||||||||||||||||||||
| fmt.Println() | ||||||||||||||||||||||
| displayOverlookStatus(config.Overlook) | ||||||||||||||||||||||
| fmt.Println() | ||||||||||||||||||||||
| displayPatchesStatus(config.Patches) | ||||||||||||||||||||||
| fmt.Printf("===============================\n\n") | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return nil | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| func Run() error { | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| //load config | ||||||||||||||||||||||
| config, err := filesystem.LoadDevlocalConfig() | ||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||
| return err | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if err := displayDevlocalConfig(config); err != nil { | ||||||||||||||||||||||
| return err | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return nil | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major
🧩 Analysis chain
🏁 Script executed:
Repository: RohitRavindra-dev/devlocal
Length of output: 413
🏁 Script executed:
Repository: RohitRavindra-dev/devlocal
Length of output: 3574
🏁 Script executed:
Repository: RohitRavindra-dev/devlocal
Length of output: 355
🏁 Script executed:
Repository: RohitRavindra-dev/devlocal
Length of output: 355
Make
IsSkipWorktreefailures propagate to status output.git ls-files -vcan return no output for an unmatched path, anddisplayOverlookStatuscurrently discards the error fromgit.IsSkipWorktree(filename), so non-tracked paths still render as “Being tracked”. Make unmatched paths return an error ininternal/git/worktrees.goand handle that error ininternal/service/status/reporter.goinstead of ignoring it.🧰 Tools
🪛 golangci-lint (2.12.2)
[error] 79-79: os/exec.Command must not be called. use os/exec.CommandContext
(noctx)
🤖 Prompt for AI Agents