

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在 中對遞交的註解 AWS CodeCommit
<a name="how-to-commit-comment"></a>

您可以使用 CodeCommit 主控台來評論儲存庫中的遞交，以及檢視和回覆其他使用者對遞交的評論。這可協助您討論對儲存庫中進行的變更，包括：
+ 為什麼進行變更。
+ 是否需要更多變更。
+ 是否應將變更合併到另一個分支。

您可以對整體遞交、對遞交中的檔案或檔案內的特定行或變更進行評論。您也可以選取一行，然後在瀏覽器中複製產生的 URL，以連結至一行程式碼。

**注意**  
為了獲得最佳結果，請在以 IAM 使用者身分登入時使用註解。未針對使用根帳戶登入資料、聯合存取或臨時登入資料登入的使用者最佳化評論功能。

**Topics**
+ [檢視對儲存庫中遞交的評論](#how-to-commit-comment-view-console)
+ [新增和回覆對儲存庫中遞交的評論](#how-to-commit-comment-add-console)
+ [檢視、新增、更新和回覆評論 (AWS CLI)](#how-to-commit-comment-cli)

## 檢視對儲存庫中遞交的評論
<a name="how-to-commit-comment-view-console"></a>

您可以使用 CodeCommit 主控台來檢視遞交的評論。

**檢視對遞交的評論**

1. 在 https：//[https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home) 開啟 CodeCommit 主控台。

1. 在 **Repositories (儲存庫)** 中，選擇您要檢閱對遞交評論的儲存庫。

1. 在導覽窗格中，選擇 **Commits (遞交)**。選擇您想要檢視任何評論的遞交之遞交 ID。

   隨即會顯示該遞交的頁面，以及任何評論。

## 新增和回覆對儲存庫中遞交的評論
<a name="how-to-commit-comment-add-console"></a>

您可以使用 CodeCommit 主控台，將註解新增至遞交與父項的比較，或新增至兩個指定遞交之間的比較。您也可以使用表情符號、您自己的註解或兩者來回覆註解。

### 新增並回覆對遞交的評論 （主控台）
<a name="how-to-commit-comment-add-cpage"></a>

您可以使用文字和表情符號，將評論新增和回覆至遞交。您的註解和表情符號會標示為屬於您用來登入主控台的 IAM 使用者或角色。

**新增和回覆對遞交的評論**

1. 在 https：//[https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home) 開啟 CodeCommit 主控台。

1. 在 **Repositories (儲存庫)** 中，選擇您要對遞交評論所在的儲存庫。

1. 在導覽窗格中，選擇 **Commits (遞交)**。選擇您想要新增或回覆評論所在的遞交之遞交 ID。

   隨即會顯示該遞交的頁面，以及任何評論。

1. 若要新增評論，請執行以下其中一項：
   + 若要新增一般評論，請在 ​**Comments on changes (對變更加上評論)** 中，輸入評論，然後選擇 **Save (儲存)**。您可以使用 [Markdown](https://en.wikipedia.org/wiki/Markdown)，或也可以純文字輸入您的評論。  
![\[對遞交中變更的一般評論。\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-commenting-changecomment.png)
   + 若要對遞交中的檔案新增評論，請找到檔案的名稱。選擇 **Comment on file (對檔案加上評論)**，輸入您的評論，然後選擇 **Save (儲存)**。  
![\[對遞交中的檔案新增評論。\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-commenting-addfilecomment.png)
   + 若要對遞交中變更的一行新增評論，請前往變更出現的行。選擇評論氣泡![\[The comment bubble icon that that indicates that you can leave a comment on that line of code.\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-commentbubble.png)，輸入您的評論，然後選擇 **Save (儲存)**。  
![\[對遞交中的一行新增評論。\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-commenting-addlinecomment.png)
**注意**  
在儲存評論之後，您可以編輯評論，也可以刪除其內容。該評論將保留一則訊息，指出內容已遭刪除。考慮為您的評論使用 **Preview markdown (預覽 Markdown)** 模式，之後再進行儲存。

1. 若要回覆對遞交的評論，請選擇 **Reply (回覆)**。若要使用表情符號回覆評論，請從清單中選擇您想要的表情符號。每個註解只能選擇一個表情符號。如果您想要變更表情符號反應，請選擇與清單不同的表情符號反應，或選擇**無**以移除您的反應。  
![\[將回應和表情符號反應新增至註解。\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-commenting-commenttab.png)

### 在比較兩個遞交指標時新增和回覆註解
<a name="how-to-commit-comment-console-compare"></a>

您可以對分支、標籤或遞交之間的比較新增評論。

**比較遞交指標時新增和回覆評論**

1. 在 https：//[https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home) 開啟 CodeCommit 主控台。

1. 在 **Repositories (儲存庫)** 中，選擇您要比較遞交、分支或附加標籤之遞交所在的儲存庫。

1. 在導覽窗格中，選擇 **Commits (遞交)**，然後選擇 **Compare commits (比較遞交)** 索引標籤。  
![\[比較任兩個遞交指標\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-compare-1.png)

1. 使用 **Destination (目的地)** 和 **Source (來源)** 欄位來比較兩個遞交指標。使用下拉式清單或貼上遞交 ID。選擇 **Compare (比較)**。  
![\[將遞交 ID 與分支比較的範例結果\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-compare-4.png)

1. 執行下列其中一項或多項：
   + 若要將新增評論到檔案或行，請選擇評論氣泡 ![\[The comment bubble icon that that indicates that you can leave a comment on that line of code.\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-commentbubble.png)。
   + 若要對比較的變更新增一般評論，請移至 **Comments on changes (對變更的評論)**。

## 檢視、新增、更新和回覆評論 (AWS CLI)
<a name="how-to-commit-comment-cli"></a>

您可以透過執行下列命令來檢視、新增、回覆、更新和刪除評論的內容：
+ 若要檢視兩個遞交間比較的評論，請執行 **[get-comments-for-compared-commit](#how-to-commit-comment-cli-get-comments)**。
+ 若要檢視評論的詳細資訊，請執行 [**get-comment**](#how-to-commit-comment-cli-get-comment-info)。
+ 若要刪除您建立的評論內容，請執行 [**delete-comment-content**](#how-to-commit-comment-cli-commit-delete)。
+ 若要對兩個遞交間的比較建立評論，請執行 [**post-comment-for-compared-commit**](#how-to-commit-comment-cli-comment)。
+ 若要更新評論，請執行 [**update-comment**](#how-to-commit-comment-cli-commit-update)。
+ 若要回覆註解，請執行 [**post-comment-reply**](#how-to-commit-comment-cli-commit-reply)。
+ 若要使用表情符號回覆註解，請執行 [**put-comment-reaction**](#how-to-commit-comment-cli-commit-reply-emoji)。
+ 若要檢視註解的表情符號反應，請執行 [**get-comment-reactions**](#how-to-commit-comment-cli-commit-emoji-view)。

### 檢視對遞交的評論
<a name="how-to-commit-comment-cli-get-comments"></a>

1. 執行 **get-comments-for-compared-commit** 命令，並指定：
   + CodeCommit 儲存庫的名稱 （使用 `--repository-name`選項）。
   + 之後遞交的完整遞交 ID，以建立比較的方向性 (使用 `--after-commit-id option`)。
   + 之前遞交的完整遞交 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
   ```

1. 如果此命令成功執行，您會看到類似如下的輸出產生：

   ```
   {
      "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"
   }
   ```

### 檢視對遞交評論的詳細資訊
<a name="how-to-commit-comment-cli-get-comment-info"></a>

1. 執行 **get-comment** 命令，指定系統產生的評論 ID。例如：

   ```
   aws codecommit get-comment --comment-id ff30b348EXAMPLEb9aa670f
   ```

1. 如果此命令成功執行，您會看到類似如下的輸出傳回：

   ```
   {
      "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
            }
      }
   }
   ```

### 刪除對遞交評論的內容
<a name="how-to-commit-comment-cli-commit-delete"></a>

1. 執行 **delete-comment-content** 命令，指定系統產生的評論 ID。例如：

   ```
   aws codecommit delete-comment-content --comment-id ff30b348EXAMPLEb9aa670f
   ```
**注意**  
只有在套用 AWSCodeCommitFullAccess 政策，或將`DeleteCommentContent`許可設定為**允許**時，才能刪除評論的內容。

1. 如果此命令成功執行，您會看到類似如下的輸出產生：

   ```
   {
      "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
            }
      }
   }
   ```

### 建立對遞交的評論
<a name="how-to-commit-comment-cli-comment"></a>

1. 執行 **post-comment-for-compared-commit** 命令，並指定：
   + CodeCommit 儲存庫的名稱 （使用 `--repository-name`選項）。
   + 之後遞交的完整遞交 ID，以建立比較的方向性 (使用 `--after-commit-id ` 選項)。
   + 之前遞交的完整遞交 ID，以建立比較的方向性 (使用 `--before-commit-id` 選項)。
   + 唯一的用戶端產生冪等符記 (使用 **--client-request-token** 選項)。
   + 評論的內容 (使用 **--content** 選項)。
   + 可放置評論位置的清單位置相關資訊，包括：
     + 要比較的檔案名稱，包括其副檔名和子目錄 (如果有) (使用 **filePath** 屬性)。
     + 比較檔案內變更的行號 (使用 **filePosition** 屬性)。
     + 對變更的評論在來源與目的地分支之間的比較中為之前或之後 (使用 **relativeFileVersion** 屬性)。

   例如，若要新增註解*「您可以為此新增測試案例嗎？」* 在名為 *MyDemoRepo* 的儲存庫中兩個遞交之間的比較中，*cl\$1sample.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   
   ```

1. 如果此命令成功執行，您會看到類似如下的輸出產生：

   ```
   { 
            "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"
    }
   ```

### 更新對遞交的評論
<a name="how-to-commit-comment-cli-commit-update"></a>

1. 執行 **update-comment** 命令，指定系統產生的評論 ID 和您要用來取代任何現有內容的內容。

   例如，若要新增內容 *"Fixed as requested. 我將更新提取請求。」* 至 ID 為 *442b498bEXAMPLE5756813* 的註解：

   ```
   aws codecommit update-comment --comment-id 442b498bEXAMPLE5756813 --content "Fixed as requested. I'll update the pull request."  
   ```

1. 如果此命令成功執行，您會看到類似如下的輸出產生：

   ```
   { 
       "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
             }
       }
    }
   ```

### 回覆對遞交的評論
<a name="how-to-commit-comment-cli-commit-reply"></a>

1. 若要對提取請求中的評論張貼回覆，請執行 **post-comment-reply** 命令，指定：
   + 您要回覆的評論由系統產生的 ID (使用 **--in-reply-to** 選項)。
   + 唯一的用戶端產生冪等符記 (使用 **--client-request-token** 選項)。
   + 回覆的內容 (使用 **--content** 選項)。

    例如，若要新增「*良好捕獲」回覆。我將移除它們。」* 至系統產生的 ID 為 *abcd1234EXAMPLEb5678efgh* 的註解：

   ```
   aws codecommit post-comment-reply --in-reply-to abcd1234EXAMPLEb5678efgh --content "Good catch. I'll remove them." --client-request-token 123Example
   ```

1. 如果此命令成功執行，您會看到類似如下的輸出產生：

   ```
   { 
       "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": []
       }
    }
   ```

### 使用表情符號回覆對遞交的評論
<a name="how-to-commit-comment-cli-commit-reply-emoji"></a>

1. 若要使用表情符號回覆提取請求中的註解，或變更表情符號反應的值，請執行 **put-comment-reaction**命令，指定：
   + 您要以表情符號回覆之註解的系統產生 ID。
   + 您要新增或更新的反應值。可接受的值包括支援的表情符號、短碼和 Unicode 值。<a name="emoji-reaction-table"></a>

   CodeCommit 中的表情符號支援下列值：  
****    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/how-to-commit-comment.html)

    例如，若要將表情符號 *：thumbsup：* 新增至系統產生的 ID 為 *abcd1234EXAMPLEb5678efgh* 的註解：

   ```
   aws codecommit put-comment-reaction --comment-id abcd1234EXAMPLEb5678efgh --reaction-value :thumbsup: 
   ```

1. 如果成功，此命令就不會產生輸出。

### 檢視對註解的表情符號反應
<a name="how-to-commit-comment-cli-commit-emoji-view"></a>

1. 若要檢視對註解的表情符號反應，包括與這些表情符號做出反應的使用者，請執行 **get-comment-reactions**命令，指定系統產生的註解 ID。

    例如，若要檢視系統產生 ID 為 *abcd1234EXAMPLEb5678efgh* 之註解的表情符號反應：

   ```
   aws codecommit get-comment-reactions --comment-id abcd1234EXAMPLEb5678efgh 
   ```

1. 如果此命令成功執行，您會看到類似如下的輸出產生：

   ```
   {
       "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"
                   ]
               }
           ]
       }
   }
   ```