fix: 增强 GPG 签名失败时的错误提示
This commit is contained in:
@@ -350,8 +350,23 @@ impl CommitCommand {
|
|||||||
.output()?;
|
.output()?;
|
||||||
|
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
|
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
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(())
|
Ok(())
|
||||||
|
|||||||
@@ -174,8 +174,23 @@ impl CommitBuilder {
|
|||||||
.output()?;
|
.output()?;
|
||||||
|
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
|
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
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(())
|
Ok(())
|
||||||
|
|||||||
@@ -374,8 +374,23 @@ impl GitRepo {
|
|||||||
.output()?;
|
.output()?;
|
||||||
|
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
|
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
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()?;
|
let head = self.repo.head()?;
|
||||||
|
|||||||
Reference in New Issue
Block a user