diff --git a/src/commands/commit.rs b/src/commands/commit.rs index 8c02e38..95e2dc4 100644 --- a/src/commands/commit.rs +++ b/src/commands/commit.rs @@ -350,8 +350,23 @@ impl CommitCommand { .output()?; if !output.status.success() { + let stdout = String::from_utf8_lossy(&output.stdout); let stderr = String::from_utf8_lossy(&output.stderr); - bail!("Failed to amend commit: {}", stderr); + + let error_msg = if stderr.is_empty() { + if stdout.is_empty() { + "GPG signing failed. Please check:\n\ + 1. GPG signing key is configured (git config --get user.signingkey)\n\ + 2. GPG agent is running\n\ + 3. You can sign commits manually (try: git commit --amend -S)".to_string() + } else { + stdout.to_string() + } + } else { + stderr.to_string() + }; + + bail!("Failed to amend commit: {}", error_msg); } Ok(()) diff --git a/src/git/commit.rs b/src/git/commit.rs index 53da566..1807025 100644 --- a/src/git/commit.rs +++ b/src/git/commit.rs @@ -174,8 +174,23 @@ impl CommitBuilder { .output()?; if !output.status.success() { + let stdout = String::from_utf8_lossy(&output.stdout); let stderr = String::from_utf8_lossy(&output.stderr); - bail!("Failed to amend commit: {}", stderr); + + let error_msg = if stderr.is_empty() { + if stdout.is_empty() { + "GPG signing failed. Please check:\n\ + 1. GPG signing key is configured (git config --get user.signingkey)\n\ + 2. GPG agent is running\n\ + 3. You can sign commits manually (try: git commit --amend -S)".to_string() + } else { + stdout.to_string() + } + } else { + stderr.to_string() + }; + + bail!("Failed to amend commit: {}", error_msg); } Ok(()) diff --git a/src/git/mod.rs b/src/git/mod.rs index 3442b58..de4882e 100644 --- a/src/git/mod.rs +++ b/src/git/mod.rs @@ -374,8 +374,23 @@ impl GitRepo { .output()?; if !output.status.success() { + let stdout = String::from_utf8_lossy(&output.stdout); let stderr = String::from_utf8_lossy(&output.stderr); - bail!("Failed to create signed commit: {}", stderr); + + let error_msg = if stderr.is_empty() { + if stdout.is_empty() { + "GPG signing failed. Please check:\n\ + 1. GPG signing key is configured (git config --get user.signingkey)\n\ + 2. GPG agent is running\n\ + 3. You can sign commits manually (try: git commit -S -m 'test')".to_string() + } else { + stdout.to_string() + } + } else { + stderr.to_string() + }; + + bail!("Failed to create signed commit: {}", error_msg); } let head = self.repo.head()?;