feat(file): 新增 file 快捷命令组,无需克隆即可读写仓库文件 #330
Loading…
Reference in New Issue
No description provided.
Delete Branch "Taoyouce/gitlink-cli:feat/file-shortcuts"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
背景
响应社区 issue「API是否支持自动读取仓库内文件(README等)?」:目前读取/修改仓库文件只能克隆仓库或手写 Raw API 调用。本 PR 新增
file快捷命令组,让用户和 AI Agent 无需克隆即可读写仓库文件。目录列表和 README 查看已由repo +tree/repo +readme覆盖,本命令组不重复。命令
file +view--raw仅输出解码后的正文(可直接管道/重定向)file +searchfile +createfile +updatefile +delete--content内联或--content-file本地文件,二选一强校验;--message缺省为<action> <path>;--new-branch支持提交到从--branch新建的分支。base64编码,故统一使用text编码(delete 也需携带空content/encoding字段,否则报「请输入正确的文件参数Files」,均已实测确认)。测试与验证
--new-branch透传、raw 内容提取(entries/README 两种响应形态)go test ./...、go vet、gofmt全部通过+view --raw、+search、+create(含--new-branch)、+update、+delete全链路逐一验证成功The contents/batch endpoint accepts multiple file operations per commit, but each existing shortcut sent exactly one. file +batch takes a JSON spec (array of {action_type, file_path, content, encoding}) and applies them atomically in one commit: gitlink-cli file +batch -s spec.json -b master -m 'batch ops' Client-side validation: action_type must be create|update|delete, file_path required. content/encoding are normalized for delete entries — the server rejects entries missing content with '请输入正确的文件参数Files' (production-reproduced). Production-verified on gitlink.org.cn: 2-file create in one commit, then 2-file delete in one commit. Unit test covers payload shape, delete normalization, and action_type validation. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>Pull request closed