Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions crates/forge_services/src/tools/patch/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,9 @@ impl<T: Infrastructure> ExecutableTool for ApplyPatch<T> {
)
} else {
format!(
"<file_content\n path=\"{}\" status=\"patched_successfully\" />\n",
input.path
"<file_content path=\"{}\">\n{}\n</file_content>\n",
input.path,
modified.trim_end()
)
};
anyhow::Ok(output)
Expand Down
5 changes: 3 additions & 2 deletions crates/forge_services/src/tools/patch/apply_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,9 @@ fn format_output(path: &str, content: &str, warning: Option<&str>) -> String {
)
} else {
format!(
"<file_content\n path=\"{}\" status=\"patched_successfully\" />\n",
path
"<file_content path=\"{}\">\n{}\n</file_content>\n",
path,
content.trim_end()
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,22 @@
source: crates/forge_services/src/tools/patch/apply.rs
expression: "TempDir::normalize(&result)"
---
<file_content
path="[TEMP_DIR]/test.txt" status="patched_successfully" />
<file_content path="[TEMP_DIR]/test.txt">


// Header comment


function test() {
// Inside comment

let y = 2;


console.log(y);
}



// Updated footer
</file_content>
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,24 @@
source: crates/forge_services/src/tools/patch/apply.rs
expression: "TempDir::normalize(&result)"
---
<file_content
path="[TEMP_DIR]/test.txt" status="patched_successfully" />
<file_content path="[TEMP_DIR]/test.txt">



// New header



function test() {
// Inside comment

let y = 2;


console.log(y);
}



// Updated footer
</file_content>
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,20 @@
source: crates/forge_services/src/tools/patch/apply.rs
expression: "TempDir::normalize(&result)"
---
<file_content
path="[TEMP_DIR]/test.txt" status="patched_successfully" />
<file_content path="[TEMP_DIR]/test.txt">


// Header comment


function test() {
// Inside comment

let y = 2;


console.log(y);
}

// Footer comment
</file_content>
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
source: crates/forge_services/src/tools/patch/apply.rs
expression: "TempDir::normalize(&result)"
---
<file_content
path="[TEMP_DIR]/test.txt" status="patched_successfully" />
<file_content path="[TEMP_DIR]/test.txt">
First Line
Last Line
</file_content>
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
source: crates/forge_services/src/tools/patch/apply.rs
expression: "TempDir::normalize(&result)"
---
<file_content
path="[TEMP_DIR]/test.txt" status="patched_successfully" />
<file_content path="[TEMP_DIR]/test.txt">
New content
</file_content>
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,14 @@
source: crates/forge_services/src/tools/patch/apply.rs
expression: "TempDir::normalize(&result)"
---
<file_content
path="[TEMP_DIR]/test.txt" status="patched_successfully" />
<file_content path="[TEMP_DIR]/test.txt">
class UserManager {
async findUser(id, options = {}) {
const user = await this.db.findOne({ userId: id, ...options });
if (!user) {
throw new UserNotFoundError(id);
}
return this.sanitizeUser(user);
}
}
</file_content>
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@
source: crates/forge_services/src/tools/patch/apply.rs
expression: "TempDir::normalize(&result)"
---
<file_content
path="[TEMP_DIR]/test.txt" status="patched_successfully" />
<file_content path="[TEMP_DIR]/test.txt">
class UserManager {
async findUser(id, options = {}) {
const user = await this.db.findOne({ userId: id, ...options });
if (!user) throw new Error('User not found');
return user;
}
}
</file_content>
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@
source: crates/forge_services/src/tools/patch/apply.rs
expression: "TempDir::normalize(&result)"
---
<file_content
path="[TEMP_DIR]/test.txt" status="patched_successfully" />
<file_content path="[TEMP_DIR]/test.txt">
function computeTotal(items, tax = 0) {
let total = 0.0;
for (const item of items) {
total += item.price * item.quantity;
}
return total;
}
</file_content>
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@
source: crates/forge_services/src/tools/patch/apply.rs
expression: "TempDir::normalize(&result)"
---
<file_content
path="[TEMP_DIR]/test.txt" status="patched_successfully" />
<file_content path="[TEMP_DIR]/test.txt">
function calculateTotal(items) {
let total = 0;
for (const item of items) {
total += item.price * item.quantity;
}
return total;
}
</file_content>
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
source: crates/forge_services/src/tools/patch/apply.rs
expression: "TempDir::normalize(&result)"
---
<file_content
path="[TEMP_DIR]/test.txt" status="patched_successfully" />
<file_content path="[TEMP_DIR]/test.txt">
New First
Middle Line
New Last
</file_content>
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
source: crates/forge_services/src/tools/patch/apply.rs
expression: "TempDir::normalize(&result)"
---
<file_content
path="[TEMP_DIR]/test.rs" status="patched_successfully" />
<file_content path="[TEMP_DIR]/test.rs">
fn main() { let x = 42; let y = x * 2; }
</file_content>
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
source: crates/forge_services/src/tools/patch/apply.rs
expression: "TempDir::normalize(&result)"
---
<file_content
path="[TEMP_DIR]/test.txt" status="patched_successfully" />
<file_content path="[TEMP_DIR]/test.txt">
Hi World
Test Line
Goodbye World
</file_content>