channel switch as an alias to reset
[?]
Nov 21, 2020, 7:03 PM
VQPAUKBQ2POZKL7CZFAZK5ZQKEBYL27XZYZWYUSH5AH25KK6DWKACDependencies
- [2]
SXEYMYF7Fixing the bad changes in history (unfortunately, by rebooting). - [3]
L4JXJHWXpijul/*: reorganize imports and remove extern crate - [4]
NLGQAH4HCredit and reset relative to current directory instead of the root - [5]
M3VTIZCPValidate change before reset
Change contents
- edit in pijul/src/main.rs at line 150
#[error("Cannot delete the current channel")]CannotDeleteCurrentChannel, - edit in pijul/src/config.rs at line 62
}}pub fn current_channel<'a>(&'a self) -> Option<&'a str> {if let Some(ref channel) = self.current_channel {Some(channel.as_str())} else {None - replacement in pijul/src/commands/reset.rs at line 13
repo_path: Option<PathBuf>,pub repo_path: Option<PathBuf>, - replacement in pijul/src/commands/reset.rs at line 15
channel: Option<String>,pub channel: Option<String>, - replacement in pijul/src/commands/reset.rs at line 17
dry_run: bool,pub dry_run: bool, - replacement in pijul/src/commands/reset.rs at line 19
change: Option<String>,files: Vec<PathBuf>,pub change: Option<String>,pub files: Vec<PathBuf>, - edit in pijul/src/commands/reset.rs at line 25
self.reset(true)}pub fn switch(self) -> Result<(), anyhow::Error> {self.reset(false)}fn reset(self, overwrite_changes: bool) -> Result<(), anyhow::Error> { - replacement in pijul/src/commands/reset.rs at line 72
if self.channel.is_some()&& self.channel.as_ref().map(|x| x.as_str()) != Some(current_channel){if self.channel.as_ref().map(|x| x.as_str()) == Some(current_channel) {if !overwrite_changes {// No need to change channel, no need to reset.return Ok(())}} else if self.channel.is_some() { - edit in pijul/src/commands/channel.rs at line 22
#[clap(name = "switch")]Switch { to: Option<String> }, - edit in pijul/src/commands/channel.rs at line 28
let repo = Repository::find_root(self.repo_path)?; - edit in pijul/src/commands/channel.rs at line 29
let current = if let Some(ref c) = repo.config.current_channel {Some(c.as_str())} else {None}; - edit in pijul/src/commands/channel.rs at line 31
let repo = Repository::find_root(self.repo_path)?;let current = repo.config.current_channel(); - edit in pijul/src/commands/channel.rs at line 45
let repo = Repository::find_root(self.repo_path)?;let current = repo.config.current_channel();if Some(delete.as_str()) == current {return Err(crate::Error::CannotDeleteCurrentChannel.into())} - edit in pijul/src/commands/channel.rs at line 54
Some(SubCommand::Switch { to }) => {(crate::commands::reset::Reset {repo_path: self.repo_path,channel: to,dry_run: false,change: None,files: Vec::new(),}).switch()?;} - edit in pijul/src/commands/channel.rs at line 64
let repo = Repository::find_root(self.repo_path)?;let current = repo.config.current_channel();