Github author information

0

I'm using Github as a source in code build and using webhook (PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED, PULL_REQUEST_REOPENED), but when I generate a pull request or update a pull request I want to access the last commit author info ( author name and email )

I'm using the command: git log -1 --format="%an <%ae>" But it will throw an error

[Container] 2022/07/08 18:17:46 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing the command: git log -1 --format="%an <%ae>". Reason: exit status 128

I'm not able to access author info based on the last commit

asked 2 years ago401 views
2 Answers
0
Accepted Answer

The error you're getting sounds like it could have something to do the clone depth on CodeBuild, which by default is 1.

In your build project, try Edit > Source, expanding the additional configuration, and try changing the Git clone depth to Full to begin with. If that works, you might be able to reduce the depth to speed up the build.

Ed
answered 2 years ago
0

Exit status 128 can mean a number of things. Do you get any other messages above that line in the logs? There should be a more verbose error message that might help.

It should look something like this:

[Container] 2022/01/01 00:00:00 Running command git log -1 --format="%an <%ae>" --test
fatal: unrecognized argument: --test
Ed
answered 2 years ago
  • [Container] 2022/07/08 18:17:46 Phase complete: PRE_BUILD State: SUCCEEDED [Container] 2022/07/08 18:17:46 Phase context status code: Message: [Container] 2022/07/08 18:17:46 Entering phase BUILD [Container] 2022/07/08 18:17:46 Running command git log -1 --format="%an <%ae>" error: Could not read 426258ef330179881b171f345ec12f1fbd323251 fatal: Failed to traverse parents of commit 6c63149a5858f3c6ad8f05f2db9be0869b879d8f

    [Container] 2022/07/08 18:17:46 Command did not exit successfully git log -1 --format="%an <%ae>" exit status 128 [Container] 2022/07/08 18:17:46 Phase complete: BUILD State: FAILED [Container] 2022/07/08 18:17:46 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: git log -1 --format="%an <%ae>". Reason: exit status 128 [Container] 2022/07/08 18:17:46 Entering phase POST_BUILD [Container] 2022/07/08 18:17:46 Phase complete: POST_BUILD State: SUCCEEDED [Container] 2022/07/08 18:17:46 Phase context status code: Message:

  • this is my latest commit 6c63149a5858f3c6ad8f05f2db9be0869b879d8f And after commit, this code build will trigger, but I'm not able to access author name and email from latest commit

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions