Skip to content

Commit a92c26f

Browse files
authored
Merge branch 'main' into fix/ssl-verification-508
2 parents 96ce880 + 37b2926 commit a92c26f

File tree

3 files changed

+118
-1
lines changed

3 files changed

+118
-1
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: README PR Check
2+
3+
on:
4+
pull_request:
5+
types: [opened]
6+
paths:
7+
- 'README.md'
8+
issue_comment:
9+
types: [created]
10+
11+
jobs:
12+
check-readme-only:
13+
if: github.event_name == 'pull_request'
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
pull-requests: write
18+
steps:
19+
- name: Check files and comment if README-only
20+
uses: actions/github-script@v7
21+
with:
22+
script: |
23+
const { owner, repo } = context.repo;
24+
const prNumber = context.payload.pull_request.number;
25+
26+
const { data: files } = await github.rest.pulls.listFiles({ owner, repo, pull_number: prNumber });
27+
28+
if (files.length !== 1 || files[0].filename !== 'README.md') {
29+
console.log('PR modifies files other than README, skipping');
30+
return;
31+
}
32+
33+
// Check if we've already commented
34+
const { data: comments } = await github.rest.issues.listComments({ owner, repo, issue_number: prNumber });
35+
if (comments.some(c => c.user.login === 'github-actions[bot]' && c.body.includes('no longer accepting PRs to add new servers'))) {
36+
console.log('Already commented on this PR, skipping');
37+
return;
38+
}
39+
40+
await github.rest.issues.addLabels({ owner, repo, issue_number: prNumber, labels: ['readme: pending'] });
41+
42+
await github.rest.issues.createComment({
43+
owner,
44+
repo,
45+
issue_number: prNumber,
46+
body: [
47+
'Thanks for your contribution!',
48+
'',
49+
'**We are no longer accepting PRs to add new servers to the README.** The server lists are deprecated and will eventually be removed entirely, replaced by the registry.',
50+
'',
51+
'👉 **To add a new MCP server:** Please publish it to the [MCP Server Registry](https://github.com/modelcontextprotocol/registry) instead. You can browse published servers at [registry.modelcontextprotocol.io](https://registry.modelcontextprotocol.io/).',
52+
'',
53+
'👉 **If this PR updates or removes an existing entry:** We do still accept these changes. Please reply with `/i-promise-this-is-not-a-new-server` to continue.',
54+
'',
55+
'If this PR is adding a new server, please close it and submit to the registry instead.',
56+
].join('\n'),
57+
});
58+
59+
handle-confirmation:
60+
if: github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '/i-promise-this-is-not-a-new-server')
61+
runs-on: ubuntu-latest
62+
permissions:
63+
pull-requests: write
64+
steps:
65+
- name: Swap labels and minimize comments
66+
uses: actions/github-script@v7
67+
with:
68+
script: |
69+
const { owner, repo } = context.repo;
70+
const prNumber = context.payload.issue.number;
71+
72+
// Check if pending label exists
73+
const { data: labels } = await github.rest.issues.listLabelsOnIssue({ owner, repo, issue_number: prNumber });
74+
if (!labels.some(l => l.name === 'readme: pending')) {
75+
console.log('No pending label found, skipping');
76+
return;
77+
}
78+
79+
// Swap labels
80+
try {
81+
await github.rest.issues.removeLabel({ owner, repo, issue_number: prNumber, name: 'readme: pending' });
82+
} catch (e) {}
83+
await github.rest.issues.addLabels({ owner, repo, issue_number: prNumber, labels: ['readme: ready for review'] });
84+
85+
// Find the bot's original comment
86+
const { data: comments } = await github.rest.issues.listComments({ owner, repo, issue_number: prNumber });
87+
const botComment = comments.find(c =>
88+
c.user.login === 'github-actions[bot]' &&
89+
c.body.includes('no longer accepting PRs to add new servers')
90+
);
91+
92+
// Minimize both comments via GraphQL
93+
const minimizeComment = async (nodeId) => {
94+
await github.graphql(`
95+
mutation($id: ID!) {
96+
minimizeComment(input: {subjectId: $id, classifier: RESOLVED}) {
97+
minimizedComment { isMinimized }
98+
}
99+
}
100+
`, { id: nodeId });
101+
};
102+
103+
if (botComment) {
104+
await minimizeComment(botComment.node_id);
105+
}
106+
107+
// Only minimize user's comment if it's just the command
108+
const userComment = context.payload.comment.body.trim();
109+
if (userComment === '/i-promise-this-is-not-a-new-server') {
110+
await minimizeComment(context.payload.comment.node_id);
111+
}

src/filesystem/__tests__/path-utils.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ describe('Path Utilities', () => {
7070
.toBe('/home/user/some path');
7171
expect(normalizePath('"/usr/local/some app/"'))
7272
.toBe('/usr/local/some app');
73+
expect(normalizePath('/usr/local//bin/app///'))
74+
.toBe('/usr/local/bin/app');
75+
expect(normalizePath('/'))
76+
.toBe('/');
77+
expect(normalizePath('///'))
78+
.toBe('/');
7379
});
7480

7581
it('removes surrounding quotes', () => {

src/filesystem/path-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function normalizePath(p: string): string {
5555
if (isUnixPath) {
5656
// For Unix paths, just normalize without converting to Windows format
5757
// Replace double slashes with single slashes and remove trailing slashes
58-
return p.replace(/\/+/g, '/').replace(/\/+$/, '');
58+
return p.replace(/\/+/g, '/').replace(/(?<!^)\/$/, '');
5959
}
6060

6161
// Convert Unix-style Windows paths (/c/, /d/) to Windows format if on Windows

0 commit comments

Comments
 (0)