Fixed situations in which cwd was specified as a relative path and used with (default) commitMode: git-cli (#486)

* fix: use latest ghcommit and fix cwd for git-cli

- `cwd` was not working correctly when commitMode was set to `git-cli`,
  as it was attempting to resolve the `cwd` twice.
  (This problem only occured when specifying a relative path for `cwd`.)
- Update `ghcommit`, and avoid calling `process.chdir()` to change the
  working directory. Instead, we now pass the `cwd` option everywhere.

fixes #475

* simplify

* Apply suggestions from code review

---------

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
This commit is contained in:
Sam Lanning
2025-05-16 11:25:00 +02:00
committed by GitHub
co-authored by Mateusz Burzyński
parent 9690d7b6f2
commit 7ed1955546
6 changed files with 15 additions and 12 deletions
+1 -1
View File
@@ -117,7 +117,7 @@ export class Git {
base: {
commit: github.context.sha,
},
addFromDirectory,
cwd: this.cwd,
force: true,
});
}
+2 -6
View File
@@ -1,5 +1,6 @@
import * as core from "@actions/core";
import fs from "node:fs/promises";
import path from "node:path";
import { Git } from "./git";
import { setupOctokit } from "./octokit";
import readChangesetState from "./readChangesetState";
@@ -16,12 +17,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
return;
}
const inputCwd = getOptionalInput("cwd");
if (inputCwd) {
core.info("changing directory to the one given as the input");
process.chdir(inputCwd);
}
const cwd = inputCwd || process.cwd();
const cwd = path.resolve(getOptionalInput("cwd") ?? "");
const octokit = setupOctokit(githubToken);
const commitMode = getOptionalInput("commitMode") ?? "git-cli";