Feature/command restore#28
Merged
Merged
Conversation
adamgracikowski
approved these changes
Oct 29, 2025
Contributor
adamgracikowski
left a comment
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implementacja komendy
restoredo przywracania zmian.Przeniosłem także logikę przechodzenia po drzewie obiektów z handlera
ls-treedo oddzielnego serwisu i lekko ją ulepszyłem.Zachęcam do testowania (oczywiście w kontrolowanych warunkach 😄)