CodeCommit: What would be the way to get change count for a Commit?

0

Get Commit API does not return any information on change count for a commit say added/modified/deleted lines.

https://docs.aws.amazon.com/codecommit/latest/APIReference/API_Commit.html

I see there is a getDifference API which returns only before and after BLOBs and changeType only and a getBlob API that returns base64 encoded file.

https://docs.aws.amazon.com/codecommit/latest/APIReference/API_GetDifferences.html https://docs.aws.amazon.com/codecommit/latest/APIReference/API_GetBlob.html

The only way i can think of to get change count is use GetDifferences API to get Blobs and use GetBlob API to get files and do a decode and use any filecompare util API to get change count which is too much to achieve a very simple thing easily available in response for a commit detail in other providers like git/azure repos.

Is there anything i am missing, can you give me pointers?

質問済み 1年前288ビュー
1回答
0

I would suggest using git commands to pull this information.

The git diff subcommand supports a --stat argument which will give you the summary of changes, with the number of changed files, along with the number of lines added, modified, or deleted.

Here are some examples, using the aws-cdk repo:

  • Changes between most recent commit and previous commit:
$ git diff --stat HEAD^1..HEAD
 packages/@aws-cdk/aws-customerprofiles/package.json | 1 +
 packages/@aws-cdk/aws-groundstation/package.json    | 1 +
 packages/@aws-cdk/aws-lookoutmetrics/package.json   | 1 +
 3 files changed, 3 insertions(+)
  • Changes between two tagged releases:
$ git diff --stat v2.68.0..v2.69.0
(I have omitted the first bit of the output here for brevity)
 packages/cdk-assets/test/docker-images.test.ts                                       |  139 +++++
 tools/@aws-cdk/eslint-plugin/lib/rules/invalid-cfn-imports.ts                        |    2 +-
 tools/@aws-cdk/individual-pkg-gen/transform-packages.ts                              |    6 +-
 tools/@aws-cdk/pkglint/lib/rules.ts                                                  |   24 -
 tools/@aws-cdk/prlint/test/module.test.ts                                            |    3 -
 version.v2.json                                                                      |    4 +-
 400 files changed, 10821 insertions(+), 7443 deletions(-)

As you can see, this gives you the total changes in summary, and also shows you a breakdown per file.

[1] https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---statltwidthgtltname-widthgtltcountgt

AWS
サポートエンジニア
Wayne_G
回答済み 1年前
  • Thanks for response. But i'm looking for a solution with which i can get the diff info from REST APIs.

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ