在 AWS CodeCommit 中对提交进行评论 - AWS CodeCommit

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

在 AWS CodeCommit 中对提交进行评论

您可以使用 CodeCommit 控制台对仓库中的提交进行评论,以及查看和回复其他用户对提交的评论。这可以帮助您讨论在存储库中进行的更改,包括:

  • 进行更改的原因。

  • 是否需要进行多处更改。

  • 是否应将更改合并到其他分支中。

您可以对整个提交、提交中的某个文件或文件中特定的行或更改发表评论。您也可以通过以下方式链接到一行代码:选择一行,然后在浏览器中复制生成的 URL。

注意

为了获得最佳结果,请在以 IAM 用户身份登录时使用评论功能。评论功能并未针对用根账户凭证、联合访问或临时凭证登录的用户进行优化。

查看对存储库中的提交的评论

您可以使用 CodeCommit 控制台查看对提交的评论。

查看对提交进行的评论
  1. 打开 CodeCommit 控制台,网址为 https://console.aws.amazon.com/codesuite/codecommit/home

  2. 存储库中,选择要查看对其提交进行的评论的存储库。

  3. 在导航窗格中,选择 Commits。选择您要查看任何评论的提交的提交 ID。

    该提交的页面将与任何评论一起显示。

在存储库中添加和回复对提交的评论

您可以使用 CodeCommit 控制台为提交和父提交的比较或两个指定提交之间的比较添加注释。您还可以使用表情符号和/或您自己的评论来回复评论。

添加和回复对提交的评论(控制台)

您可以使用文本和表情符号添加和回复对提交的评论。您的评论和表情符号将标记为属于用于登录控制台的 IAM 用户或角色。

添加和回复对提交进行的评论
  1. 打开 CodeCommit 控制台,网址为 https://console.aws.amazon.com/codesuite/codecommit/home

  2. 存储库中,选择要在其中对提交进行评论的存储库。

  3. 在导航窗格中,选择 Commits。选择您要在其中添加或回复评论的提交的提交 ID。

    该提交的页面将与任何评论一起显示。

  4. 要添加评论,请执行以下操作之一:

    • 要添加一般评论,请在对更改的评论中输入评论,然后选择保存。您可以使用 Markdown,也可以纯文本格式输入评论。

      
                  对提交中更改的一般评论。
    • 要向提交中的文件添加评论,请找到该文件的名称。选择对文件的评论,输入评论,然后选择保存

      
                  对提交中的文件添加评论。
    • 要向提交中的已更改行添加评论,请转到显示更改的行。选择评论气泡 ,输入评论,然后选择保存

      
                  对提交中的行添加评论。
    注意

    您可以在保存评论后编辑它。您也可以删除其内容。评论将保留一条消息,说明内容已被删除。请考虑在保存您的评论之前为该评论使用预览 markdown 模式。

  5. 要回复对提交的评论,请选择回复。要使用表情符号回复评论,请从列表中选择所需的表情符号。每条评论只能选择一个表情符号。如果要更改表情符号反应,请从列表中选择其他表情符号,或选择以删除反应。

    
            在评论中添加回复和表情符号反应。

在比较两个提交说明符时添加和回复评论

您可以向两个分支、标签或提交之间的比较添加评论。

在比较提交说明符时添加或回复评论
  1. 打开 CodeCommit 控制台,网址为 https://console.aws.amazon.com/codesuite/codecommit/home

  2. 存储库中,选择要比较提交、分支或已标记提交的存储库。

  3. 在导航窗格中,选择提交,然后选择比较提交选项卡。

    
              比较任意两个提交说明符
  4. 使用目标字段来比较两个提交说明符。使用下拉列表或粘贴提交 ID。选择 Compare

    
              将提交 ID 与分支比较时的示例结果
  5. 执行以下一个或多个操作:

    • 要添加对文件或行的评论,请选择评论气泡

    • 要添加对所比较更改的一般评论,请转到 Comments on changes

查看、添加、更新和回复评论 (AWS CLI)

您可以通过运行以下命令来查看、添加、回复、更新和删除评论内容:

查看对提交进行的评论

  1. 运行 get-comments-for-compared-commit 命令,并指定:

    • CodeCommit 存储库的名称(带--repository-name选项)。

    • “after”提交的完整提交 ID,用于建立比较的方向性(使用 --after-commit-id option)。

    • “before”提交的完整提交 ID,用于建立比较的方向性(使用 --before-commit-id 选项)。

    • (可选)要返回下一批结果的枚举令牌(使用 --next-token 选项)。

    • (可选) 一个用于限制返回的结果数的非负整数 (使用 --max-results 选项)。

    例如,要查看对名为 MyDemoRepo 的存储库中两个提交之间的比较做出的评论,请运行以下命令:

    aws codecommit get-comments-for-compared-commit --repository-name MyDemoRepo --before-commit-ID 6e147360EXAMPLE --after-commit-id 317f8570EXAMPLE
  2. 如果成功,该命令产生类似以下内容的输出:

    { "commentsForComparedCommitData": [ { "afterBlobId": "1f330709EXAMPLE", "afterCommitId": "317f8570EXAMPLE", "beforeBlobId": "80906a4cEXAMPLE", "beforeCommitId": "6e147360EXAMPLE", "comments": [ { "authorArn": "arn:aws:iam::111111111111:user/Li_Juan", "clientRequestToken": "123Example", "commentId": "ff30b348EXAMPLEb9aa670f", "content": "Whoops - I meant to add this comment to the line, not the file, but I don't see how to delete it.", "creationDate": 1508369768.142, "deleted": false, "CommentId": "123abc-EXAMPLE", "lastModifiedDate": 1508369842.278, "callerReactions": [], "reactionCounts": { "SMILE" : 6, "THUMBSUP" : 1 } }, { "authorArn": "arn:aws:iam::111111111111:user/Li_Juan", "clientRequestToken": "123Example", "commentId": "553b509bEXAMPLE56198325", "content": "Can you add a test case for this?", "creationDate": 1508369612.240, "deleted": false, "commentId": "456def-EXAMPLE", "lastModifiedDate": 1508369612.240, "callerReactions": [], "reactionCounts": { "THUMBSUP" : 2 } } ], "location": { "filePath": "cl_sample.js", "filePosition": 1232, "relativeFileVersion": "after" }, "repositoryName": "MyDemoRepo" } ], "nextToken": "exampleToken" }

查看提交评论的详细信息

  1. 运行 get-comment 命令,并指定系统生成的评论 ID。例如:

    aws codecommit get-comment --comment-id ff30b348EXAMPLEb9aa670f
  2. 如果成功,该命令返回类似以下内容的输出:

    { "comment": { "authorArn": "arn:aws:iam::111111111111:user/Li_Juan", "clientRequestToken": "123Example", "commentId": "ff30b348EXAMPLEb9aa670f", "content": "Whoops - I meant to add this comment to the line, but I don't see how to delete it.", "creationDate": 1508369768.142, "deleted": false, "commentId": "", "lastModifiedDate": 1508369842.278, "callerReactions": [], "reactionCounts": { "SMILE" : 6, "THUMBSUP" : 1 } } }

删除提交评论的内容

  1. 运行 delete-comment-content 命令,并指定系统生成的评论 ID。例如:

    aws codecommit delete-comment-content --comment-id ff30b348EXAMPLEb9aa670f
    注意

    只有在应用了 AWSCodeCommitFullAccess 策略或将DeleteCommentContent权限设置为 “许” 的情况下,您才能删除评论的内容。

  2. 如果成功,该命令产生类似以下内容的输出:

    { "comment": { "creationDate": 1508369768.142, "deleted": true, "lastModifiedDate": 1508369842.278, "clientRequestToken": "123Example", "commentId": "ff30b348EXAMPLEb9aa670f", "authorArn": "arn:aws:iam::111111111111:user/Li_Juan", "callerReactions": [], "reactionCounts": { "CLAP" : 1 } } }

创建提交评论

  1. 运行 post-comment-for-compared-commit 命令,并指定:

    • CodeCommit 存储库的名称(带--repository-name选项)。

    • “after”提交的完整提交 ID,用于建立比较的方向性(使用 --after-commit-id 选项)。

    • “before”提交的完整提交 ID,用于建立比较的方向性(使用 --before-commit-id 选项)。

    • 客户端生成的唯一等幂令牌(使用 --client-request-token 选项)。

    • 您的评论的内容(使用 --content 选项)。

    • 有关评论放置位置信息的列表,包括:

      • 所比较文件的名称,包括其扩展名和子目录(如果有,则使用 filePath 属性)。

      • 在比较文件中更改的行号(使用 filePosition 属性)。

      • 对更改的评论在源分支与目标分支之间比较“之前”还是“之后”(使用 relativeFileVersion 属性)。

    例如,要添加评论 "Can you add a test case for this?" 关于比较名为 MyDemoRepo:的存储库中两次提交时对 cl_sample.js 文件的更改

    aws codecommit post-comment-for-compared-commit --repository-name MyDemoRepo --before-commit-id 317f8570EXAMPLE --after-commit-id 5d036259EXAMPLE --client-request-token 123Example --content "Can you add a test case for this?" --location filePath=cl_sample.js,filePosition=1232,relativeFileVersion=AFTER
  2. 如果成功,该命令产生类似以下内容的输出:

    { "afterBlobId": "1f330709EXAMPLE", "afterCommitId": "317f8570EXAMPLE", "beforeBlobId": "80906a4cEXAMPLE", "beforeCommitId": "6e147360EXAMPLE", "comment": { "authorArn": "arn:aws:iam::111111111111:user/Li_Juan", "clientRequestToken": "", "commentId": "553b509bEXAMPLE56198325", "content": "Can you add a test case for this?", "creationDate": 1508369612.203, "deleted": false, "commentId": "abc123-EXAMPLE", "lastModifiedDate": 1508369612.203, "callerReactions": [], "reactionCounts": [] }, "location": { "filePath": "cl_sample.js", "filePosition": 1232, "relativeFileVersion": "AFTER" }, "repositoryName": "MyDemoRepo" }

更新提交评论

  1. 运行 update-comment 命令,并指定要替换任何现有内容的系统生成的评论 ID 和内容。

    例如,要将内容 "Fixed as requested. I'll update the pull request." 添加到 ID 为 442b498bEXAMPLE5756813 的评论,请运行以下命令:

    aws codecommit update-comment --comment-id 442b498bEXAMPLE5756813 --content "Fixed as requested. I'll update the pull request."
  2. 如果成功,该命令产生类似以下内容的输出:

    { "comment": { "authorArn": "arn:aws:iam::111111111111:user/Li_Juan", "clientRequestToken": "", "commentId": "442b498bEXAMPLE5756813", "content": "Fixed as requested. I'll update the pull request.", "creationDate": 1508369929.783, "deleted": false, "lastModifiedDate": 1508369929.287, "callerReactions": [], "reactionCounts": { "THUMBSUP" : 2 } } }

回复提交评论

  1. 要在拉取请求中发布对评论的回复,请运行 post-comment-reply 命令,并且指定:

    • 要回复的评论的系统生成的 ID(使用 --in-reply-to 选项)。

    • 客户端生成的唯一等幂令牌(使用 --client-request-token 选项)。

    • 您的回复的内容(使用 --content 选项)。

    例如,要将回复 "Good catch. I'll remove them." 添加到系统生成的 ID 为 abcd1234EXAMPLEb5678efgh 的评论,请运行以下命令:

    aws codecommit post-comment-reply --in-reply-to abcd1234EXAMPLEb5678efgh --content "Good catch. I'll remove them." --client-request-token 123Example
  2. 如果成功,该命令产生类似以下内容的输出:

    { "comment": { "authorArn": "arn:aws:iam::111111111111:user/Li_Juan", "clientRequestToken": "123Example", "commentId": "442b498bEXAMPLE5756813", "content": "Good catch. I'll remove them.", "creationDate": 1508369829.136, "deleted": false, "CommentId": "abcd1234EXAMPLEb5678efgh", "lastModifiedDate": 150836912.221, "callerReactions": [], "reactionCounts": [] } }

使用表情符号回复对提交的评论

  1. 要使用表情符号回复拉取请求中的评论,或者要更改表情符号反应的值,请运行 put-comment-reaction 命令,指定以下内容:

    • 要使用表情符号回复的评论的系统生成的 ID。

    • 要添加或更新的反应的值。可接受的值包括支持的表情符号、简码和 Unicode 值。

    中的表情符号支持以下值: CodeCommit

    表情符号 短代码 Unicode

    👍

    :thumbsup:

    U+1F44D

    👎

    :thumbsdown:

    U+1F44E

    😄

    :smile:

    U+1F604

    :heart:

    U+2764

    😠

    :angry:

    U+1F620

    😕

    :confused:

    U+1F615

    😱

    :scream:

    U+1F631

    😭

    :sob:

    U+1F62D

    👏

    :clap:

    U+1F44F

    🎊

    :confetti_ball:

    U+1F38A

    🚢

    :ship:

    U+1F6A2

    👀

    :eyes:

    U+1F440

    none

    U+0000

    例如,要将表情符号 :thumbsup: 添加到系统生成的 ID 为 abcd1234EXAMPLEb5678efgh 的评论,请运行以下命令:

    aws codecommit put-comment-reaction --comment-id abcd1234EXAMPLEb5678efgh --reaction-value :thumbsup:
  2. 如果成功,此命令不会产生任何输出。

查看对评论的表情符号反应

  1. 要查看对评论的表情符号反应(包括使用这些表情符号做出了反应的用户),请运行 get-comment-reactions 命令,指定评论的系统生成的 ID。

    例如,要将表情符号反应添加到系统生成的 ID 为 abcd1234EXAMPLEb5678efgh 的评论,请运行以下命令:

    aws codecommit get-comment-reactions --comment-id abcd1234EXAMPLEb5678efgh
  2. 如果成功,该命令产生类似以下内容的输出:

    { "reactionsForComment": { [ { "reaction": { "emoji:"👍", "shortCode": "thumbsup", "unicode": "U+1F44D" }, "users": [ "arn:aws:iam::123456789012:user/Li_Juan", "arn:aws:iam::123456789012:user/Mary_Major", "arn:aws:iam::123456789012:user/Jorge_Souza" ] }, { "reaction": { "emoji": "👎", "shortCode": "thumbsdown", "unicode": "U+1F44E" }, "users": [ "arn:aws:iam::123456789012:user/Nikhil_Jayashankar" ] }, { "reaction": { "emoji": "😕", "shortCode": "confused", "unicode": "U+1F615" }, "users": [ "arn:aws:iam::123456789012:user/Saanvi_Sarkar" ] } ] } }