Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cee6c60b8 | ||
|
|
5bd35a33ad | ||
|
|
bae7930119 |
No files matched your search
@@ -22,7 +22,7 @@ To apply, you should have:
|
||||
|
||||
### ✍️ How to Apply
|
||||
|
||||
1. Open a discussion in [rtk-ai/rtk Maintainers Applications · Discussions · GitHub]() titled **Maintainer Application: [Your GitHub Handle]**
|
||||
1. Open a discussion in [rtk-ai/rtk Maintainers Applications · Discussions · GitHub](https://github.com/rtk-ai/rtk/discussions/categories/maintainers-applications) titled **Maintainer Application: [Your GitHub Handle]**
|
||||
2. In your application, include:
|
||||
- The ecosystem(s) you're interested in
|
||||
- Your experience with those ecosystems
|
||||
|
||||
+3
-1
@@ -3,6 +3,7 @@
|
||||
use crate::core::config;
|
||||
use crate::core::tracking;
|
||||
use crate::core::utils::{exit_code_from_output, exit_code_from_status, resolved_command};
|
||||
use std::process::Stdio;
|
||||
use anyhow::{Context, Result};
|
||||
use std::ffi::OsString;
|
||||
use std::process::Command;
|
||||
@@ -908,6 +909,7 @@ fn run_commit(args: &[String], verbose: u8, global_args: &[String]) -> Result<i3
|
||||
}
|
||||
|
||||
let output = build_commit_command(args, global_args)
|
||||
.stdin(Stdio::inherit())
|
||||
.output()
|
||||
.context("Failed to run git commit")?;
|
||||
|
||||
@@ -972,7 +974,7 @@ fn run_push(args: &[String], verbose: u8, global_args: &[String]) -> Result<i32>
|
||||
cmd.arg(arg);
|
||||
}
|
||||
|
||||
let output = cmd.output().context("Failed to run git push")?;
|
||||
let output = cmd.stdin(Stdio::inherit()).output().context("Failed to run git push")?;
|
||||
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
|
||||
+2
-2
@@ -77,8 +77,8 @@ where
|
||||
// On failure, skip filtering and return early (e.g. psql error messages
|
||||
// containing '|' would be misinterpreted by the table parser)
|
||||
if opts.skip_filter_on_failure && exit_code != 0 {
|
||||
if !stderr.is_empty() {
|
||||
eprint!("{}", stderr);
|
||||
if !stderr.trim().is_empty() {
|
||||
eprintln!("{}", stderr.trim());
|
||||
}
|
||||
timer.track(
|
||||
&format!("{} {}", tool_name, args_display),
|
||||
|
||||
+24
-49
@@ -70,11 +70,11 @@ pub fn tokenize(input: &str) -> Vec<ParsedToken> {
|
||||
.is_some_and(|&nc| nc.is_ascii_alphabetic() || nc == '_')
|
||||
{
|
||||
let mut name = String::from("$");
|
||||
while chars
|
||||
.peek()
|
||||
.is_some_and(|&nc| nc.is_ascii_alphanumeric() || nc == '_')
|
||||
{
|
||||
let nc = chars.next().unwrap();
|
||||
while let Some(&nc) = chars.peek() {
|
||||
if !nc.is_ascii_alphanumeric() && nc != '_' {
|
||||
break;
|
||||
}
|
||||
chars.next();
|
||||
byte_pos += nc.len_utf8();
|
||||
name.push(nc);
|
||||
}
|
||||
@@ -107,7 +107,8 @@ pub fn tokenize(input: &str) -> Vec<ParsedToken> {
|
||||
let start = byte_pos;
|
||||
byte_pos += char_len;
|
||||
if chars.peek() == Some(&'|') {
|
||||
byte_pos += chars.next().unwrap().len_utf8();
|
||||
chars.next();
|
||||
byte_pos += 1;
|
||||
tokens.push(ParsedToken {
|
||||
kind: TokenKind::Operator,
|
||||
value: "||".into(),
|
||||
@@ -137,18 +138,21 @@ pub fn tokenize(input: &str) -> Vec<ParsedToken> {
|
||||
let start = byte_pos;
|
||||
byte_pos += char_len;
|
||||
if chars.peek() == Some(&'&') {
|
||||
byte_pos += chars.next().unwrap().len_utf8();
|
||||
chars.next();
|
||||
byte_pos += 1;
|
||||
tokens.push(ParsedToken {
|
||||
kind: TokenKind::Operator,
|
||||
value: "&&".into(),
|
||||
offset: start,
|
||||
});
|
||||
} else if chars.peek() == Some(&'>') {
|
||||
byte_pos += chars.next().unwrap().len_utf8();
|
||||
chars.next();
|
||||
byte_pos += 1;
|
||||
let mut val = String::from("&>");
|
||||
if chars.peek() == Some(&'>') {
|
||||
chars.next();
|
||||
byte_pos += 1;
|
||||
val.push('>');
|
||||
byte_pos += chars.next().unwrap().len_utf8();
|
||||
}
|
||||
tokens.push(ParsedToken {
|
||||
kind: TokenKind::Redirect,
|
||||
@@ -181,17 +185,19 @@ pub fn tokenize(input: &str) -> Vec<ParsedToken> {
|
||||
val.push('>');
|
||||
byte_pos += char_len;
|
||||
if chars.peek() == Some(&'>') {
|
||||
chars.next();
|
||||
byte_pos += 1;
|
||||
val.push('>');
|
||||
byte_pos += chars.next().unwrap().len_utf8();
|
||||
}
|
||||
if chars.peek() == Some(&'&') {
|
||||
chars.next();
|
||||
byte_pos += 1;
|
||||
val.push('&');
|
||||
byte_pos += chars.next().unwrap().len_utf8();
|
||||
while chars
|
||||
.peek()
|
||||
.is_some_and(|&c| c.is_ascii_digit() || c == '-')
|
||||
{
|
||||
let nc = chars.next().unwrap();
|
||||
while let Some(&nc) = chars.peek() {
|
||||
if !nc.is_ascii_digit() && nc != '-' {
|
||||
break;
|
||||
}
|
||||
chars.next();
|
||||
val.push(nc);
|
||||
byte_pos += nc.len_utf8();
|
||||
}
|
||||
@@ -209,8 +215,9 @@ pub fn tokenize(input: &str) -> Vec<ParsedToken> {
|
||||
let mut val = String::from("<");
|
||||
byte_pos += char_len;
|
||||
if chars.peek() == Some(&'<') {
|
||||
chars.next();
|
||||
byte_pos += 1;
|
||||
val.push('<');
|
||||
byte_pos += chars.next().unwrap().len_utf8();
|
||||
}
|
||||
tokens.push(ParsedToken {
|
||||
kind: TokenKind::Redirect,
|
||||
@@ -251,18 +258,6 @@ fn flush_arg(tokens: &mut Vec<ParsedToken>, current: &mut String, offset: usize)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn strip_quotes(s: &str) -> String {
|
||||
let chars: Vec<char> = s.chars().collect();
|
||||
if chars.len() >= 2
|
||||
&& ((chars[0] == '"' && chars[chars.len() - 1] == '"')
|
||||
|| (chars[0] == '\'' && chars[chars.len() - 1] == '\''))
|
||||
{
|
||||
return chars[1..chars.len() - 1].iter().collect();
|
||||
}
|
||||
s.to_string()
|
||||
}
|
||||
|
||||
pub fn shell_split(input: &str) -> Vec<String> {
|
||||
let mut tokens = Vec::new();
|
||||
let mut current = String::new();
|
||||
@@ -860,26 +855,6 @@ mod tests {
|
||||
.any(|t| t.kind == TokenKind::Arg && t.value == "file"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_strip_quotes_double() {
|
||||
assert_eq!(strip_quotes("\"hello\""), "hello");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_strip_quotes_single() {
|
||||
assert_eq!(strip_quotes("'hello'"), "hello");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_strip_quotes_none() {
|
||||
assert_eq!(strip_quotes("hello"), "hello");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_strip_quotes_mismatched() {
|
||||
assert_eq!(strip_quotes("\"hello'"), "\"hello'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_shell_split_simple() {
|
||||
assert_eq!(
|
||||
|
||||
@@ -2370,4 +2370,33 @@ mod tests {
|
||||
Some("rtk wc src/*.rs".into())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_classify_command_substitution_passthrough() {
|
||||
assert_eq!(
|
||||
classify_command("git log $(git rev-parse HEAD~1)"),
|
||||
Classification::Supported {
|
||||
rtk_equivalent: "rtk git",
|
||||
category: "Git",
|
||||
estimated_savings_pct: 70.0,
|
||||
status: RtkStatus::Existing,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rewrite_command_substitution_passthrough() {
|
||||
assert_eq!(
|
||||
rewrite_command("git log $(git rev-parse HEAD~1)", &[]),
|
||||
Some("rtk git log $(git rev-parse HEAD~1)".into())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_split_command_substitution_no_split() {
|
||||
assert_eq!(
|
||||
split_command_chain("git log $(git rev-parse HEAD~1)"),
|
||||
vec!["git log $(git rev-parse HEAD~1)"]
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user