pinokiod 5.0.4 → 5.0.6
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 +5 -3
- package/kernel/bin/git.js +2 -2
- package/kernel/git.js +15 -0
- package/package.json +1 -1
- package/server/index.js +16 -4
package/kernel/api/index.js
CHANGED
|
@@ -1498,9 +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
|
|
1502
|
-
if (this.kernel.git
|
|
1503
|
-
|
|
1501
|
+
// ensure gitconfig defaults 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
|
+
}
|
|
1504
1506
|
}
|
|
1505
1507
|
// init shell before running just to make sure the environment variables are fresh
|
|
1506
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
|
@@ -105,6 +105,21 @@ class Git {
|
|
|
105
105
|
await fs.promises.writeFile(gitconfigPath, ini.stringify(config))
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
+
async clearStaleLock(repoPath) {
|
|
109
|
+
if (!repoPath) return
|
|
110
|
+
const lockPath = path.resolve(repoPath, ".git", "index.lock")
|
|
111
|
+
try {
|
|
112
|
+
await fs.promises.access(lockPath, fs.constants.F_OK)
|
|
113
|
+
} catch (_) {
|
|
114
|
+
return
|
|
115
|
+
}
|
|
116
|
+
// best-effort: if no other git op is active, remove the stale lock
|
|
117
|
+
try {
|
|
118
|
+
await fs.promises.unlink(lockPath)
|
|
119
|
+
} catch (_) {
|
|
120
|
+
// ignore
|
|
121
|
+
}
|
|
122
|
+
}
|
|
108
123
|
async findGitDirs(dir, results = []) {
|
|
109
124
|
const entries = await fs.promises.readdir(dir, { withFileTypes: true });
|
|
110
125
|
for (const entry of entries) {
|
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) {
|