nrwl / nx-set-shas

:sparkles: A Github Action which sets the base and head SHAs required for `nx affected` commands in CI
https://nx.dev
MIT License
162 stars 76 forks source link

Fails When repo contains `only single` commit #95

Closed k-paxian closed 1 year ago

k-paxian commented 1 year ago

This command fails https://github.com/nrwl/nx-set-shas/blob/a89d5d812a67784a3c8ec83687f446be2d1c7e9d/find-successful-workflow.js#L50

When repo contains only single commit, so origin/master~1 can't be resolved correctly. This exceptional case must be handled gracefully.

...
WARNING: Unable to find a successful workflow run on 'origin/master'
We are therefore defaulting to use HEAD~1 on 'origin/master'

NOTE: You can instead make this a hard error by setting 'error-on-no-successful-workflow' on the action in your workflow.
fatal: ambiguous argument 'origin/master~1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
node:internal/errors:863
  const err = new Error(message);
              ^

Error: Command failed: git rev-parse origin/master~1
fatal: ambiguous argument 'origin/master~1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

    at checkExecSyncError (node:child_process:871:11)
    at execSync (node:child_process:943:15)
    at /runner/_work/_actions/nrwl/nx-set-shas/main/dist/index.js:1[37](https://github.com/newvoicemedia/omni-e2e-smoke-checker-test/actions/runs/5475685812/jobs/9972135144#step:8:39)58:20
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  status: 128,
  signal: null,
  output: [
    null,
    'origin/master~1\n',
    "fatal: ambiguous argument 'origin/master~1': unknown revision or path not in the working tree.\n" +
      "Use '--' to separate paths from revisions, like this:\n" +
      "'git <command> [<revision>...] -- [<file>...]'\n"
  ],
  pid: 23709[48](https://github.com/newvoicemedia/omni-e2e-smoke-checker-test/actions/runs/5475685812/jobs/9972135144#step:8:50),
  stdout: 'origin/master~1\n',
  stderr: "fatal: ambiguous argument 'origin/master~1': unknown revision or path not in the working tree.\n" +
    "Use '--' to separate paths from revisions, like this:\n" +
    "'git <command> [<revision>...] -- [<file>...]'\n"
}
...
k-paxian commented 1 year ago

duplicates https://github.com/nrwl/nx-set-shas/issues/84