Skip to content

Commit 02284d3

Browse files
committed
Remove reliance from presence of config options
1 parent 8fa591a commit 02284d3

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

Diff for: .github/workflows/ci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ jobs:
3939
if: matrix.os == 'macos-latest'
4040
run: brew install gpgme
4141

42+
- name: Install GnuPG on Windows
43+
if: matrix.os == 'windows-latest'
44+
run: choco install gnupg
45+
4246
- name: Build Debug
4347
run: |
4448
rustc --version

Diff for: asyncgit/src/sync/commit.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ pub fn commit(repo_path: &str, msg: &str) -> Result<CommitId> {
7070

7171
let parents = parents.iter().collect::<Vec<_>>();
7272

73-
let commit_oid = if config.get_bool("commit.gpgsign")? {
73+
let commit_oid = if config
74+
.get_bool("commit.gpgsign")
75+
.unwrap_or(false)
76+
{
7477
// Generate commit content
7578
let commit_bufffer = repo.commit_create_buffer(
7679
&signature,
@@ -85,17 +88,18 @@ pub fn commit(repo_path: &str, msg: &str) -> Result<CommitId> {
8588

8689
// Prepare to sign using the designated key in the user's git config
8790
let mut gpg_ctx = Context::from_protocol(Protocol::OpenPgp)?;
88-
let key =
89-
gpg_ctx.get_key(config.get_string("user.signingkey")?)?;
90-
gpg_ctx.add_signer(&key)?;
91+
if let Ok(key_id) = config.get_string("user.signingkey") {
92+
let key = gpg_ctx.get_key(key_id)?;
93+
gpg_ctx.add_signer(&key)?;
94+
}
9195
gpg_ctx.set_armor(true);
9296

9397
// Create GPG signature for commit content
9498
let mut signature_buffer = Vec::new();
9599
gpg_ctx
96100
.sign_detached(&*commit_bufffer, &mut signature_buffer)?;
97-
let gpg_signature =
98-
std::str::from_utf8(&signature_buffer).unwrap();
101+
let gpg_signature = std::str::from_utf8(&signature_buffer)
102+
.expect("Buffer was not valid UTF-8");
99103

100104
let commit_oid = repo.commit_signed(
101105
&commit_content,

0 commit comments

Comments
 (0)