十年匠心定制 · 商业建站与技术教学双线并行 咨询热线:400-886-1026 service@lmnt.cn
ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

使用 AWS CLI `codecommit put-comment-reaction` 为 CodeCommit 评论添加与移除 Emoji 反应

使用 AWS CLI `codecommit put-comment-reaction` 为 CodeCommit 评论添加与移除 Emoji 反应 使用 AWS CLIcodecommit put-comment-reaction为 CodeCommit 评论添加与移除 Emoji 反应【免费下载链接】aws-cliUniversal Command Line Interface for Amazon Web Services项目地址: https://gitcode.com/GitHub_Trending/aw/aws-cli导读本文围绕 AWS CLI 的aws codecommit put-comment-reaction命令展开讲解如何在 AWS CodeCommit 的提交评论、Pull Request 评论上添加或更新 Emoji 反应Reaction并配套介绍查看反应结果的get-comment-reactions与get-comment命令。读完本文你将掌握put-comment-reaction的完整参数含义、短代码short code写法、如何移除既有反应以及该命令在 AWS CLI 底层服务模型中的实现细节与异常约束。命令概览put-comment-reaction能做什么在 AWS CodeCommit 的代码评审流程中评审者可以在提交评论commit comment或 Pull Request 评论上添加 Emoji 反应用轻量方式表达赞同困惑等态度而无需再敲一条文字评论。AWS CLI 为此提供了put-comment-reaction命令。在 服务模型文件 中该操作被描述为Adds or updates a reaction to a specified comment for the user whose identity is used to make the request. You can only add or update a reaction for yourself. You cannot add, modify, or delete a reaction for another user.即为指定评论添加或更新一个反应且只能操作发起请求者自己的反应无法替其他用户添加、修改或删除反应。核心命令与参数详解标准调用形式原示例文档 put-comment-reaction.rst 给出的命令如下aws codecommit put-comment-reaction \ --comment-id abcd1234EXAMPLEb5678efgh \ --reaction-value :thumbsup:该命令不会产生任何输出success 时静默返回可通过命令退出码是否为 0 判断是否执行成功。参数语义依据服务模型根据 PutCommentReactionInput 定义本命令只有两个参数且二者均为必填参数类型必填说明--comment-idstring是要添加/更新反应的目标评论 ID由 CodeCommit 系统生成可通过get-comment、get-comments-for-pull-request等命令获取。--reaction-valuestring是要添加或更新的 Emoji 反应值short code 形式如:thumbsup:。关于--reaction-value服务模型明确说明The emoji reaction you want to add or update. To remove a reaction, provide a value of blank or null. You can also provide the value ofnone.也就是说--reaction-value支持以下取值形态短代码short code如:thumbsup:冒号包裹的短码格式none或空值blank/null用于移除该用户在此评论上的既有反应。反应短代码与展示格式CodeCommit 支持一组有限的 Emoji 反应。从配套示例 get-comment-reactions.rst 的输出可以看到一个反应在服务端以三种格式同时存储对应 ReactionValueFormats 定义emojiEmoji Version 1.0 图形字符不同操作系统渲染略有差异shortCode短代码文本如thumbsupunicodeUnicode 码点如U1F44D。示例输出中出现的短代码包括thumbsup、thumbsdown、confused等写命令时对应为:thumbsup:、:thumbsdown:、:confused:。完整支持列表以 AWS CodeCommit 用户指南中的 Emoji 反应表为准原文档指向该表的链接Comment on a commit in AWS CodeCommit。实战场景场景一给提交评论点个赞先通过get-comment获取评论 ID更多用法见 get-comment.rst然后执行aws codecommit put-comment-reaction \ --comment-id ff30b348EXAMPLEb9aa670f \ --reaction-value :thumbsup:无输出即表示成功添加若之前已添加过同一反应则等价于更新/幂等保持。场景二更换或移除自己的反应由于每个用户对同一评论只能保留一个反应见下文异常说明想要换一个表情时直接再次调用put-comment-reaction覆盖即可aws codecommit put-comment-reaction \ --comment-id ff30b348EXAMPLEb9aa670f \ --reaction-value :confused:想要撤销自己的反应将--reaction-value置为noneaws codecommit put-comment-reaction \ --comment-id ff30b348EXAMPLEb9aa670f \ --reaction-value none同样地也可以传空字符串或 null 来达到移除效果依据服务模型对 reactionValue 的文档说明。场景三验证反应是否生效put-comment-reaction不返回结果验证方式有两种方式一查看单个评论的反应计数。执行get-comment从返回的reactionCounts字段查看每个反应的统计aws codecommit get-comment \ --comment-id ff30b348EXAMPLEb9aa670f参考 get-comment.rst 的示例输出reactionCounts形如{ comment: { commentId: ff30b348EXAMPLEb9aa670f, content: Whoops - I meant to add this comment to the line, but I dont see how to delete it., callerReactions: [], reactionCounts: { SMILE: 6, THUMBSUP: 1 } } }reactionCounts对应服务模型中的 ReactionCountsMap以反应值为键、计数为值。其中callerReactions表示当前调用者自己给出的反应。方式二列出该评论上的所有反应明细。使用get-comment-reactions查看每个反应由哪些 IAM 用户触发对应 ReactionForComment 定义aws codecommit get-comment-reactions \ --comment-id abcd1234EXAMPLEb5678efgh参考示例输出每个反应条目包含reactionemoji/shortCode/unicode 三种格式与reactionUsers用户 ARN 列表完整用法见 get-comment-reactions.rst。底层原理CLI 命令如何生成与执行put-comment-reaction并非 AWS CLI 中的手工定制命令而是由 botocore 根据服务模型自动生成的通用 API 命令。它的行为由以下文件共同决定service-2.json 中的PutCommentReaction操作定义HTTP 方法为POST请求 URI 为/请求体包含commentId与reactionValue两个必填字段同文件中的 PutCommentReactionInput 定义了参数结构、类型与文档说明AWS CLI 的命令表构建逻辑见 customizations/codecommit.py 中的命令注入机制会自动把模型中的操作注册为aws codecommit下的子命令。该文件主要为 CodeCommit 注入credential-helper等特殊命令put-comment-reaction这类标准操作则直接由模型驱动这也是为什么它的参数名、必填约束与错误类型都严格对齐服务模型。异常与限制值得注意的边界从 PutCommentReaction 操作的 errors 列表 可以看出命令可能抛出的异常包括CommentDoesNotExistException评论不存在CommentIdRequiredException/InvalidCommentIdException评论 ID 缺失或格式非法ReactionValueRequiredException/InvalidReactionValueException反应值缺失或不受支持参见 InvalidReactionValueException 定义ReactionLimitExceededException反应数量超限。模型文档明确指出Reactions are limited to one reaction per user for each individual comment ID——每个用户对同一评论只能有一个反应CommentDeletedException目标评论已被删除。小结aws codecommit put-comment-reaction是 CodeCommit 评论协作中最轻量的交互入口一条命令即可为提交评论或 Pull Request 评论添加 Emoji 反应配合get-comment-reactions查看反应明细、get-comment查看反应计数即可完成添加 → 查看 → 覆盖 → 移除的完整闭环。使用时要牢记两条关键约束只能操作自己的反应且同一用户对同一评论仅保留一个反应移除反应时只需将--reaction-value置为none或空值即可。【免费下载链接】aws-cliUniversal Command Line Interface for Amazon Web Services项目地址: https://gitcode.com/GitHub_Trending/aw/aws-cli创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表