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

View File

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

View File

@@ -113,10 +113,12 @@ class BlockParser {
} }
// Add blocks in order // Add blocks in order
parsedFile.blocks.sortedBy { it.order }.forEach { block -> val sortedBlocks = parsedFile.blocks.sortedBy { it.order }
result.appendLine(block.content) sortedBlocks.forEachIndexed { index, block ->
if (block != parsedFile.blocks.last()) { result.append(block.content)
result.appendLine() // 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 snapshot = json.decodeFromString<BlockSnapshot>(content)
val snapshotTime = Instant.parse(snapshot.timestamp) val snapshotTime = Instant.parse(snapshot.timestamp)
// Only include snapshots before the given timestamp // Only include snapshots before or at the given timestamp
if (snapshotTime.isBefore(timestamp)) { if (!snapshotTime.isAfter(timestamp)) {
snapshots.add(snapshot to snapshotTime) snapshots.add(snapshot to snapshotTime)
} }
} catch (e: Exception) { } catch (e: Exception) {