mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-20 12:23:22 +00:00
Merge pull request #481 from runkids/runkids/479-update-into-shorthand
fix(update): accept the org/team shorthand for --into repos in every entry point
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"skillshare/internal/install"
|
||||
"skillshare/internal/sourcewalk"
|
||||
@@ -87,17 +86,7 @@ func cmdUpdateProjectBatch(sourcePath string, opts *updateOptions, projectRoot s
|
||||
continue
|
||||
}
|
||||
|
||||
// Normalize _ prefix for tracked repos
|
||||
repoName := name
|
||||
if !strings.HasPrefix(repoName, "_") {
|
||||
prefixed := filepath.Join(sourcePath, "_"+name)
|
||||
if install.IsTrackedCheckout(prefixed) {
|
||||
repoName = "_" + name
|
||||
}
|
||||
}
|
||||
repoPath := filepath.Join(sourcePath, repoName)
|
||||
|
||||
if install.IsTrackedCheckout(repoPath) {
|
||||
if repoName, repoPath := install.FindTrackedCheckoutUnlessSkill(sourcePath, name); repoPath != "" {
|
||||
if !seen[repoPath] {
|
||||
seen[repoPath] = true
|
||||
targets = append(targets, updateTarget{name: repoName, path: repoPath, isRepo: true})
|
||||
|
||||
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -22,14 +23,13 @@ type updateTarget struct {
|
||||
// resolveByBasename searches nested skills and tracked repos by their
|
||||
// directory basename. Returns an error when zero or multiple matches found.
|
||||
func resolveByBasename(sourceDir, name string, walks ...sourcewalk.Options) (updateTarget, error) {
|
||||
name = path.Clean(filepath.ToSlash(name)) // "team/" names the same item as "team"
|
||||
var matches []updateTarget
|
||||
|
||||
// Search tracked repos
|
||||
repos, _ := install.GetTrackedRepos(sourceDir, walks...)
|
||||
for _, r := range repos {
|
||||
if r == name || filepath.Base(r) == "_"+name || filepath.Base(r) == name {
|
||||
matches = append(matches, updateTarget{name: r, path: filepath.Join(sourceDir, r), isRepo: true})
|
||||
}
|
||||
for _, r := range install.MatchTrackedRepos(repos, name) {
|
||||
matches = append(matches, updateTarget{name: r, path: filepath.Join(sourceDir, r), isRepo: true})
|
||||
}
|
||||
|
||||
// Search updatable skills
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package install
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"skillshare/internal/sourcewalk"
|
||||
)
|
||||
|
||||
// FindTrackedCheckout maps a name typed by the user to a tracked checkout
|
||||
// under sourceRoot. It tries the name as given, then with "_" added to the
|
||||
// last path segment, so "org/team" finds the checkout "org/_team" that
|
||||
// `install --track --into org` creates. A name that would leave sourceRoot
|
||||
// never matches. It returns the slash-form name relative to sourceRoot and the
|
||||
// checkout path, or empty strings when nothing matches.
|
||||
func FindTrackedCheckout(sourceRoot, input string) (name, repoPath string) {
|
||||
sourceRoot = filepath.Clean(sourceRoot)
|
||||
for _, candidate := range trackedRepoCandidates(input) {
|
||||
p := filepath.Join(sourceRoot, filepath.FromSlash(candidate))
|
||||
rel, err := filepath.Rel(sourceRoot, p)
|
||||
if err != nil || rel == ".." || strings.HasPrefix(rel, ".."+string(filepath.Separator)) {
|
||||
continue
|
||||
}
|
||||
if IsTrackedCheckout(p) {
|
||||
return candidate, p
|
||||
}
|
||||
}
|
||||
return "", ""
|
||||
}
|
||||
|
||||
// FindTrackedCheckoutUnlessSkill is FindTrackedCheckout, except that the
|
||||
// shorthand inside a folder (org/team -> org/_team) does not apply when a
|
||||
// directory already exists at org/team: that is the skill the name refers to.
|
||||
func FindTrackedCheckoutUnlessSkill(sourceRoot, input string) (name, repoPath string) {
|
||||
name, repoPath = FindTrackedCheckout(sourceRoot, input)
|
||||
if repoPath == "" {
|
||||
return "", ""
|
||||
}
|
||||
if typed := cleanName(input); name != typed && path.Dir(name) != "." {
|
||||
if info, err := os.Stat(filepath.Join(sourceRoot, filepath.FromSlash(typed))); err == nil && info.IsDir() {
|
||||
return "", ""
|
||||
}
|
||||
}
|
||||
return name, repoPath
|
||||
}
|
||||
|
||||
// cleanName turns a typed name into a clean slash path ("org/team/" -> "org/team").
|
||||
func cleanName(input string) string {
|
||||
return path.Clean(filepath.ToSlash(input))
|
||||
}
|
||||
|
||||
// trackedRepoCandidates lists the slash-form names a tracked repo may have for
|
||||
// input: input itself, then input with "_" added to its last path segment.
|
||||
func trackedRepoCandidates(input string) []string {
|
||||
input = cleanName(input)
|
||||
if base := path.Base(input); !strings.HasPrefix(base, "_") {
|
||||
return []string{input, path.Join(path.Dir(input), "_"+base)}
|
||||
}
|
||||
return []string{input}
|
||||
}
|
||||
|
||||
// MatchTrackedRepos returns the repos (slash paths, as GetTrackedRepos lists
|
||||
// them) that input names: by full path, with "_" added to the last segment, or
|
||||
// by basename, with or without its "_".
|
||||
func MatchTrackedRepos(repos []string, input string) []string {
|
||||
input = cleanName(input)
|
||||
candidates := trackedRepoCandidates(input)
|
||||
var matches []string
|
||||
for _, repo := range repos {
|
||||
base := path.Base(repo)
|
||||
if slices.Contains(candidates, repo) || base == input || base == "_"+input {
|
||||
matches = append(matches, repo)
|
||||
}
|
||||
}
|
||||
return matches
|
||||
}
|
||||
|
||||
// ResolveTrackedRepo is FindTrackedCheckout plus a fallback to the one tracked
|
||||
// repo whose basename matches the name (with or without its "_"). More than
|
||||
// one such repo is an error. Returns empty strings and no error when nothing
|
||||
// matches.
|
||||
func ResolveTrackedRepo(sourceRoot, input string, walk ...sourcewalk.Options) (name, repoPath string, err error) {
|
||||
if name, repoPath = FindTrackedCheckout(sourceRoot, input); repoPath != "" {
|
||||
return name, repoPath, nil
|
||||
}
|
||||
repos, err := GetTrackedRepos(sourceRoot, walk...)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("failed to list tracked repositories: %w", err)
|
||||
}
|
||||
matches := MatchTrackedRepos(repos, input)
|
||||
if len(matches) > 1 {
|
||||
return "", "", fmt.Errorf("multiple tracked repositories match: %s — use the full path", input)
|
||||
}
|
||||
if len(matches) == 0 {
|
||||
return "", "", nil
|
||||
}
|
||||
match := matches[0]
|
||||
return match, filepath.Join(filepath.Clean(sourceRoot), filepath.FromSlash(match)), nil
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package install
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func fakeTrackedRepo(t *testing.T, root, rel string) {
|
||||
t.Helper()
|
||||
if err := os.MkdirAll(filepath.Join(root, filepath.FromSlash(rel), ".git"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveTrackedRepo(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
fakeTrackedRepo(t, root, "_team")
|
||||
fakeTrackedRepo(t, root, "org/_team")
|
||||
fakeTrackedRepo(t, root, "org/_solo")
|
||||
fakeTrackedRepo(t, root, "a/_dup")
|
||||
fakeTrackedRepo(t, root, "b/_dup")
|
||||
outside := filepath.Join(filepath.Dir(root), filepath.Base(root)+"-outside", "_x")
|
||||
if err := os.MkdirAll(filepath.Join(outside, ".git"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
cases := []struct{ input, want string }{
|
||||
{"team", "_team"},
|
||||
{"_team", "_team"},
|
||||
{"org/team", "org/_team"},
|
||||
{"org/_team", "org/_team"},
|
||||
{"solo", "org/_solo"},
|
||||
{"team/", "_team"},
|
||||
{"org/team/", "org/_team"},
|
||||
{"./org/_team", "org/_team"},
|
||||
{"../" + filepath.Base(root) + "-outside/x", ""},
|
||||
{"ghost", ""},
|
||||
}
|
||||
for _, c := range cases {
|
||||
t.Run(c.input, func(t *testing.T) {
|
||||
got, path, err := ResolveTrackedRepo(root, c.input)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got != c.want {
|
||||
t.Errorf("name = %q, want %q", got, c.want)
|
||||
}
|
||||
if wantPath := filepath.Join(root, filepath.FromSlash(c.want)); c.want != "" && path != wantPath {
|
||||
t.Errorf("path = %q, want %q", path, wantPath)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if _, _, err := ResolveTrackedRepo(root, "dup"); err == nil {
|
||||
t.Error("expected an ambiguity error for dup")
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package server
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -537,54 +536,12 @@ func (s *Server) handleUninstallSkill(w http.ResponseWriter, r *http.Request) {
|
||||
writeError(w, http.StatusNotFound, "skill not found: "+name)
|
||||
}
|
||||
|
||||
// resolveTrackedRepo resolves a repo name (flat or nested) to its directory name
|
||||
// and absolute path under s.cfg.EffectiveSkillsSource(). Returns ("", "", nil) if not found.
|
||||
// Returns a non-nil error for ambiguous matches or internal failures.
|
||||
// resolveTrackedRepo resolves a repo name (flat or nested) to its slash-form
|
||||
// name and absolute path under s.cfg.EffectiveSkillsSource(). Returns ("", "", nil)
|
||||
// if not found, and a non-nil error for ambiguous matches or internal failures.
|
||||
func (s *Server) resolveTrackedRepo(input string, walks ...sourcewalk.Options) (string, string, error) {
|
||||
sourceRoot := filepath.Clean(s.cfg.EffectiveSkillsSource())
|
||||
candidates := []string{input}
|
||||
if !strings.HasPrefix(filepath.Base(input), "_") {
|
||||
if dir := filepath.Dir(input); dir != "." && dir != "" {
|
||||
candidates = append(candidates, filepath.ToSlash(filepath.Join(dir, "_"+filepath.Base(input))))
|
||||
} else {
|
||||
candidates = append(candidates, "_"+input)
|
||||
}
|
||||
if len(walks) == 0 {
|
||||
walks = []sourcewalk.Options{s.skillsWalk()}
|
||||
}
|
||||
for _, candidate := range candidates {
|
||||
repoPath := filepath.Clean(filepath.Join(sourceRoot, candidate))
|
||||
relPath, relErr := filepath.Rel(sourceRoot, repoPath)
|
||||
if relErr != nil || relPath == ".." || strings.HasPrefix(relPath, ".."+string(filepath.Separator)) {
|
||||
continue
|
||||
}
|
||||
if install.IsTrackedCheckout(repoPath) {
|
||||
return candidate, repoPath, nil
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: match nested tracked repos by basename.
|
||||
var walk sourcewalk.Options
|
||||
if len(walks) > 0 {
|
||||
walk = walks[0]
|
||||
} else {
|
||||
walk = s.skillsWalk()
|
||||
}
|
||||
repos, err := install.GetTrackedRepos(s.cfg.EffectiveSkillsSource(), walk)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("failed to list tracked repositories: %w", err)
|
||||
}
|
||||
var match string
|
||||
for _, repo := range repos {
|
||||
base := filepath.Base(repo)
|
||||
trimmed := strings.TrimPrefix(base, "_")
|
||||
if base == input || trimmed == input {
|
||||
if match != "" {
|
||||
return "", "", fmt.Errorf("multiple tracked repositories match: %s — use the full path", input)
|
||||
}
|
||||
match = repo
|
||||
}
|
||||
}
|
||||
if match != "" {
|
||||
return match, filepath.Join(sourceRoot, match), nil
|
||||
}
|
||||
return "", "", nil
|
||||
return install.ResolveTrackedRepo(s.cfg.EffectiveSkillsSource(), input, walks[0])
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -166,6 +167,7 @@ func (s *Server) updateSingle(name string, force, skipAudit bool) updateResultIt
|
||||
}
|
||||
|
||||
func (s *Server) updateSingleByKind(name, kind string, force, skipAudit bool) updateResultItem {
|
||||
name = path.Clean(filepath.ToSlash(name)) // "org/team/" names the same item as "org/team"
|
||||
if kind == "agent" {
|
||||
return s.updateAgent(name, force, skipAudit)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"skillshare/internal/testutil"
|
||||
)
|
||||
|
||||
// addPendingTrackedRepo clones a tracked repo into src/rel and pushes one more
|
||||
// commit to its remote, so an update moves HEAD. It returns the checkout path.
|
||||
func addPendingTrackedRepo(t *testing.T, src, rel string) string {
|
||||
t.Helper()
|
||||
base := t.TempDir()
|
||||
remote := testutil.SetupBareRemoteRepo(t, base)
|
||||
testutil.SeedRemoteBranch(t, base, remote, "main", map[string]string{"child/SKILL.md": trackedCleanSkill})
|
||||
repo := filepath.Join(src, filepath.FromSlash(rel))
|
||||
testutil.RunGit(t, "", "clone", remote, repo)
|
||||
seed := filepath.Join(base, "seed-main")
|
||||
if err := os.WriteFile(filepath.Join(seed, "child", "SKILL.md"), []byte(trackedCleanSkill+"More help.\n"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
testutil.RunGit(t, seed, "add", "-A")
|
||||
testutil.RunGit(t, seed, "commit", "-m", "update")
|
||||
testutil.RunGit(t, seed, "push", "origin", "HEAD:main")
|
||||
return repo
|
||||
}
|
||||
|
||||
// `update org/team` for a repo installed with --into org (org/_team) must
|
||||
// update that repo and leave a top-level _team alone, on both dashboard routes.
|
||||
func TestHandleUpdate_ShorthandIntoRepo(t *testing.T) {
|
||||
for _, route := range []struct {
|
||||
name string
|
||||
stream bool
|
||||
}{{"single", false}, {"stream", true}} {
|
||||
t.Run(route.name, func(t *testing.T) {
|
||||
s, src := newTestServer(t)
|
||||
nested := addPendingTrackedRepo(t, src, "org/_team")
|
||||
top := addPendingTrackedRepo(t, src, "_team")
|
||||
topBefore := testutil.RunGit(t, top, "rev-parse", "HEAD")
|
||||
nestedBefore := testutil.RunGit(t, nested, "rev-parse", "HEAD")
|
||||
|
||||
results := runFollowUpdate(t, s, route.stream, "org/team")
|
||||
|
||||
if len(results) != 1 || results[0].Name != "org/_team" || results[0].Action != "updated" {
|
||||
t.Fatalf("results = %+v, want org/_team updated", results)
|
||||
}
|
||||
if got := testutil.RunGit(t, nested, "rev-parse", "HEAD"); got == nestedBefore {
|
||||
t.Error("org/_team was not updated")
|
||||
}
|
||||
if got := testutil.RunGit(t, top, "rev-parse", "HEAD"); got != topBefore {
|
||||
t.Error("top-level _team was updated by the org/team shorthand")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// A skill that exists at org/team is what the name refers to; the shorthand
|
||||
// must not send the update to org/_team instead.
|
||||
func TestHandleUpdateStream_ExistingSkillBeatsShorthand(t *testing.T) {
|
||||
s, src := newTestServer(t)
|
||||
addSkill(t, src, "org/team")
|
||||
addTrackedRepo(t, src, "org/_team")
|
||||
|
||||
results := runFollowUpdate(t, s, true, "org/team")
|
||||
|
||||
if len(results) != 1 || results[0].Name != "org/team" || results[0].IsRepo {
|
||||
t.Fatalf("results = %+v, want the org/team skill, not the org/_team repo", results)
|
||||
}
|
||||
}
|
||||
|
||||
// `org/team/` names the same skill as `org/team`, so the exact-skill lookup
|
||||
// must see it before the shorthand can pick org/_team.
|
||||
func TestHandleUpdate_TrailingSlashKeepsExistingSkill(t *testing.T) {
|
||||
s, src := newTestServer(t)
|
||||
addSkill(t, src, "org/team")
|
||||
addSkillMeta(t, src, "org/team", "/nonexistent/skill-source")
|
||||
addTrackedRepo(t, src, "org/_team")
|
||||
s.reloadSkillsStore() // pick up the metadata written above
|
||||
|
||||
results := runFollowUpdate(t, s, false, "org/team/")
|
||||
|
||||
if len(results) != 1 || results[0].IsRepo {
|
||||
t.Fatalf("results = %+v, want the org/team skill, not the org/_team repo", results)
|
||||
}
|
||||
}
|
||||
@@ -59,22 +59,11 @@ func (s *Server) handleUpdateStream(w http.ResponseWriter, r *http.Request) {
|
||||
items = append(items, updateItem{name: name, invalid: true})
|
||||
continue
|
||||
}
|
||||
// Check if it's a tracked repo (a _-prefixed checkout; an unprefixed one is a regular skill)
|
||||
repoName := name
|
||||
if !strings.HasPrefix(repoName, "_") {
|
||||
repoName = "_" + name
|
||||
}
|
||||
repoPath := filepath.Join(source, repoName)
|
||||
if install.IsTrackedCheckout(repoPath) {
|
||||
// A tracked repo (a _-prefixed checkout; an unprefixed one is a regular skill)
|
||||
if repoName, repoPath := install.FindTrackedCheckoutUnlessSkill(source, name); repoPath != "" {
|
||||
items = append(items, updateItem{name: repoName, isRepo: true, path: repoPath})
|
||||
continue
|
||||
}
|
||||
// Check original name as repo
|
||||
origPath := filepath.Join(source, name)
|
||||
if install.IsTrackedCheckout(origPath) {
|
||||
items = append(items, updateItem{name: name, isRepo: true, path: origPath})
|
||||
continue
|
||||
}
|
||||
// Regular skill
|
||||
skillPath := filepath.Join(source, name)
|
||||
items = append(items, updateItem{name: name, isRepo: false, path: skillPath})
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
//go:build !online
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"skillshare/internal/testutil"
|
||||
)
|
||||
|
||||
// addPendingTrackedRepo clones a tracked repo into sourceDir/rel and pushes one
|
||||
// more commit to its remote, so an update changes my-skill/SKILL.md.
|
||||
func addPendingTrackedRepo(t *testing.T, sb *testutil.Sandbox, sourceDir, rel string) string {
|
||||
t.Helper()
|
||||
repoPath := filepath.Join(sourceDir, filepath.FromSlash(rel))
|
||||
remoteDir := filepath.Join(t.TempDir(), "remote.git")
|
||||
run(t, "", "git", "init", "--bare", remoteDir)
|
||||
run(t, sb.Root, "git", "clone", remoteDir, repoPath)
|
||||
sb.WriteFile(filepath.Join(repoPath, "my-skill", "SKILL.md"), "---\nname: my-skill\n---\n# Clean")
|
||||
run(t, repoPath, "git", "add", "-A")
|
||||
run(t, repoPath, "git", "commit", "-m", "init")
|
||||
run(t, repoPath, "git", "push", "origin", "HEAD")
|
||||
|
||||
workDir := filepath.Join(t.TempDir(), "work")
|
||||
run(t, sb.Root, "git", "clone", remoteDir, workDir)
|
||||
sb.WriteFile(filepath.Join(workDir, "my-skill", "SKILL.md"), "---\nname: my-skill\n---\n# Updated clean")
|
||||
run(t, workDir, "git", "add", "-A")
|
||||
run(t, workDir, "git", "commit", "-m", "update")
|
||||
run(t, workDir, "git", "push", "origin", "HEAD")
|
||||
return repoPath
|
||||
}
|
||||
|
||||
// `update org/team` for a repo installed with --into org (org/_team) must
|
||||
// update that repo, never a top-level _team that sits next to it.
|
||||
func assertShorthandUpdatesNestedRepo(t *testing.T, sb *testutil.Sandbox, sourceDir string, update func(name string) *testutil.Result) {
|
||||
t.Helper()
|
||||
nested := addPendingTrackedRepo(t, sb, sourceDir, "org/_team")
|
||||
top := addPendingTrackedRepo(t, sb, sourceDir, "_team")
|
||||
|
||||
update("org/team").AssertSuccess(t)
|
||||
|
||||
if got := sb.ReadFile(filepath.Join(nested, "my-skill", "SKILL.md")); !strings.Contains(got, "Updated clean") {
|
||||
t.Errorf("org/_team was not updated, got %q", got)
|
||||
}
|
||||
if got := sb.ReadFile(filepath.Join(top, "my-skill", "SKILL.md")); strings.Contains(got, "Updated clean") {
|
||||
t.Errorf("top-level _team was updated by the org/team shorthand")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdate_ShorthandIntoRepo(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
setupGlobalConfig(sb)
|
||||
|
||||
assertShorthandUpdatesNestedRepo(t, sb, sb.SourcePath, func(name string) *testutil.Result {
|
||||
return sb.RunCLI("update", name)
|
||||
})
|
||||
}
|
||||
|
||||
func TestUpdateProject_ShorthandIntoRepo(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
projectRoot := sb.SetupProjectDir("claude")
|
||||
|
||||
assertShorthandUpdatesNestedRepo(t, sb, filepath.Join(projectRoot, ".skillshare", "skills"), func(name string) *testutil.Result {
|
||||
return sb.RunCLIInDir(projectRoot, "update", name, "-p")
|
||||
})
|
||||
}
|
||||
|
||||
// A skill at org/team is what `update org/team -p` names; the shorthand must
|
||||
// not send it to the org/_team checkout beside it.
|
||||
func TestUpdateProject_ExistingSkillBeatsShorthand(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
projectRoot := sb.SetupProjectDir("claude")
|
||||
source := filepath.Join(projectRoot, ".skillshare", "skills")
|
||||
addPendingTrackedRepo(t, sb, source, "org/_team")
|
||||
writeProjectMeta(t, sb.CreateProjectSkill(projectRoot, "org/team", map[string]string{"SKILL.md": "# Team"}))
|
||||
|
||||
result := sb.RunCLIInDir(projectRoot, "update", "org/team", "--dry-run", "-p")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputNotContains(t, "_team")
|
||||
}
|
||||
|
||||
// `update team/` names the same item as `update team`: both the skill and the
|
||||
// _team repo match, so it is ambiguous either way.
|
||||
func TestUpdate_TrailingSlashKeepsAmbiguity(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
setupGlobalConfig(sb)
|
||||
addPendingTrackedRepo(t, sb, sb.SourcePath, "_team")
|
||||
writeMeta(t, sb.CreateSkill("team", map[string]string{"SKILL.md": "# Team"}))
|
||||
|
||||
result := sb.RunCLI("update", "team/")
|
||||
|
||||
result.AssertFailure(t)
|
||||
result.AssertAnyOutputContains(t, "matches multiple items")
|
||||
}
|
||||
@@ -408,7 +408,7 @@ skillshare update --all -p --skip-audit # Skip security audit gate
|
||||
| **Local-path install** | Re-copy from the recorded path | Listed in `.metadata.json` with `type: local` |
|
||||
| **Local skill** | Skipped | Not listed in `.metadata.json` |
|
||||
|
||||
The `_` prefix is optional — `skillshare update team-skills -p` auto-detects `_team-skills`.
|
||||
The `_` prefix is optional, on the last path segment too — `skillshare update team-skills -p` auto-detects `_team-skills`, and `skillshare update devops/team-skills -p` finds a repo installed with `--into devops` at `devops/_team-skills`.
|
||||
|
||||
### Lockfile
|
||||
|
||||
|
||||
@@ -408,7 +408,7 @@ skillshare update --all -p --skip-audit # security audit gate をスキップ
|
||||
| **ローカルパスからのインストール** | 記録されたパスから再コピー | `.metadata.json` に `type: local` で記載されている |
|
||||
| **Local skill** | スキップ | `.metadata.json` に記載されていない |
|
||||
|
||||
`_` prefix は省略可能です — `skillshare update team-skills -p` は自動的に `_team-skills` を検出します。
|
||||
`_` prefix は最後のパス区間でも省略可能です — `skillshare update team-skills -p` は自動的に `_team-skills` を検出し、`skillshare update devops/team-skills -p` は `--into devops` でインストールした `devops/_team-skills` を検出します。
|
||||
|
||||
### ロックファイル
|
||||
|
||||
|
||||
@@ -408,7 +408,7 @@ skillshare update --all -p --skip-audit # 보안 audit gate 건너뛰기
|
||||
| **로컬 경로 설치** | 기록된 경로에서 다시 복사 | `.metadata.json`에 `type: local`로 등록됨 |
|
||||
| **Local skill** | 건너뜀 | `.metadata.json`에 등록되지 않음 |
|
||||
|
||||
`_` 접두사는 선택 사항입니다 — `skillshare update team-skills -p`는 `_team-skills`를 자동으로 감지합니다.
|
||||
`_` 접두사는 경로의 마지막 구간에서도 선택 사항입니다 — `skillshare update team-skills -p`는 `_team-skills`를 자동으로 감지하고, `skillshare update devops/team-skills -p`는 `--into devops`로 설치한 `devops/_team-skills`를 찾습니다.
|
||||
|
||||
### Lockfile
|
||||
|
||||
|
||||
+1
-1
@@ -408,7 +408,7 @@ skillshare update --all -p --skip-audit # Skip security audit gate
|
||||
| **Local-path install** | Re-copy from the recorded path | Listed in `.metadata.json` with `type: local` |
|
||||
| **Local skill** | Skipped | Not listed in `.metadata.json` |
|
||||
|
||||
`_` 前缀是可选的——`skillshare update team-skills -p` 会自动检测为 `_team-skills`。
|
||||
`_` 前缀是可选的,路径的最后一段也一样——`skillshare update team-skills -p` 会自动检测为 `_team-skills`,`skillshare update devops/team-skills -p` 会找到以 `--into devops` 安装的 `devops/_team-skills`。
|
||||
|
||||
### 锁定文件
|
||||
|
||||
|
||||
+1
-1
@@ -408,7 +408,7 @@ skillshare update --all -p --skip-audit # 跳過安全性 audit 關卡
|
||||
| **從本機路徑安裝** | 從記錄的路徑重新複製 | 列於 `.metadata.json`,且 `type: local` |
|
||||
| **本機 skill** | 跳過 | 未列於 `.metadata.json` |
|
||||
|
||||
`_` 前綴是選填的 — `skillshare update team-skills -p` 會自動偵測為 `_team-skills`。
|
||||
`_` 前綴是選填的,路徑最後一段也一樣 — `skillshare update team-skills -p` 會自動偵測為 `_team-skills`,`skillshare update devops/team-skills -p` 會找到以 `--into devops` 安裝的 `devops/_team-skills`。
|
||||
|
||||
### Lockfile
|
||||
|
||||
|
||||
Reference in New Issue
Block a user