Skip to content

Commit 52b4de2

Browse files
committed
refactor: update patch application instructions to use standard patch format and tweak env rule
1 parent af60792 commit 52b4de2

File tree

4 files changed

+20
-50
lines changed

4 files changed

+20
-50
lines changed

app/actions/rules.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ env-secrets:
8484
## Environment Variables
8585
- Store secrets in a .env file (never commit it)
8686
- A .env.example file should be provided for reference and any new secrets should be added to it
87+
- Any secret that is no longer needed should be removed from the .env.example file
8788
- The implementation should use the dotenv (or similar) library to load environment variables from .env files
8889
- Variables should also be loaded from the environment
8990

app/routes/generate.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,31 +122,20 @@ def generate_patch(files: Dict[str, str], source: str = "scratch", repo_url: str
122122
# Add a comment header explaining the patch
123123
if source == "repo" and repo_url:
124124
patch_lines.append(f"# Gitrules configuration patch generated from repository: {repo_url}")
125-
patch_lines.append("# Apply with: git apply <this-patch>")
126-
use_git_format = True
125+
patch_lines.append("# Apply with: patch -p0 < <this-patch>")
127126
elif source == "template":
128127
patch_lines.append("# Gitrules configuration patch generated from template")
129128
patch_lines.append("# Apply with: patch -p0 < <this-patch>")
130-
use_git_format = False
131129
else:
132130
patch_lines.append("# Gitrules configuration patch generated from scratch")
133131
patch_lines.append("# Apply with: patch -p0 < <this-patch>")
134-
use_git_format = False
135132

136133
patch_lines.append("")
137134

138135
for filepath, content in files.items():
139-
if use_git_format:
140-
# Git format
141-
patch_lines.append(f"diff --git a/{filepath} b/{filepath}")
142-
patch_lines.append("new file mode 100644")
143-
patch_lines.append("index 0000000..1234567")
144-
patch_lines.append("--- /dev/null")
145-
patch_lines.append(f"+++ b/{filepath}")
146-
else:
147-
# Standard patch format
148-
patch_lines.append(f"--- /dev/null")
149-
patch_lines.append(f"+++ {filepath}")
136+
# Standard patch format
137+
patch_lines.append(f"--- /dev/null")
138+
patch_lines.append(f"+++ {filepath}")
150139

151140
lines = content.split('\n')
152141
if lines and lines[-1] == '':

app/templates/components/final_step_modal.html

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ <h3 class="text-lg font-black mb-3">👁️ File Preview</h3>
5656
<h3 class="text-lg font-black mb-3">🔧 Patch Preview</h3>
5757
<div class="bg-yellow-50 border-2 border-black p-3 text-sm">
5858
<p class="mb-2">The following patch file will be generated for easy application to your repository:</p>
59-
<code class="block bg-white border border-black p-2 font-mono text-xs">git apply gitrules-config.patch</code>
59+
<code class="block bg-white border border-black p-2 font-mono text-xs">patch -p0 &lt; gitrules-config.patch</code>
6060
</div>
6161
<div id="patch-preview" class="bg-gray-50 border-2 border-black p-4 font-mono text-xs overflow-x-auto max-h-64 overflow-y-auto mt-2">
6262
<!-- Patch content will be shown here -->
@@ -248,12 +248,9 @@ <h4 class="font-bold mb-2">🤖 Agents (${selectedAgents.length})</h4>
248248

249249
// Generate patch for each file
250250
Object.entries(state.files).forEach(([path, content]) => {
251-
// Create a proper git diff format
252-
patchContent += `diff --git a/${path} b/${path}\n`;
253-
patchContent += `new file mode 100644\n`;
254-
patchContent += `index 0000000..0000000\n`;
251+
// Create a proper patch format
255252
patchContent += `--- /dev/null\n`;
256-
patchContent += `+++ b/${path}\n`;
253+
patchContent += `+++ ${path}\n`;
257254

258255
// Add file content with + prefix for each line
259256
const lines = content.split('\n');
@@ -323,11 +320,8 @@ <h4 class="font-bold mb-2">🤖 Agents (${selectedAgents.length})</h4>
323320

324321
// Generate patch for each file
325322
Object.entries(state.files).forEach(([path, content]) => {
326-
patchContent += `diff --git a/${path} b/${path}\n`;
327-
patchContent += `new file mode 100644\n`;
328-
patchContent += `index 0000000..0000000\n`;
329323
patchContent += `--- /dev/null\n`;
330-
patchContent += `+++ b/${path}\n`;
324+
patchContent += `+++ ${path}\n`;
331325

332326
const lines = content.split('\n');
333327
patchContent += `@@ -0,0 +1,${lines.length} @@\n`;
@@ -350,7 +344,7 @@ <h4 class="font-bold mb-2">🤖 Agents (${selectedAgents.length})</h4>
350344

351345
// Copy patch to clipboard
352346
navigator.clipboard.writeText(patchContent).then(() => {
353-
alert('Patch copied to clipboard! You can now paste and apply it using: git apply');
347+
alert('Patch copied to clipboard! You can now paste and apply it using: patch -p0');
354348
}).catch(err => {
355349
console.error('Failed to copy patch:', err);
356350
alert('Failed to copy patch to clipboard. Please download the files instead.');

app/templates/generate.html

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
}
5959
</style>
6060

61-
<div class="min-h-screen bg-cyan-50 -mt-20 pt-20 page-content">
61+
<div class="bg-cyan-50 -mt-20 pt-20 flex flex-col min-h-screen page-content">
6262
<!-- Header -->
6363
<div class="bg-cyan-50 border-b-2 border-black shadow-[0_4px_0px_0px_rgba(0,0,0,1)] sticky top-0 z-10">
6464
<div class="container mx-auto px-4 py-4">
@@ -74,11 +74,11 @@ <h1 class="text-2xl font-black text-black">Generate Your Configuration</h1>
7474
</div>
7575
</div>
7676

77-
<div class="container mx-auto px-4 py-6">
77+
<div class="container mx-auto px-4 py-6 flex-1 overflow-auto">
7878
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
7979
<!-- Left Column: Summary -->
8080
<div class="lg:col-span-1">
81-
<div class="bg-white border-2 border-black shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] p-4 sticky top-24">
81+
<div class="bg-white border-2 border-black shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] p-4">
8282
<h3 class="text-xl font-black text-black mb-4">📋 Selected Tools</h3>
8383
<div id="selectedSummary" class="space-y-3">
8484
<!-- Will be populated dynamically -->
@@ -415,11 +415,7 @@ <h4 class="font-bold mb-2">🔌 MCPs (${grouped.mcps.length})</h4>
415415
const commandElement = document.getElementById('patchCommand');
416416

417417
// Update command based on source
418-
if (sourceInfo.source === 'repo') {
419-
commandElement.innerHTML = 'git apply &lt;&lt; \'EOF\'<br/>[patch content]<br/>EOF';
420-
} else {
421-
commandElement.innerHTML = 'patch -p0 &lt;&lt; \'EOF\'<br/>[patch content]<br/>EOF';
422-
}
418+
commandElement.innerHTML = 'patch -p0 &lt;&lt; \'EOF\'<br/>[patch content]<br/>EOF';
423419

424420
if (!patchContent) {
425421
container.innerHTML = '<div class="text-gray-500">No patch generated</div>';
@@ -545,19 +541,11 @@ <h4 class="font-bold mb-2">🔌 MCPs (${grouped.mcps.length})</h4>
545541
let contentToCopy;
546542
let message;
547543

548-
if (isFromRepo) {
549-
// For repo source: git apply with inline patch
550-
contentToCopy = `git apply << 'EOF'
544+
// Use patch for all sources
545+
contentToCopy = `patch -p0 << 'EOF'
551546
${patchContent}
552547
EOF`;
553-
message = 'Git patch command copied to clipboard! Paste and run directly in your terminal';
554-
} else {
555-
// For template/scratch: patch with inline content
556-
contentToCopy = `patch -p0 << 'EOF'
557-
${patchContent}
558-
EOF`;
559-
message = 'Patch command copied to clipboard! Paste and run directly in your terminal';
560-
}
548+
message = 'Patch command copied to clipboard! Paste and run directly in your terminal';
561549

562550
navigator.clipboard.writeText(contentToCopy).then(() => {
563551
showNotification(message);
@@ -589,17 +577,15 @@ <h4 class="font-bold mb-2">🔌 MCPs (${grouped.mcps.length})</h4>
589577

590578
function applyConfiguration() {
591579
// Show instructions for applying
592-
const isFromRepo = sourceInfo.source === 'repo';
593-
const command = isFromRepo ? 'git apply gitrules-config.patch' : 'patch -p0 < gitrules-config.patch';
594-
const reviewStep = isFromRepo ? 'git status' : 'ls -la';
595-
const commitStep = isFromRepo ? 'git commit -am "Add Gitrules configuration"' : '';
580+
const command = 'patch -p0 < gitrules-config.patch';
581+
const reviewStep = 'ls -la';
596582

597583
const instructions = `
598584
To apply this configuration to your repository:
599585
600586
1. Save the patch file as 'gitrules-config.patch'
601587
2. Run: ${command}
602-
3. Review the changes with: ${reviewStep}${commitStep ? '\n4. Commit when ready: ' + commitStep : ''}
588+
3. Review the changes with: ${reviewStep}
603589
`;
604590

605591
alert(instructions);

0 commit comments

Comments
 (0)