fix(restore): fixed restore command

This commit is contained in:
darwincereska
2025-11-10 16:52:12 -05:00
parent eb8fa26c18
commit c38a8bb95c
4 changed files with 33 additions and 6 deletions

View File

@@ -4,6 +4,7 @@
- [x] Configure `build.gradle.kts` with dependencies
- [x] Set up testing framework
# Core
- [x] Create `Repository.kt` class
@@ -14,6 +15,7 @@
- [x] Implement `Timeline.kt` for version tracking
- [x] Add `RepoMetadata` and configuration
# File Operations
- [x] Implement markdown file scanning
@@ -23,8 +25,10 @@
- [x] Add file timestamp tracking
- [ ] Create backup and restore mechanisms
# Core Commands
## Init Command
- [x] `notevc init` - Initialize repository
@@ -32,6 +36,7 @@
- [x] Generate initial metadata file
- [x] Handle existing repository detection
## Status Command
- [x] `notevc status` - Show file changes
@@ -39,6 +44,7 @@
- [x] Display added/modified/deleted files
- [x] Show clean working directory message
## Commit command
- [x] `notevc commit "message"` - Create snapshot
@@ -47,6 +53,7 @@
- [x] Create snapshot with metadata
- [x] Update repository head pointer
## Log Command
- [ ] `notevc log` - Show commit history
@@ -54,8 +61,10 @@
- [ ] Show commit hashes, messages, and timestamps
- [ ] add `--since` time filtering option
# Advanced Commands
## Diff Command
- [ ] `notevc diff` - Show current changes
@@ -63,6 +72,7 @@
- [ ] `notevc diff <commit>` - Compare with specific commit
- [ ] Implement basic text diffing algorithm
## Restore Command
- [ ] `notevc restore <commit>` - Restore entire state
@@ -70,12 +80,14 @@
- [ ] Add conformation prompts for destructive operations
- [ ] Handle file conflicts gracefully
## Show Command
- [ ] `notevc show <commit>` - Display commit changes
- [ ] Show commit metadata and file changes
- [ ] Display file contents at specific commit
# Utilities and Polish
- [ ] Add colored output for better UX
@@ -85,6 +97,7 @@
- [ ] Add version information (`notevc --version`)
- [ ] Implement configuration file support
# Testing
- [ ] Write unit tests for `ObjectStore`
@@ -94,6 +107,7 @@
- [ ] Add edge case testing (empty repos, corrupted data)
- [ ] Performance testing with large note collections
# Build and Distribution
- [ ] Create fat JAR for distribution
@@ -102,6 +116,7 @@
- [ ] Create installation scripts
- [ ] Add build automation (GitHub Actions)
# Future Features
- [ ] Compression for stored content
@@ -112,3 +127,4 @@
- [ ] Export/import functionality
- [ ] NeoVim Plugin

View File

@@ -1,6 +1,8 @@
# ![logo.png](./images/png/Color40X50.png) NoteVC: Version Control for Markdown
# Repository management
Initialize notevc repo:
@@ -23,6 +25,7 @@ Show commit history:
notevc log [--since=time]
```
# Viewing changes
Show changes since last commit:
@@ -40,6 +43,8 @@ Show specific commit:
notevc show <commit-hash>
```
# Restoration
Restore to specific version:
@@ -57,6 +62,8 @@ Restore entire repo state:
notevc checkout <commit-hash>
```
# Utilities
Remove old snapshots:
@@ -73,3 +80,5 @@ Show/set configuration:
```bash
notevc config
```

View File

@@ -113,10 +113,12 @@ class BlockParser {
}
// Add blocks in order
parsedFile.blocks.sortedBy { it.order }.forEach { block ->
result.appendLine(block.content)
if (block != parsedFile.blocks.last()) {
result.appendLine()
val sortedBlocks = parsedFile.blocks.sortedBy { it.order }
sortedBlocks.forEachIndexed { index, block ->
result.append(block.content)
// Add separator between blocks (not after last block)
if (index < sortedBlocks.size - 1) {
result.append("\n")
}
}

View File

@@ -169,8 +169,8 @@ class BlockStore(
val snapshot = json.decodeFromString<BlockSnapshot>(content)
val snapshotTime = Instant.parse(snapshot.timestamp)
// Only include snapshots before the given timestamp
if (snapshotTime.isBefore(timestamp)) {
// Only include snapshots before or at the given timestamp
if (!snapshotTime.isAfter(timestamp)) {
snapshots.add(snapshot to snapshotTime)
}
} catch (e: Exception) {