chore(commands): more commands for suggestions (#10)

## What's new
- color completion message command green
https://github.com/versenilvis/IRIS/pull/10/commits/6e141f5e6909fad1ec42725cce38d51729acf399
- new flat command folder structure
https://github.com/versenilvis/IRIS/pull/10/commits/87026a854a529ec5d5baed967d5f7a7f0085a24b
- fix some linter problems
https://github.com/versenilvis/IRIS/pull/10/commits/536de790cefda912f50bf4022e40ce2b965db2e2
- fix some gemini fix suggestions
This commit is contained in:
VERSE
2026-06-23 10:27:26 +07:00
committed by GitHub
parent 3d76a3ee88
commit a2972f61f1
42 changed files with 2406 additions and 245 deletions
+70 -1
View File
@@ -9,7 +9,7 @@ import (
"testing"
"github.com/versenilvis/iris/commands/core"
_ "github.com/versenilvis/iris/commands/dev"
_ "github.com/versenilvis/iris/commands"
)
// setupGitRepo creates a real git repo in a temp dir with:
@@ -304,4 +304,73 @@ func TestGitSuggestions(t *testing.T) {
t.Error("git reset HEAD should suggest file.go")
}
})
t.Run("show suggests tags and commits", func(t *testing.T) {
res := core.Lookup("git show ")
foundTag := false
foundCommit := false
for _, r := range res {
if strings.Contains(r.Cmd, "v1.0") {
foundTag = true
}
// commit hashes are 7+ hex chars
parts := strings.Fields(r.Cmd)
if len(parts) > 0 {
h := parts[len(parts)-1]
if len(h) >= 7 {
foundCommit = true
}
}
}
if !foundTag {
t.Error("git show should suggest tag v1.0")
}
if !foundCommit {
t.Error("git show should suggest commit hashes")
}
})
t.Run("cherry-pick suggests commits", func(t *testing.T) {
res := core.Lookup("git cherry-pick ")
if len(res) == 0 {
t.Error("git cherry-pick should suggest commits")
}
// all suggestions should be short hex hashes
for _, r := range res {
parts := strings.Fields(r.Cmd)
if len(parts) == 0 {
continue
}
h := parts[len(parts)-1]
if len(h) < 7 {
t.Errorf("cherry-pick suggestion looks invalid: %s", r.Cmd)
}
}
})
t.Run("revert suggests commits", func(t *testing.T) {
res := core.Lookup("git revert ")
if len(res) == 0 {
t.Error("git revert should suggest commits")
}
})
t.Run("global flags don't break subcommand detection", func(t *testing.T) {
ctx := context.Background()
out, err := exec.CommandContext(ctx, "git", "rev-parse", "--abbrev-ref", "HEAD").Output()
if err != nil {
t.Skip("can't determine HEAD branch")
}
activeBranch := strings.TrimSpace(string(out))
res := core.Lookup("git -c core.pager=cat checkout ")
for _, r := range res {
parts := strings.Fields(r.Cmd)
for _, p := range parts {
if p == activeBranch {
t.Errorf("git -c core.pager=cat checkout should not suggest active branch '%s', got: %s", activeBranch, r.Cmd)
}
}
}
})
}