pinokiod 5.0.5 → 5.0.7
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.
- package/kernel/api/index.js +1 -4
- package/kernel/bin/git.js +2 -2
- package/kernel/git.js +13 -4
- package/package.json +1 -1
- package/server/index.js +16 -4
package/kernel/api/index.js
CHANGED
|
@@ -1498,14 +1498,11 @@ 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 defaults
|
|
1501
|
+
// ensure gitconfig defaults before any shell commands run
|
|
1502
1502
|
if (this.kernel.git) {
|
|
1503
1503
|
if (typeof this.kernel.git.ensureDefaults === "function") {
|
|
1504
1504
|
await this.kernel.git.ensureDefaults()
|
|
1505
1505
|
}
|
|
1506
|
-
if (typeof this.kernel.git.clearStaleLock === "function") {
|
|
1507
|
-
await this.kernel.git.clearStaleLock()
|
|
1508
|
-
}
|
|
1509
1506
|
}
|
|
1510
1507
|
// init shell before running just to make sure the environment variables are fresh
|
|
1511
1508
|
await this.kernel.shell.init()
|
package/kernel/bin/git.js
CHANGED
|
@@ -52,8 +52,8 @@ class Git {
|
|
|
52
52
|
async uninstall(req, ondata) {
|
|
53
53
|
await this.kernel.bin.exec({ message: "conda remove git gh" }, ondata)
|
|
54
54
|
}
|
|
55
|
-
env() {
|
|
56
|
-
|
|
55
|
+
env(cwd) {
|
|
56
|
+
const gitconfig_path = path.resolve(this.kernel.homedir, "gitconfig")
|
|
57
57
|
return {
|
|
58
58
|
GIT_CONFIG_GLOBAL: gitconfig_path,
|
|
59
59
|
GH_CONFIG_DIR: this.kernel.path("config/gh")
|
package/kernel/git.js
CHANGED
|
@@ -40,6 +40,16 @@ class Git {
|
|
|
40
40
|
const dest = path.resolve(this.kernel.homedir, `scripts/git/${name}.json`)
|
|
41
41
|
return fs.promises.copyFile(src, dest)
|
|
42
42
|
}))
|
|
43
|
+
|
|
44
|
+
// best-effort: clear any stale index.lock files across all known repos at startup
|
|
45
|
+
try {
|
|
46
|
+
const repos = await this.repos(this.kernel.path("api"))
|
|
47
|
+
for (const repo of repos) {
|
|
48
|
+
if (repo && repo.dir) {
|
|
49
|
+
await this.clearStaleLock(repo.dir)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
} catch (_) {}
|
|
43
53
|
}
|
|
44
54
|
async ensureDefaults(homeOverride) {
|
|
45
55
|
const home = homeOverride || this.kernel.homedir
|
|
@@ -105,10 +115,9 @@ class Git {
|
|
|
105
115
|
await fs.promises.writeFile(gitconfigPath, ini.stringify(config))
|
|
106
116
|
}
|
|
107
117
|
}
|
|
108
|
-
async clearStaleLock(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const lockPath = path.resolve(home, ".git", "index.lock")
|
|
118
|
+
async clearStaleLock(repoPath) {
|
|
119
|
+
if (!repoPath) return
|
|
120
|
+
const lockPath = path.resolve(repoPath, ".git", "index.lock")
|
|
112
121
|
try {
|
|
113
122
|
await fs.promises.access(lockPath, fs.constants.F_OK)
|
|
114
123
|
} catch (_) {
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -62,10 +62,22 @@ const Info = require("../kernel/info")
|
|
|
62
62
|
|
|
63
63
|
const Setup = require("../kernel/bin/setup")
|
|
64
64
|
|
|
65
|
-
function normalize(str) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
65
|
+
function normalize(str) {
|
|
66
|
+
if (!str) return '';
|
|
67
|
+
return (str.endsWith('\n') ? str : str + '\n').replace(/\r\n/g, '\n');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this.gitEnv = (repoPath) => {
|
|
71
|
+
const gitBin = this.kernel.bin && this.kernel.bin.git ? this.kernel.bin.git : null
|
|
72
|
+
if (gitBin && typeof gitBin.env === 'function') {
|
|
73
|
+
const env = gitBin.env(repoPath)
|
|
74
|
+
if (this.kernel.git && typeof this.kernel.git.clearStaleLock === "function" && repoPath) {
|
|
75
|
+
this.kernel.git.clearStaleLock(repoPath).catch(() => {})
|
|
76
|
+
}
|
|
77
|
+
return env
|
|
78
|
+
}
|
|
79
|
+
return {}
|
|
80
|
+
}
|
|
69
81
|
|
|
70
82
|
class Server {
|
|
71
83
|
constructor(config) {
|