Ignore LFS files when creating checkpoints

This commit is contained in:
Saoud Rizwan 2025-01-06 22:26:13 -08:00
parent 5c0aeb9671
commit d542d751d7
3 changed files with 21 additions and 1 deletions

View file

@ -1,5 +1,9 @@
# Change Log
## [3.1.2]
- Fix issue where LFS files would be not be ignored when creating checkpoints
## [3.1.0]
- Added checkpoints: Snapshots of workspace are automatically created whenever Cline uses a tool

View file

@ -2,7 +2,7 @@
"name": "claude-dev",
"displayName": "Cline (prev. Claude Dev)",
"description": "Autonomous coding agent right in your IDE, capable of creating/editing files, running commands, using the browser, and more with your permission every step of the way.",
"version": "3.1.1",
"version": "3.1.2",
"icon": "assets/icons/icon.png",
"galleryBanner": {
"color": "#617A91",

View file

@ -105,6 +105,21 @@ class CheckpointTracker {
await git.addConfig("core.worktree", this.cwd) // sets the working tree to the current workspace
// Get LFS patterns from workspace if they exist
let lfsPatterns: string[] = []
try {
const attributesPath = path.join(this.cwd, ".gitattributes")
if (await fileExistsAtPath(attributesPath)) {
const attributesContent = await fs.readFile(attributesPath, "utf8")
lfsPatterns = attributesContent
.split("\n")
.filter((line) => line.includes("filter=lfs"))
.map((line) => line.split(" ")[0].trim())
}
} catch (error) {
console.warn("Failed to read .gitattributes:", error)
}
// Add basic excludes directly in git config, while respecting any .gitignore in the workspace
// .git/info/exclude is local to the shadow git repo, so it's not shared with the main repo - and won't conflict with user's .gitignore
// TODO: let user customize these
@ -198,6 +213,7 @@ class CheckpointTracker {
"npm-debug.log*",
"yarn-debug.log*",
"yarn-error.log*",
...lfsPatterns,
].join("\n"),
)