mirror of
https://github.com/Pagwin-Fedora/ppi.git
synced 2025-07-17 22:15:42 +00:00
Fixed bug with certain commit hashes and code improvements
The bug was that if a byte in a commit id was less than 16 then it would have a leading 0 which the format specifier that printed hex would ignore. The code improvements were removing instances or reading newlines from stdin because breakpoints are better and the print statements are sufficeient as points to break on, it may make sense to replace them with function calls to functions which noop in future but for now this is good enough. In addition ignored some warnings in enum definitions, having error info is useful in the debugger if nothing else so we're not just going to throw that away due to a warning.
This commit is contained in:
parent
1d20205fc9
commit
7d3e456a41
3 changed files with 9 additions and 8 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -290,7 +290,7 @@ checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ppi"
|
name = "ppi"
|
||||||
version = "1.1.2"
|
version = "1.1.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"dirs",
|
"dirs",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "ppi"
|
name = "ppi"
|
||||||
version = "1.1.3"
|
version = "1.1.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -21,7 +21,7 @@ struct Config{
|
||||||
subcommands: Subcommands
|
subcommands: Subcommands
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum Errors{IoErr(std::io::Error), GitErr(git2::Error), CliErr(CliError), Unknown}
|
enum Errors{IoErr(std::io::Error), GitErr(git2::Error), CliErr(CliError), Unknown}
|
||||||
impl From<std::io::Error> for Errors {
|
impl From<std::io::Error> for Errors {
|
||||||
|
@ -103,7 +103,6 @@ fn main() -> Result<(),Errors> {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
{
|
{
|
||||||
eprintln!("repo cloned");
|
eprintln!("repo cloned");
|
||||||
std::io::stdin().read_line(&mut String::new())?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
eprintln!("checking out appropriate branch");
|
eprintln!("checking out appropriate branch");
|
||||||
|
@ -116,7 +115,6 @@ fn main() -> Result<(),Errors> {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
{
|
{
|
||||||
eprintln!("origin deleted");
|
eprintln!("origin deleted");
|
||||||
std::io::stdin().read_line(&mut String::new())?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut walk = repo.revwalk()?;
|
let mut walk = repo.revwalk()?;
|
||||||
|
@ -128,16 +126,18 @@ fn main() -> Result<(),Errors> {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
{
|
{
|
||||||
eprintln!("oldest commit found");
|
eprintln!("oldest commit found");
|
||||||
std::io::stdin().read_line(&mut String::new())?;
|
|
||||||
}
|
}
|
||||||
let pwd = repo.path().parent().expect("very bad cloning into the root dir happening");
|
let pwd = repo.path().parent().expect("very bad cloning into the root dir happening");
|
||||||
eprintln!("rebasing skeleton's commits down into single commit {:?}", pwd);
|
eprintln!("rebasing skeleton's commits down into single commit {:?}", pwd);
|
||||||
// I give up git2 documentation/api is just too bad for me to do this with it
|
// I give up git2 documentation/api is just too bad for me to do this with it
|
||||||
|
|
||||||
|
let commit_arg:&str = &oldest_commit.id()
|
||||||
|
.as_bytes().iter()
|
||||||
|
.map(|byte|format!("{:02x}",byte))
|
||||||
|
.collect::<String>()[0..7];
|
||||||
handle_process(std::process::Command::new("git")
|
handle_process(std::process::Command::new("git")
|
||||||
.current_dir(pwd)
|
.current_dir(pwd)
|
||||||
.args(["reset", "--mixed" , oldest_commit.id().as_bytes().iter().map(|byte|format!("{:x}",byte)).collect::<String>().chars().take(7).collect::<String>().as_str()]))?;
|
.args(["reset", "--mixed" , commit_arg]))?;
|
||||||
|
|
||||||
handle_process(std::process::Command::new("git")
|
handle_process(std::process::Command::new("git")
|
||||||
.current_dir(pwd)
|
.current_dir(pwd)
|
||||||
|
@ -163,6 +163,7 @@ fn main() -> Result<(),Errors> {
|
||||||
prog_copy.print_help()?;
|
prog_copy.print_help()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum CliError{Io(std::io::Error), NonZero}
|
enum CliError{Io(std::io::Error), NonZero}
|
||||||
impl From<std::io::Error> for CliError {
|
impl From<std::io::Error> for CliError {
|
||||||
|
|
Loading…
Reference in a new issue