safe-push 0.5.0 → 0.7.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/.claude/settings.local.json +4 -3
- package/dist/index.js +21 -6
- package/package.json +1 -1
- package/src/checker.ts +1 -1
- package/src/git.ts +23 -3
- package/dist/mcp.js +0 -29184
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"permissions": {
|
|
3
3
|
"allow": [
|
|
4
|
-
"WebFetch(domain:github.com)",
|
|
5
|
-
"
|
|
4
|
+
"WebFetch(domain:api.github.com)",
|
|
5
|
+
"WebFetch(domain:raw.githubusercontent.com)",
|
|
6
|
+
"WebFetch(domain:ai.acsim.app)"
|
|
6
7
|
]
|
|
7
8
|
},
|
|
8
9
|
"enableAllProjectMcpServers": true,
|
|
9
10
|
"enabledMcpjsonServers": [
|
|
10
|
-
"
|
|
11
|
+
"memory"
|
|
11
12
|
]
|
|
12
13
|
}
|
package/dist/index.js
CHANGED
|
@@ -20429,7 +20429,7 @@ async function getLocalEmail() {
|
|
|
20429
20429
|
return execGit(["config", "user.email"]);
|
|
20430
20430
|
});
|
|
20431
20431
|
}
|
|
20432
|
-
async function getDiffFiles(remote = "origin") {
|
|
20432
|
+
async function getDiffFiles(remote = "origin", authorEmail) {
|
|
20433
20433
|
return withSpan("safe-push.git.getDiffFiles", async () => {
|
|
20434
20434
|
const branch = await getCurrentBranch();
|
|
20435
20435
|
const isNew = await isNewBranch(remote);
|
|
@@ -20449,12 +20449,27 @@ async function getDiffFiles(remote = "origin") {
|
|
|
20449
20449
|
} else {
|
|
20450
20450
|
baseBranch = `${remote}/${branch}`;
|
|
20451
20451
|
}
|
|
20452
|
-
|
|
20452
|
+
let output;
|
|
20453
|
+
if (authorEmail) {
|
|
20454
|
+
output = await execGit([
|
|
20455
|
+
"log",
|
|
20456
|
+
`--author=${authorEmail}`,
|
|
20457
|
+
"--name-only",
|
|
20458
|
+
"--format=",
|
|
20459
|
+
`${baseBranch}..HEAD`
|
|
20460
|
+
]);
|
|
20461
|
+
} else {
|
|
20462
|
+
output = await execGit([
|
|
20463
|
+
"diff",
|
|
20464
|
+
"--name-only",
|
|
20465
|
+
`${baseBranch}...HEAD`
|
|
20466
|
+
]);
|
|
20467
|
+
}
|
|
20453
20468
|
if (!output) {
|
|
20454
20469
|
return [];
|
|
20455
20470
|
}
|
|
20456
|
-
return output.split(`
|
|
20457
|
-
`).filter(Boolean);
|
|
20471
|
+
return [...new Set(output.split(`
|
|
20472
|
+
`).filter(Boolean))];
|
|
20458
20473
|
});
|
|
20459
20474
|
}
|
|
20460
20475
|
async function execPush(args = [], remote = "origin") {
|
|
@@ -20586,7 +20601,7 @@ async function checkPush(config) {
|
|
|
20586
20601
|
const newBranch = await isNewBranch();
|
|
20587
20602
|
const authorEmail = await getLastCommitAuthorEmail();
|
|
20588
20603
|
const localEmail = await getLocalEmail();
|
|
20589
|
-
const diffFiles = await getDiffFiles();
|
|
20604
|
+
const diffFiles = await getDiffFiles("origin", localEmail);
|
|
20590
20605
|
const forbiddenFiles = findForbiddenFiles(diffFiles, config.forbiddenPaths);
|
|
20591
20606
|
const hasForbiddenChanges = forbiddenFiles.length > 0;
|
|
20592
20607
|
const isOwnLastCommit = authorEmail.toLowerCase() === localEmail.toLowerCase();
|
|
@@ -31292,7 +31307,7 @@ function createMcpCommand() {
|
|
|
31292
31307
|
// package.json
|
|
31293
31308
|
var package_default = {
|
|
31294
31309
|
name: "safe-push",
|
|
31295
|
-
version: "0.
|
|
31310
|
+
version: "0.7.0",
|
|
31296
31311
|
description: "Git push safety checker - blocks pushes to forbidden areas",
|
|
31297
31312
|
type: "module",
|
|
31298
31313
|
bin: {
|
package/package.json
CHANGED
package/src/checker.ts
CHANGED
|
@@ -101,7 +101,7 @@ export async function checkPush(config: Config): Promise<CheckResult> {
|
|
|
101
101
|
const newBranch = await isNewBranch();
|
|
102
102
|
const authorEmail = await getLastCommitAuthorEmail();
|
|
103
103
|
const localEmail = await getLocalEmail();
|
|
104
|
-
const diffFiles = await getDiffFiles();
|
|
104
|
+
const diffFiles = await getDiffFiles("origin", localEmail);
|
|
105
105
|
|
|
106
106
|
const forbiddenFiles = findForbiddenFiles(diffFiles, config.forbiddenPaths);
|
|
107
107
|
const hasForbiddenChanges = forbiddenFiles.length > 0;
|
package/src/git.ts
CHANGED
|
@@ -77,7 +77,10 @@ export async function getLocalEmail(): Promise<string> {
|
|
|
77
77
|
* リモートとの差分ファイル一覧を取得
|
|
78
78
|
* 新規ブランチの場合はmainまたはmasterとの差分を取得
|
|
79
79
|
*/
|
|
80
|
-
export async function getDiffFiles(
|
|
80
|
+
export async function getDiffFiles(
|
|
81
|
+
remote = "origin",
|
|
82
|
+
authorEmail?: string
|
|
83
|
+
): Promise<string[]> {
|
|
81
84
|
return withSpan("safe-push.git.getDiffFiles", async () => {
|
|
82
85
|
const branch = await getCurrentBranch();
|
|
83
86
|
const isNew = await isNewBranch(remote);
|
|
@@ -101,12 +104,29 @@ export async function getDiffFiles(remote = "origin"): Promise<string[]> {
|
|
|
101
104
|
baseBranch = `${remote}/${branch}`;
|
|
102
105
|
}
|
|
103
106
|
|
|
104
|
-
|
|
107
|
+
let output: string;
|
|
108
|
+
if (authorEmail) {
|
|
109
|
+
// 自分のコミットで変更されたファイルのみ取得
|
|
110
|
+
output = await execGit([
|
|
111
|
+
"log",
|
|
112
|
+
`--author=${authorEmail}`,
|
|
113
|
+
"--name-only",
|
|
114
|
+
"--format=",
|
|
115
|
+
`${baseBranch}..HEAD`,
|
|
116
|
+
]);
|
|
117
|
+
} else {
|
|
118
|
+
output = await execGit([
|
|
119
|
+
"diff",
|
|
120
|
+
"--name-only",
|
|
121
|
+
`${baseBranch}...HEAD`,
|
|
122
|
+
]);
|
|
123
|
+
}
|
|
105
124
|
if (!output) {
|
|
106
125
|
return [];
|
|
107
126
|
}
|
|
108
127
|
|
|
109
|
-
|
|
128
|
+
// 重複を除去して返す
|
|
129
|
+
return [...new Set(output.split("\n").filter(Boolean))];
|
|
110
130
|
});
|
|
111
131
|
}
|
|
112
132
|
|