Skip to content

Feature/command restore#28

Merged
mikolajkarbowski merged 10 commits into
developfrom
feature/command-restore
Nov 15, 2025
Merged

Feature/command restore#28
mikolajkarbowski merged 10 commits into
developfrom
feature/command-restore

Conversation

@mikolajkarbowski
Copy link
Copy Markdown
Contributor

@mikolajkarbowski mikolajkarbowski commented Oct 29, 2025

Implementacja komendy restore do przywracania zmian.
Przeniosłem także logikę przechodzenia po drzewie obiektów z handlera ls-tree do oddzielnego serwisu i lekko ją ulepszyłem.

Zachęcam do testowania (oczywiście w kontrolowanych warunkach 😄)

Copy link
Copy Markdown
Contributor

@adamgracikowski adamgracikowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spoko, trochę potestowałem nawet. Przywracanie zmian zdaje się działać, usunięte pliki widzę, że też przywraca 🔥

Czy mógłbyś do handlers\status\operations.rs dodać metodę do Requesta:

    /// Returns `true` if the working tree is clean — i.e., no staged,
    /// unstaged, unmerged, untracked, or ignored entries are present.
    #[inline]
    fn is_clean(&self) -> bool {
        [
            &self.staged,
            &self.unstaged,
            &self.unmerged,
            &self.untracked,
            &self.ignored,
        ]
        .into_iter()
        .all(|opt| opt.as_ref().map(|v| v.is_empty()).unwrap_or(true))
    }

i zmodyfikować tą metodę:

    /// Renders the complete, human-readable status report from the data in this [Response].
    ///
    /// # Arguments
    ///
    /// * `short` - An `Option` to override the output format.
    ///   If `Some(true)`, forces short format.
    ///   If `Some(false)` or `None`, defaults to the long (standard) format.
    pub fn render_status(&self, short: Option<bool>, branch: Option<bool>) -> String {
        let short = short.unwrap_or(false);
        let branch = branch.unwrap_or(true);
        let mut out = String::new();

        if branch && let Some(branch) = &self.branch {
            out.push_str(&format!("{branch}"));
        }

        if self.is_clean() {
            out.push_str("Nothing to commit, working tree clean.\n");
            return out;
        }

        out.push_str(&self.render_section("Changes to be committed", &self.staged, short));
        out.push_str(&self.render_section("Changes not staged for commit", &self.unstaged, short));
        out.push_str(&self.render_section("Unmerged paths", &self.unmerged, short));
        out.push_str(&self.render_section("Untracked files", &self.untracked, short));
        out.push_str(&self.render_section("Ignored files", &self.ignored, short));
        out
    }

bo mi się obecnie Nothing to commit nie wyświetla xD

Comment thread cli/src/commands/restore.rs Outdated
Comment thread cli/src/commands/restore.rs Outdated
Comment thread cli/src/commands/restore.rs Outdated
Comment thread cli/src/commands/restore.rs Outdated
Comment thread cli/src/commands/restore.rs
Comment thread engine/src/handlers/restore/operations.rs Outdated
Comment thread engine/src/index/meva_index.rs
Comment thread engine/src/index/working_dir.rs
Comment thread engine/src/traversal.rs
Comment thread engine/src/traversal/meva_commit_tree_walker.rs
@mikolajkarbowski mikolajkarbowski merged commit 7aa9864 into develop Nov 15, 2025
1 check passed
@mikolajkarbowski mikolajkarbowski deleted the feature/command-restore branch November 17, 2025 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants