Skip to content

Commit 7ed1955

Browse files
s0Andarist
andauthored
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>
1 parent 9690d7b commit 7ed1955

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

.changeset/lemon-garlics-sell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@changesets/action": patch
3+
---
4+
5+
Fixed situations in which `cwd` was specified as a relative path and used with (default) `commitMode: git-cli`
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"@actions/core": "^1.11.1",
3434
"@actions/exec": "^1.1.1",
3535
"@actions/github": "^6.0.1",
36-
"@changesets/ghcommit": "1.4.0",
36+
"@changesets/ghcommit": "^2.0.0",
3737
"@changesets/pre": "^1.0.9",
3838
"@changesets/read": "^0.5.3",
3939
"@manypkg/get-packages": "^1.1.3",

src/git.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export class Git {
117117
base: {
118118
commit: github.context.sha,
119119
},
120-
addFromDirectory,
120+
cwd: this.cwd,
121121
force: true,
122122
});
123123
}

src/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as core from "@actions/core";
22
import fs from "node:fs/promises";
3+
import path from "node:path";
34
import { Git } from "./git";
45
import { setupOctokit } from "./octokit";
56
import readChangesetState from "./readChangesetState";
@@ -16,12 +17,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
1617
return;
1718
}
1819

19-
const inputCwd = getOptionalInput("cwd");
20-
if (inputCwd) {
21-
core.info("changing directory to the one given as the input");
22-
process.chdir(inputCwd);
23-
}
24-
const cwd = inputCwd || process.cwd();
20+
const cwd = path.resolve(getOptionalInput("cwd") ?? "");
2521

2622
const octokit = setupOctokit(githubToken);
2723
const commitMode = getOptionalInput("commitMode") ?? "git-cli";

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@
219219
resolved "https://registry.yarnpkg.com/@changesets/get-version-range-type/-/get-version-range-type-0.3.2.tgz#8131a99035edd11aa7a44c341cbb05e668618c67"
220220
integrity sha512-SVqwYs5pULYjYT4op21F2pVbcrca4qA/bAA3FmFXKMN7Y+HcO8sbZUTx3TAy2VXulP2FACd1aC7f2nTuqSPbqg==
221221

222-
"@changesets/ghcommit@1.4.0":
223-
version "1.4.0"
224-
resolved "https://registry.yarnpkg.com/@changesets/ghcommit/-/ghcommit-1.4.0.tgz#61a8bcdad1e78140ad69b6c6980e9c82471c8993"
225-
integrity sha512-gG4QZsMwply4wFxqjfO7oI70lAb579zRbKB2EgjkVo+olWzXvmcQb52zkLpL3L9+QrAGD0QP8fNER9Wn3CmcHw==
222+
"@changesets/ghcommit@^2.0.0":
223+
version "2.0.0"
224+
resolved "https://registry.yarnpkg.com/@changesets/ghcommit/-/ghcommit-2.0.0.tgz#a3d8f733ad7ec9bb1f17c7dc0b64c3f62636305f"
225+
integrity sha512-UFS7mCjh3B8KfiDQi6JbZNDoANdTqLgBKHCwMASZ25A3yfxaFVKURGzwdMdlcYx5k6dHN1igDHzgXuwOyZ9xKg==
226226
dependencies:
227227
isomorphic-git "^1.27.1"
228228

0 commit comments

Comments
 (0)