Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenvukhang committed Jun 30, 2023
2 parents b40730b + ae021f6 commit 253eb09
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gitnu"
version = "0.6.7"
version = "0.6.8-alpha1"
authors = ["Nguyen Vu Khang <[email protected]>"]
description = """
gitnu indexes your git status so you can use numbers instead of filenames.
Expand Down
38 changes: 30 additions & 8 deletions core/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::ffi::OsStr;
use std::io::{BufRead, BufReader, Read};
use std::path::{Path, PathBuf};
use std::process::Command;
Expand Down Expand Up @@ -87,7 +88,7 @@ impl App {
pub fn run(&mut self) -> Result<(), GitnuError> {
// print command preview if GITNU_DEBUG environment variable is set
if std::env::var("GITNU_DEBUG").is_ok() {
eprintln!("\x1b[0;30m{}\x1b[0m", self.preview());
eprintln!("\x1b[0;30m{}\x1b[0m", self.preview_args().join(" "));
}
use GitCommand as G;
match self.git_command {
Expand All @@ -101,13 +102,34 @@ impl App {
}
}

pub fn preview(&self) -> String {
let mut preview = String::from("git");
self.cmd.get_args().filter_map(|v| v.to_str()).for_each(|arg| {
preview.push(' ');
preview.push_str(arg)
});
preview.replace(" -c color.ui=always", "")
/// Returns a complete list of arguments
pub fn preview_args(&self) -> Vec<&str> {
let args: Vec<_> =
self.cmd.get_args().filter_map(|v| v.to_str()).collect();

let mut ignore = vec![];

// remove `-c color.ui=always` flag
let flag_rm = args.iter().position(|&v| v == "color.ui=always");
if let Some(v) = flag_rm {
ignore.extend_from_slice(&[v - 1, v]);
}

ignore.sort();
ignore.reverse();

let mut preview = Vec::with_capacity(args.len() + 1);
preview.push("git");

for i in 0..args.len() {
if ignore.last() == Some(&i) {
ignore.pop();
continue;
}
preview.push(args[i])
}

preview
}
}

Expand Down
3 changes: 1 addition & 2 deletions scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ def next_minor(self):
return clone

def next_patch(self):
clone = self.clone()
clone.patch += 1
clone = self.next_prerelease()
clone.prerelease = None
return clone

Expand Down

0 comments on commit 253eb09

Please sign in to comment.