Compare commits

...
Author SHA1 Message Date
Patrick szymkowiak 6cee6c60b8 fix(git): inherit stdin for commit and push to preserve SSH signing (#733)
Command::output() sets stdin to Stdio::piped() by default, creating an
empty pipe instead of inheriting the terminal. SSH signing tools
(1Password, YubiKey, gpg-agent with pinentry) need TTY access on stdin
for passphrase prompts or agent communication. This caused signatures
to be silently dropped — commits succeeded but without gpgsig headers.

Fix: add .stdin(Stdio::inherit()) to git commit and git push commands
so they inherit the parent's stdin (terminal or hook pipe). Output
capture via stdout/stderr pipes is preserved.

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
2026-04-02 21:04:46 +02:00
aesoft 5bd35a33ad Merge pull request #952 from rtk-ai/fix/pr-934-review
fix(review): PR #934
2026-03-31 20:45:44 +02:00
aesoft bae7930119 fix(review): PR #934 2026-03-31 20:43:59 +02:00
5 changed files with 59 additions and 53 deletions

No files matched your search

+1 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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!(
+29
View File
@@ -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)"]
);
}
}