pinokiod 5.0.4 → 5.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1498,9 +1498,14 @@ class Api {
1498
1498
  // let keypath = path.resolve(this.kernel.homedir, "key.json")
1499
1499
  // this.kernel.keys = (await this.loader.load(keypath)).resolved
1500
1500
 
1501
- // ensure gitconfig carries required defaults before any shell commands run
1502
- if (this.kernel.git && typeof this.kernel.git.ensureDefaults === "function") {
1503
- await this.kernel.git.ensureDefaults()
1501
+ // ensure gitconfig defaults and clear stale git locks before any shell commands run
1502
+ if (this.kernel.git) {
1503
+ if (typeof this.kernel.git.ensureDefaults === "function") {
1504
+ await this.kernel.git.ensureDefaults()
1505
+ }
1506
+ if (typeof this.kernel.git.clearStaleLock === "function") {
1507
+ await this.kernel.git.clearStaleLock()
1508
+ }
1504
1509
  }
1505
1510
  // init shell before running just to make sure the environment variables are fresh
1506
1511
  await this.kernel.shell.init()
package/kernel/git.js CHANGED
@@ -105,6 +105,22 @@ class Git {
105
105
  await fs.promises.writeFile(gitconfigPath, ini.stringify(config))
106
106
  }
107
107
  }
108
+ async clearStaleLock(homeOverride) {
109
+ const home = homeOverride || this.kernel.homedir
110
+ if (!home) return
111
+ const lockPath = path.resolve(home, ".git", "index.lock")
112
+ try {
113
+ await fs.promises.access(lockPath, fs.constants.F_OK)
114
+ } catch (_) {
115
+ return
116
+ }
117
+ // best-effort: if no other git op is active, remove the stale lock
118
+ try {
119
+ await fs.promises.unlink(lockPath)
120
+ } catch (_) {
121
+ // ignore
122
+ }
123
+ }
108
124
  async findGitDirs(dir, results = []) {
109
125
  const entries = await fs.promises.readdir(dir, { withFileTypes: true });
110
126
  for (const entry of entries) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "5.0.4",
3
+ "version": "5.0.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {