Skip to content

feat(cli): send canonical path with each share, list path column - #64

Merged
scott merged 1 commit into
mainfrom
feat/share-path
Aug 24, 2026
Merged

feat(cli): send canonical path with each share, list path column#64
scott merged 1 commit into
mainfrom
feat/share-path

Conversation

@scott

@scott scott commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • canonicalPath() resolves symlinks and cleans absolute path so the same file shared from different cwd or via symlinks maps to one share.
  • POST /api/shares now carries the canonical path. Server returns 201 on insert, 200 on update — CLI uses both the status code and the local cache to choose between "Shared ..." and "Already shared ... — refreshing content in place." messages.
  • list gains a PATH column; legacy shares without a path render as -.
  • remove <path> canonicalizes before consulting the local map or the server, so symlinks and relative paths match.
  • New runShareWithCtx + runWatchAndPushCtx take a context.Context so tests can stop the watch cleanly. End-to-end watch test rewritten to wait for the PUT (not just any push) before asserting.

Test plan

go test ./...
go vet ./...
go build ./...

New tests in share_test.go:

  • TestCanonicalPathAbsoluteClean — abs + clean output
  • TestCanonicalPathFollowsSymlink — symlinks resolved
  • TestCreateShareSendsPathField — POST body contains the path
  • TestCreateShareReturnsCreatedFlagOnUpdate — server's 200 reflects as created=false
  • TestRunListShowsPathColumn — list output renders the path
  • TestRunListShowsDashForMissingPath — legacy shares render as -

Pairs with gandermd/gandermd#44. Closes #63.

Backward compatibility

The new path field is additive. Old gander builds hit the server without path and dedupe by filename (server-side fallback). New gander builds hit an old gandermd and the unknown field is ignored — same one-share-per-filename behavior as today. The fallback window lets both ship in the same release cycle without a flag day.

gandermd now upserts shares by (user, path) — re-sharing the same
file from the CLI naturally updates the existing share rather than
creating a duplicate with a fresh short_id.

- canonicalPath() resolves symlinks and cleans the absolute path so
  the same file shared from different cwd or via symlinks produces
  one share, not many.
- POST /api/shares now carries the canonical path. CLI sends it on
  every share; the server returns 201 for new, 200 for updated. The
  CLI uses the server's status plus the local cache to decide
  whether to print 'Shared ...' or 'Already shared ... — refreshing'.
- runShareWithCtx + runWatchAndPushCtx accept a context so tests can
  stop the watch cleanly. End-to-end watch test rewritten to wait
  for the PUT (not just any push) before asserting.
- list output gains a PATH column; legacy shares without a path
  render as '-'.
- remove <path> canonicalizes the arg before consulting the local
  map and the server, so symlinks and relative paths match the
  share the user expects.

Pairs with gandermd/gandermd#44. Closes #63.
@scott

scott commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator Author

/oc please review this PR and approve if you find it ready to merge

@scott
scott merged commit ceb45d9 into main Aug 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: send canonical path with each share, index by path

1 participant