querysub 0.277.0 → 0.279.0
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/package.json +1 -1
- package/src/4-deploy/git.ts +16 -8
package/package.json
CHANGED
package/src/4-deploy/git.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { runPromise } from "../functional/runCommand";
|
|
|
4
4
|
import { measureWrap } from "socket-function/src/profiling/measure";
|
|
5
5
|
import fs from "fs";
|
|
6
6
|
import os from "os";
|
|
7
|
+
import path from "path";
|
|
7
8
|
export async function getGitURLLive(gitDir = ".") {
|
|
8
9
|
return (await runPromise(`git remote get-url origin`, { cwd: gitDir })).trim();
|
|
9
10
|
}
|
|
@@ -24,15 +25,22 @@ export async function commitAndPush(config: {
|
|
|
24
25
|
gitDir: string;
|
|
25
26
|
message: string;
|
|
26
27
|
}) {
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
// Use a file to handle newlines, etc
|
|
29
|
+
const tempFile = path.join(os.tmpdir(), `commit-message-${Date.now()}-${Math.random().toString(36).substr(2, 9)}.txt`);
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
await fs.promises.writeFile(tempFile, config.message, 'utf8');
|
|
33
|
+
await runPromise(`git add --all`, { cwd: config.gitDir });
|
|
34
|
+
await runPromise(`git commit -F "${tempFile}"`, { cwd: config.gitDir });
|
|
35
|
+
await runPromise(`git push`, { cwd: config.gitDir });
|
|
36
|
+
} finally {
|
|
37
|
+
// Clean up temporary file
|
|
38
|
+
try {
|
|
39
|
+
await fs.promises.unlink(tempFile);
|
|
40
|
+
} catch {
|
|
41
|
+
// Ignore cleanup errors
|
|
42
|
+
}
|
|
32
43
|
}
|
|
33
|
-
await runPromise(`git add --all`, { cwd: config.gitDir });
|
|
34
|
-
await runPromise(`git commit -m "${escapeArg(config.message)}"`, { cwd: config.gitDir });
|
|
35
|
-
await runPromise(`git push`, { cwd: config.gitDir });
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
export async function getGitRefInfo(config: {
|