@monoweave/git 1.1.0 → 1.2.1
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/lib/gitCommands.d.ts +8 -1
- package/lib/gitCommands.js +20 -4
- package/package.json +2 -2
package/lib/gitCommands.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { type YarnContext } from '@monoweave/types';
|
|
2
|
+
export declare const gitUpstreamBranch: ({ cwd, context, }: {
|
|
3
|
+
cwd: string;
|
|
4
|
+
context?: YarnContext | undefined;
|
|
5
|
+
}) => Promise<string>;
|
|
2
6
|
export declare const gitCheckout: ({ files }: {
|
|
3
7
|
files: string[];
|
|
4
8
|
}, { cwd, context }: {
|
|
@@ -9,9 +13,12 @@ export declare const gitResolveSha: (ref: string, { cwd, context }: {
|
|
|
9
13
|
cwd: string;
|
|
10
14
|
context?: YarnContext | undefined;
|
|
11
15
|
}) => Promise<string>;
|
|
12
|
-
export declare const gitDiffTree: (ref: string, { cwd, context }: {
|
|
16
|
+
export declare const gitDiffTree: (ref: string, { cwd, context, onlyIncludeDeletedFiles, paths, fetch, }: {
|
|
13
17
|
cwd: string;
|
|
14
18
|
context?: YarnContext | undefined;
|
|
19
|
+
onlyIncludeDeletedFiles?: boolean | undefined;
|
|
20
|
+
paths?: string[] | undefined;
|
|
21
|
+
fetch?: boolean | undefined;
|
|
15
22
|
}) => Promise<string>;
|
|
16
23
|
export declare const gitLog: (from: string, to: string, { cwd, DELIMITER, context }: {
|
|
17
24
|
cwd: string;
|
package/lib/gitCommands.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.gitCommit = exports.gitAdd = exports.gitGlob = exports.gitLastTaggedCommit = exports.gitPush = exports.gitPull = exports.gitPushTags = exports.gitTag = exports.gitLog = exports.gitDiffTree = exports.gitResolveSha = exports.gitCheckout = void 0;
|
|
29
|
+
exports.gitCommit = exports.gitAdd = exports.gitGlob = exports.gitLastTaggedCommit = exports.gitPush = exports.gitPull = exports.gitPushTags = exports.gitTag = exports.gitLog = exports.gitDiffTree = exports.gitResolveSha = exports.gitCheckout = exports.gitUpstreamBranch = void 0;
|
|
30
30
|
const io_1 = require("@monoweave/io");
|
|
31
31
|
const logging_1 = __importStar(require("@monoweave/logging"));
|
|
32
32
|
const micromatch_1 = __importDefault(require("micromatch"));
|
|
@@ -35,11 +35,16 @@ const git = async (subcommand, { cwd, context }) => {
|
|
|
35
35
|
logging_1.default.debug(`[Exec] ${command}`, { report: context?.report });
|
|
36
36
|
return await (0, io_1.exec)(command, { cwd, env: { GIT_TERMINAL_PROMPT: '0', ...process.env } });
|
|
37
37
|
};
|
|
38
|
-
const
|
|
38
|
+
const gitUpstreamBranch = async ({ cwd, context, }) => {
|
|
39
39
|
const { stdout: branch } = await git('rev-parse --abbrev-ref --symbolic-full-name @\\{u\\}', {
|
|
40
40
|
cwd,
|
|
41
41
|
context,
|
|
42
42
|
});
|
|
43
|
+
return branch;
|
|
44
|
+
};
|
|
45
|
+
exports.gitUpstreamBranch = gitUpstreamBranch;
|
|
46
|
+
const gitCheckout = async ({ files }, { cwd, context }) => {
|
|
47
|
+
const branch = await (0, exports.gitUpstreamBranch)({ cwd, context });
|
|
43
48
|
await git(`checkout ${branch.trim()} -- ${files.map((f) => `"${f}"`).join(' ')}`, {
|
|
44
49
|
cwd,
|
|
45
50
|
context,
|
|
@@ -54,8 +59,19 @@ const gitResolveSha = async (ref, { cwd, context }) => {
|
|
|
54
59
|
return stdout.trim();
|
|
55
60
|
};
|
|
56
61
|
exports.gitResolveSha = gitResolveSha;
|
|
57
|
-
const gitDiffTree = async (ref, { cwd, context }) => {
|
|
58
|
-
|
|
62
|
+
const gitDiffTree = async (ref, { cwd, context, onlyIncludeDeletedFiles, paths, fetch = false, }) => {
|
|
63
|
+
if (fetch) {
|
|
64
|
+
await git('fetch', { cwd, context });
|
|
65
|
+
}
|
|
66
|
+
const args = ['--no-commit-id', '--name-only', '-r', '--root'];
|
|
67
|
+
if (onlyIncludeDeletedFiles) {
|
|
68
|
+
args.push('--diff-filter=D');
|
|
69
|
+
}
|
|
70
|
+
let command = `diff-tree ${args.join(' ')} ${ref.trim()}`;
|
|
71
|
+
if (paths?.length) {
|
|
72
|
+
command += ` -- ${paths.map((p) => `"${p}"`)}`;
|
|
73
|
+
}
|
|
74
|
+
const { stdout } = await git(command, {
|
|
59
75
|
cwd,
|
|
60
76
|
context,
|
|
61
77
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monoweave/git",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/monoweave/monoweave.git",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@monoweave/types": "1.1.0",
|
|
37
37
|
"@types/jest": "^29.5.12",
|
|
38
38
|
"@types/micromatch": "^4.0.6",
|
|
39
|
-
"@types/node": "^
|
|
39
|
+
"@types/node": "^20.12.2",
|
|
40
40
|
"@yarnpkg/core": "^4.0.3",
|
|
41
41
|
"@yarnpkg/fslib": "^3.0.2"
|
|
42
42
|
},
|