diff options
| author | mo8it <mo8it@proton.me> | 2024-04-18 12:41:17 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-04-18 12:41:17 +0200 |
| commit | 01e6732e4d920d9a1859e05fa28382e4307571af (patch) | |
| tree | 122060cdc0ef3f81d367e0afc7b0e3e9d29d33ee /src/exercise.rs | |
| parent | f04089b8bc724d41dcd26117c85f32328b5eb597 (diff) | |
Improve resetting
Diffstat (limited to 'src/exercise.rs')
| -rw-r--r-- | src/exercise.rs | 38 |
1 files changed, 3 insertions, 35 deletions
diff --git a/src/exercise.rs b/src/exercise.rs index 7f924f9..eb7b725 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -1,17 +1,13 @@ -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result}; use crossterm::style::{style, StyledContent, Stylize}; use std::{ fmt::{self, Display, Formatter}, fs, path::Path, - process::{Command, Output, Stdio}, + process::{Command, Output}, }; -use crate::{ - embedded::{WriteStrategy, EMBEDDED_FILES}, - info_file::Mode, - DEVELOPING_OFFICIAL_RUSTLINGS, -}; +use crate::{info_file::Mode, DEVELOPING_OFFICIAL_RUSTLINGS}; pub struct TerminalFileLink<'a> { path: &'a str, @@ -87,34 +83,6 @@ impl Exercise { } } - pub fn reset(&self) -> Result<()> { - if Path::new("info.toml").exists() { - let output = Command::new("git") - .arg("stash") - .arg("push") - .arg("--") - .arg(self.path) - .stdin(Stdio::null()) - .stdout(Stdio::null()) - .output() - .with_context(|| format!("Failed to run `git stash push -- {}`", self.path))?; - - if !output.status.success() { - bail!( - "`git stash push -- {}` didn't run successfully: {}", - self.path, - String::from_utf8_lossy(&output.stderr), - ); - } - } else { - EMBEDDED_FILES - .write_exercise_to_disk(self.path, WriteStrategy::Overwrite) - .with_context(|| format!("Failed to reset the exercise {self}"))?; - } - - Ok(()) - } - pub fn terminal_link(&self) -> StyledContent<TerminalFileLink<'_>> { style(TerminalFileLink { path: self.path }) .underlined() |
