Git command not returning expected results from inside a JavaScript action

Hi all. From my command line, if I execute the following two commands (to print the filenames in a commit), they return the expected output:

$ git log -1 --name-only --pretty=format: c0ddab
lib/ow/css.js

$ git log -1 --name-only --pretty=format: fc3039
.github/workflows/github-actions-demo.yml

But if I try to do the same from inside a JavaScript GitHub Action, it does not return the same–it returns:

/usr/bin/git log -1 --name-only --pretty=format: c0ddab
 c0ddab
.github/workflows/github-actions-demo.yml

/usr/bin/git log -1 --name-only --pretty=format: fc3039
 fc3039
.github/workflows/github-actions-demo.yml

Anyone know why that’s happening or how I can troubleshoot?

Here is the full code from my JavaScript Action


index.js

const exec = require("@actions/exec");

async function myAAFunc() {

  let commitSha;

  const options = {};

  commitSha = "c0ddab";

  await exec.exec(

    "git",

    ["log", "-1", "--name-only", `--pretty=format: ${commitSha}`],

    options

  );

 

  commitSha = "fc3039";

  await exec.exec(

    "git",

    ["log", "-1", "--name-only", `--pretty=format: ${commitSha}`],

    options

  );

}

myAAFunc();